Skip to content

Reporter

generate_report(user_request, plan, execution_result, verification_result, html=False, profile='chem')

Create a deterministic Markdown or HTML execution report.

Source code in src/cspilot/agents/reporter.py
def generate_report(
    user_request: str,
    plan: dict[str, Any],
    execution_result: dict[str, Any],
    verification_result: dict[str, Any],
    html: bool = False,
    profile: str = "chem",
) -> str:
    """Create a deterministic Markdown or HTML execution report."""
    selected_profile = get_profile(profile)
    sections = _report_sections(
        user_request,
        plan,
        execution_result,
        verification_result,
        profile,
        selected_profile.default_output_style,
    )
    if html:
        return _as_html(sections)
    return _as_markdown(sections)

make_report(user_request, tool_results, verification)

Build a plain-text report strictly from returned tool data.

Source code in src/cspilot/agents/reporter.py
def make_report(
    user_request: str,
    tool_results: list[dict[str, Any]],
    verification: dict[str, Any],
) -> str:
    """Build a plain-text report strictly from returned tool data."""
    lines = [f"Request: {user_request}"]
    if verification.get("workdir"):
        lines.append(f"Workdir: {verification['workdir']}")
    if not tool_results:
        lines.append("No tool results were returned.")
    for index, result in enumerate(tool_results, start=1):
        name = str(result.get("tool_name", f"step_{index}"))
        status = result.get("status", "returned")
        lines.append(f"Step {index} ({name}): {status}.")
        workdir = result.get("workdir") or result.get("run_dir")
        if workdir and workdir != verification.get("workdir"):
            lines.append(f"Workdir: {workdir}")
        for key, value in _reported_values(result):
            lines.append(f"{key}: {value}")
        files = _generated_files(result)
        if files:
            lines.append("Generated files: " + ", ".join(files))

    if verification.get("verified"):
        lines.append("Verification: passed.")
    else:
        lines.append("Verification: failed or incomplete.")
        for issue in verification.get("issues", []):
            lines.append(f"Issue: {issue}")
    return "\n".join(lines)