feat: add runtime discovery and execution traces
This commit is contained in:
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
from cross_eval.agent import AgentInvocationError, invoke_agent, invoke_agent_agentic
|
||||
from cross_eval.worktree import WorktreeError
|
||||
from cross_eval.config import try_reload_config
|
||||
from cross_eval.discovery import discover_repo, format_repo_discovery
|
||||
from cross_eval.models import (
|
||||
AgentConfig,
|
||||
AgentResult,
|
||||
@@ -804,6 +805,7 @@ def _execute_step(
|
||||
|
||||
# 8. Save to disk
|
||||
_save_step_output(run_dir, output_iter, step.name, result.output)
|
||||
_maybe_save_step_transcript(run_dir, output_iter, step.name, result)
|
||||
|
||||
|
||||
def _execute_parallel_batch(
|
||||
@@ -929,6 +931,7 @@ def _execute_parallel_batch(
|
||||
step.name, r.duration_seconds, len(r.output),
|
||||
)
|
||||
_save_step_output(run_dir, output_iter, step.name, r.output)
|
||||
_maybe_save_step_transcript(run_dir, output_iter, step.name, r)
|
||||
|
||||
if errors:
|
||||
spinner.stop(f"[parallel] FAILED ({batch_elapsed}s)")
|
||||
@@ -1001,10 +1004,12 @@ def _build_runtime_inputs(
|
||||
) -> dict[str, str]:
|
||||
"""Load runtime env and expose safe execution hints to prompts."""
|
||||
env, loaded_files, loaded_values = build_runtime_environment(config.execution, cwd)
|
||||
discovery = discover_repo(cwd, set(loaded_values) | set(env))
|
||||
input_contents["execution_policy"] = build_execution_policy(config.execution)
|
||||
input_contents["environment_context"] = summarize_environment(
|
||||
config.execution, loaded_files, env, loaded_values,
|
||||
)
|
||||
input_contents["repo_discovery"] = format_repo_discovery(discovery)
|
||||
return env
|
||||
|
||||
|
||||
@@ -1018,6 +1023,8 @@ def _augment_prompt_with_runtime_context(
|
||||
extras.append("## Execution Policy\n" + context["execution_policy"])
|
||||
if context.get("environment_context"):
|
||||
extras.append("## Environment Context\n" + context["environment_context"])
|
||||
if context.get("repo_discovery"):
|
||||
extras.append("## Repository Discovery\n" + context["repo_discovery"])
|
||||
if not extras:
|
||||
return prompt
|
||||
return prompt.rstrip() + "\n\n" + "\n\n".join(extras) + "\n"
|
||||
@@ -1198,6 +1205,20 @@ def _save_step_output(
|
||||
return path
|
||||
|
||||
|
||||
def _maybe_save_step_transcript(
|
||||
run_dir: Path,
|
||||
iteration: int,
|
||||
step_name: str,
|
||||
result: AgentResult,
|
||||
) -> Path | None:
|
||||
"""Persist raw stdout/stderr transcript when available."""
|
||||
if not result.transcript:
|
||||
return None
|
||||
return _save_step_output(
|
||||
run_dir, iteration, f"{step_name}_transcript", result.transcript,
|
||||
)
|
||||
|
||||
|
||||
def _format_runtime_error_markdown(
|
||||
exc: Exception,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user