agora.fleet.stage_runner
Micro-stage task execution.
A StagedTask splits one logical task into a sequence of focused LLM
calls. Each Stage gets its own fresh message history, a small
max_iterations cap, and only the files it needs pre-loaded into the user
message. The task’s postconditions are evaluated once at the end over whatever
the cumulative stages produced.
- Two wins for weak models:
Fresh context per stage — no 37-message accumulation blowing past num_ctx.
One action per stage — the model decides less, hallucinates less.
Classes
One focused LLM call in a staged task — OR a declarative decision stage. |
|
Execute a |
|
A |
- class agora.fleet.stage_runner.Stage[source]
Bases:
objectOne focused LLM call in a staged task — OR a declarative decision stage.
When
kind == "llm"(the default),instruction+context_filesfeed a user-message into the agent’s tool-use loop bounded bymax_iterations. Whenkind == "decision",decision_id/question/options/output_pathdescribe a Matrix poll + reaction card the framework posts on the LLM’s behalf; no LLM call is made. The dispatch happens inStageRunner.execute_staged_task.- instruction: str = ''
The user-message for this stage. Should describe ONE action. Empty when
kind='decision'.
- context_files: tuple[str, ...] = ()
Files (relative to work_dir) to include verbatim in the user message.
- validation: Callable[[ToolContext], tuple[bool, str]] | None = None
Optional check run after the stage completes. Returns
(ok, reason).
- __init__(instruction='', context_files=(), max_iterations=5, validation=None, name='', kind='llm', decision_id='', question='', options=(), output_path='', validation_args=<factory>, hide_tools=())
- class agora.fleet.stage_runner.StagedTask[source]
Bases:
objectA
Taskaugmented with an ordered sequence of stages.The wrapped
Taskprovides the id, spec, postconditions, and agent assignment. The stages drive the actual LLM calls.- __init__(task, stages=<factory>)
- class agora.fleet.stage_runner.StageRunner[source]
Bases:
objectExecute a
StagedTaskstage-by-stage, then evaluate the task spec.Built for hard-to-generate tasks where a single 20-iteration loop blows past num_ctx or lets the model drift. The runner reuses the underlying
AgentRuntimemachinery (system prompts, tool execution, postcondition evaluation) but resets the message history at every stage boundary, capping per-stage iterations aggressively. Two wins for weak models: fresh context per stage so accumulated tokens don’t pile up, and one-action stages so the model decides less and hallucinates less.Three stage kinds are dispatched here:
"llm"(default) — a focused agent turn against the configured LLM."decision"— bypasses the LLM, posts a Matrix poll + reaction card, waits for the user’s answer, writes the chosen option id tostage.output_path."framework"— pure mechanical step (e.g.framework_finalize_plan) that the framework executes itself rather than asking the LLM.
- async execute_staged_task(staged, identity)[source]
Run every stage in order, then evaluate the wrapped task’s postconditions.
Returns the same
TaskResultshape as a non-staged task — postconditions are checked once at the end over the cumulative artefacts, so callers can treat staged and non-staged tasks uniformly.On stage failure (validation predicate returns False, decision-stage timeout, framework-stage exception), the runner short-circuits and returns a failure result without running later stages. The remaining stages do not execute.