Skip to main content

Module run_task

Module run_task 

Source
Expand description

tcode run-task end-to-end execution layer (#1034, #1035).

Why: This is the orchestration closer that makes the tcode binary run a task for real — load project context, assemble the PM prompt, run the PM loop, let it delegate to the engineer in-process, capture the diff + transcript + usage, and render a human or JSON report with meaningful exit codes. The LLM client is injected so the whole path is testable offline with a scripted mock. What: RunTaskParams, execute_run_task, RunReport, ExitCode, and the transcript types (TurnRecord, SharedTranscript, RecordingLlmClient). Test: run_task::tests::* (all offline, mocked LLM). tcode run-task end-to-end execution (#1034, #1035).

Why: This is the closer that makes the tcode binary actually run a task. It wires every M1 piece together: load the project CLAUDE.md context (#1033), assemble the PM system prompt, run the PM through an AgentLoop against the real (or mocked) LlmClient, let the PM delegate to the python-engineer via the DelegateToAgentTool + InProcessAgentRunner, and have the engineer run its own loop with fs/bash tools scoped to the project. The run captures a diff of the working tree, the PM+engineer transcript, and aggregated token/cost usage, then renders both a human and a JSON report with meaningful exit codes. What: RunTaskParams carries the CLI inputs; execute_run_task is the async orchestrator returning a RunReport. The LLM client is injected so production passes a real LlmClient and tests pass a scripted mock — no live key needed. Test: run_task::tests drive the whole PM→engineer path offline.

Structs§

RecordingLlmClient
A transparent LlmClientTrait that records each turn into a shared transcript.
RedelegationCapSignal
Shared signal tracking total re-delegation attempts across one run (#2265).
RunReport
The full result of a run-task invocation, ready to render.
RunTaskParams
Inputs to a single run-task invocation, parsed from the CLI.
TurnRecord
One recorded assistant turn for the run transcript.

Enums§

ExitCode
Distinct process exit codes for a run-task invocation.

Constants§

MAX_REDELEGATIONS
Maximum total engineer delegation attempts for a single execute_run_task run, shared across every delegate_to_agent call the PM makes (#2265).

Functions§

aggregate_usage_per_role
Sum every transcript turn’s usage, pricing EACH turn against its OWN role’s resolved model rather than blending the whole transcript under one model (#1475 bug 1 fix).
execute_run_task
Execute a run-task end-to-end and return the rendered report.
resolve_agent_model_slug
Resolve an agent’s model slug, honouring an optional per-run override (#1035, #1475 bug 1 fix’s prerequisite).

Type Aliases§

SharedTranscript
Shared, thread-safe transcript accumulator.