Start the interactive agentic loop against a running sandbox VM.
(
model: str = "claude-sonnet-4-5",
mcp_url: str = "http://localhost:7002/mcp",
output_dir: str | None = None,
temperature: float = 0.2,
)
| 49 | |
| 50 | |
| 51 | def run_loop( |
| 52 | model: str = "claude-sonnet-4-5", |
| 53 | mcp_url: str = "http://localhost:7002/mcp", |
| 54 | output_dir: str | None = None, |
| 55 | temperature: float = 0.2, |
| 56 | ) -> None: |
| 57 | """Start the interactive agentic loop against a running sandbox VM.""" |
| 58 | from harness.paths import ensure_runtime_dirs, init_run_env |
| 59 | |
| 60 | load_dotenv(find_dotenv(), override=True) |
| 61 | ensure_runtime_dirs() |
| 62 | _run_id, host_run = init_run_env("agentic_loop") |
| 63 | if output_dir is None: |
| 64 | output_dir = str(host_run) |
| 65 | else: |
| 66 | output_dir = str(Path(output_dir).expanduser().resolve()) |
| 67 | Path(output_dir).mkdir(parents=True, exist_ok=True) |
| 68 | |
| 69 | config = LoopConfig( |
| 70 | model=model, |
| 71 | mcp_url=mcp_url, |
| 72 | temperature=temperature, |
| 73 | output_dir=output_dir, |
| 74 | ) |
| 75 | |
| 76 | mcp_client = MCPClient(url=config.mcp_url) |
| 77 | llm_client = LLMClient() |
| 78 | |
| 79 | host_out = Path(output_dir) |
| 80 | # Mirror the host-side layout inside the container so each loop session's |
| 81 | # logs live under /workspace/outputs/<run_name>/ rather than at the |
| 82 | # /workspace root. |
| 83 | sandbox_out = f"outputs/{host_out.name}" |
| 84 | logger = Logger( |
| 85 | mcp_client, |
| 86 | log_file=f"{sandbox_out}/agent_run.log", |
| 87 | to_stdout=True, |
| 88 | host_log_path=host_out / "agent_run.log", |
| 89 | event_log_path=f"{sandbox_out}/agent_events.log", |
| 90 | host_event_log_path=host_out / "agent_events.log", |
| 91 | ) |
| 92 | |
| 93 | loop = AgenticLoop(mcp_client, llm_client, config, logger) |
| 94 | try: |
| 95 | loop.run_interactive() |
| 96 | finally: |
| 97 | mcp_client.close() |
| 98 | |
| 99 | |
| 100 | def main(): |
no test coverage detected