Skip to main content
Glama

validate_debug_completion

Validates that post-run debug artifacts (JSON and log file) exist and contain required content. Checks artifact JSON keys and log markers, returning any errors found.

Instructions

Validate post-run debug artifacts landed on disk with the right shape.

    Three deterministic checks:
    - STR-001: ``selected_robust_trial.json`` + log file both exist.
    - VAL-003: artifact JSON parses and carries every required top-level key.
    - BT-010: log contains each required marker substring (order irrelevant).

    Args:
        artifact_path: Absolute path to the JSON artifact (typically
            ``<workspace>/backtest/selected_robust_trial.json``).
        log_path: Absolute path to the debug log file.
        required_json_keys: Top-level keys expected on the artifact.
            Defaults to ``["trial_number", "params", "metrics"]``.
        required_log_markers: Substrings expected in the log. Defaults
            to ``["STAGE 4 COMPLETE", "STAGE 5 COMPLETE", "FINAL SUCCESS"]``.

    Returns ``{"any_errors": bool, "findings": [{"code", "message",
    "context"}, ...]}``. Never raises — parse / file-access failures
    surface as findings with the appropriate error code.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artifact_pathYes
log_pathYes
required_json_keysNo
required_log_markersNo

Implementation Reference

  • Core implementation of validate_debug_completion. Performs three deterministic checks: STR-001 (artifact/log existence), VAL-003 (JSON shape keys), BT-010 (log marker presence). Returns a Report object.
    def validate_debug_completion(
        artifact_path: "Path | str",
        log_path: "Path | str",
        required_json_keys: Iterable[str] = _DEFAULT_REQUIRED_JSON_KEYS,
        required_log_markers: Iterable[str] = _DEFAULT_REQUIRED_LOG_MARKERS,
    ) -> Report:
        """Return a ``Report`` with findings for every problem detected.
    
        Parameters
        ----------
        artifact_path
            Path to the JSON artifact (typically
            ``<workspace>/backtest/selected_robust_trial.json``).
        log_path
            Path to the debug log file.
        required_json_keys
            Top-level keys expected on the artifact JSON.
        required_log_markers
            Substrings expected somewhere in the log (order irrelevant).
        """
        report = Report()
        artifact_path = Path(artifact_path)
        log_path = Path(log_path)
        required_json_keys = tuple(required_json_keys)
        required_log_markers = tuple(required_log_markers)
    
        # --- Artifact existence + JSON shape ------------------------------------
        if not artifact_path.exists():
            report.add(Finding(
                code="STR-001",
                message=f"Required artifact missing: {artifact_path}",
                context={"file": str(artifact_path)},
            ))
        else:
            try:
                payload = json.loads(artifact_path.read_text(encoding="utf-8"))
            except json.JSONDecodeError as e:
                report.add(Finding(
                    code="VAL-003",
                    message=f"Artifact is not valid JSON: {e}",
                    context={
                        "file": str(artifact_path),
                        "missing_keys": list(required_json_keys),
                        "present_keys": [],
                    },
                ))
            else:
                missing = [k for k in required_json_keys if k not in payload]
                if missing:
                    report.add(Finding(
                        code="VAL-003",
                        message=f"Artifact missing required keys: {missing}",
                        context={
                            "file": str(artifact_path),
                            "missing_keys": missing,
                            "present_keys": sorted(payload.keys()),
                        },
                    ))
    
        # --- Log file existence + marker presence -------------------------------
        if not log_path.exists():
            report.add(Finding(
                code="STR-001",
                message=f"Log file missing: {log_path}",
                context={"file": str(log_path)},
            ))
        else:
            log_text = log_path.read_text(encoding="utf-8")
            missing_markers = [m for m in required_log_markers if m not in log_text]
            if missing_markers:
                last_seen: str | None = None
                for marker in required_log_markers:
                    if marker in log_text:
                        last_seen = marker
                report.add(Finding(
                    code="BT-010",
                    message=f"Required log markers absent: {missing_markers}",
                    context={
                        "log_path": str(log_path),
                        "missing_marker": missing_markers,
                        "last_marker_seen": last_seen,
                    },
                ))
    
        return report
  • Finding and Report dataclasses used by the validator. Finding holds code/message/context. Report aggregates findings and provides to_dict() for MCP serialization.
    @dataclass
    class Finding:
        """One issue surfaced by a validator.
    
        ``code`` is an error-catalog code (STR-*, VAL-*, PRM-*, IND-*, BT-*).
        ``message`` is a short human-readable summary.
        ``context`` carries the structured key/value fix-template fields from
        the catalog entry so downstream consumers can format remediation
        guidance deterministically.
        """
    
        code: str
        message: str
        context: Dict[str, Any] = field(default_factory=dict)
    
    
    @dataclass
    class Report:
        """Aggregate of findings from one validator call.
    
        A validator returns one ``Report``. The caller can inspect
        ``any_errors`` as a one-shot gate, or iterate ``findings`` to surface
        every issue at once. ``to_dict()`` produces the JSON-serializable
        form the MCP tool wrappers return to agents.
        """
    
        findings: List[Finding] = field(default_factory=list)
    
        def add(self, finding: Finding) -> None:
            self.findings.append(finding)
    
        @property
        def any_errors(self) -> bool:
            return len(self.findings) > 0
    
        def to_dict(self) -> Dict[str, Any]:
            return {
                "any_errors": self.any_errors,
                "findings": [asdict(f) for f in self.findings],
            }
  • MCP tool registration via @server.tool() decorator. Defines the tool signature (artifact_path, log_path, required_json_keys, required_log_markers) and delegates to the core implementation. Converts Report to dict.
    @server.tool()
    def validate_debug_completion(
        artifact_path: str,
        log_path: str,
        required_json_keys: list[str] | None = None,
        required_log_markers: list[str] | None = None,
    ) -> dict:
        """Validate post-run debug artifacts landed on disk with the right shape.
    
        Three deterministic checks:
        - STR-001: ``selected_robust_trial.json`` + log file both exist.
        - VAL-003: artifact JSON parses and carries every required top-level key.
        - BT-010: log contains each required marker substring (order irrelevant).
    
        Args:
            artifact_path: Absolute path to the JSON artifact (typically
                ``<workspace>/backtest/selected_robust_trial.json``).
            log_path: Absolute path to the debug log file.
            required_json_keys: Top-level keys expected on the artifact.
                Defaults to ``["trial_number", "params", "metrics"]``.
            required_log_markers: Substrings expected in the log. Defaults
                to ``["STAGE 4 COMPLETE", "STAGE 5 COMPLETE", "FINAL SUCCESS"]``.
    
        Returns ``{"any_errors": bool, "findings": [{"code", "message",
        "context"}, ...]}``. Never raises — parse / file-access failures
        surface as findings with the appropriate error code.
        """
        from echolon.strategy.validators.debug_completion import (
            validate_debug_completion as _impl,
        )
        kwargs = {}
        if required_json_keys is not None:
            kwargs["required_json_keys"] = required_json_keys
        if required_log_markers is not None:
            kwargs["required_log_markers"] = required_log_markers
        report = _impl(artifact_path=artifact_path, log_path=log_path, **kwargs)
        return report.to_dict()
  • Re-exports Finding and Report from the validators package so debug_completion.py can import them via 'from echolon.strategy.validators import Finding, Report'.
    from echolon.strategy.validators._report import Finding, Report
    
    __all__ = ["Finding", "Report"]
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It clearly states the tool never raises exceptions and surfaces failures as findings with error codes, which is transparent about error handling. However, other behavioral aspects (e.g., performance, side effects) are not covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with bullet points and code formatting, front-loading the purpose. It is slightly lengthy due to detailed parameter docs, but each sentence adds value. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description explains the return format. With 4 parameters and 2 required, all are documented. The tool is simple (validation-only), and the description covers behavior, parameters, and returns adequately for an agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description thoroughly explains each parameter with examples, defaults, and expected formats (e.g., artifact_path: absolute path; required_json_keys defaults). This adds significant meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool validates post-run debug artifacts and lists three deterministic checks with codes (STR-001, VAL-003, BT-010), making the purpose highly specific and distinct from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for post-run validation but provides no guidance on when to use this tool versus alternatives (e.g., other validation tools). No exclusions or conditions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DolphinQuant/echolon'

If you have feedback or need assistance with the MCP directory API, please join our Discord server