Skip to main content

execute_run_task

Function execute_run_task 

Source
pub async fn execute_run_task(
    params: RunTaskParams,
    llm: Arc<dyn InferenceAdapter>,
) -> RunReport
Expand description

Execute a run-task end-to-end and return the rendered report.

Why: The single orchestration entry point the binary calls (with a real LlmClient) and tests call (with a scripted mock). Keeping the LLM client as an injected Arc<dyn InferenceAdapter> is what makes the whole path testable offline without a network call or an API key. What: Loads the PM config, assembles its prompt (BASE + PM prompt + project CLAUDE.md), builds the engineer runner (fs/bash scoped to the project, with the optional per-run model override), wraps it in the PM’s DelegateToAgentTool, snapshots the working tree, runs the PM AgentLoop (#2265 fix #5: wired with with_stop_signal against the SAME redelegation_signal the engineer runner shares, so the PM stops issuing delegate_to_agent calls the turn after the re-delegation cap latches instead of spinning through its remaining turns on doomed retries), snapshots again, and assembles a RunReport (diff + transcript + usage/cost + exit code). A PM-config or loop error yields a ConfigError/RunFailure report rather than a panic. Test: run_task::tests::end_to_end_pm_delegates_to_engineer, diff_reflects_engineer_file_change, usage_and_cost_aggregate_end_to_end, exit_code_reflects_run_failure, run_wide_ceiling_stops_the_pm_loop_and_ends_partial_promptly.