3.0 KiB
07.1 — Sub-agent pipeline as a subgraph
Convert subagent_runner/ "prepare prompt → filter tools → run child →
checkpoint/handback → mirror transcript" into an explicit graph.
Current status (2026-07-02): tinyagents/subagent_graph.rs defines and exports
the fixed pipeline topology, and run_typed_mode now runs that graph as a
best-effort diagnostic skeleton before continuing through the procedural runner.
The skeleton records the named phases with GraphTracingSink; the node effects
remain pending and can be moved over one phase at a time without changing the
external sub-agent behavior. The live child turn loop is still
run_subagent_via_graph: it already uses the shared TinyAgents harness for
steering, early exit, cap summaries, transcript persistence, and usage
aggregation, but it is not yet a SubAgentSession/subagent_node graph
implementation. The standalone ops/usage.rs glue file is deleted; the
remaining AggregatedUsage bridge lives with the graph route that produces it,
and the oversized-result apply_handoff helper now lives beside
ResultHandoffCache in handoff.rs instead of under ops/.
Steps
- Partially done: define
build_subagent_pipeline_graph(now intinyagents/subagent_graph.rsor undersubagent_runner/): nodesresolve_definition(registry lookup + allowlist) →prepare_context(parent ctx, memory, action root, sandbox) →assemble_prompt→expose_tools(uses 01.3 selection middleware) →run_child(harness leaf viasubagent_nodeor directrun_turn_via_tinyagents_shared) →finalize(checkpoint/ awaiting-user handback, worker-thread mirror, handoff cache). Follow the establishedbuild_*_graph+*_topology()pattern; topology export exists, but node effects are still diagnostic placeholders. - Partially done:
run_typed_mode(ops/runner.rs, the single chokepoint) invokes the compiled subgraph for diagnostic tracing before continuing through the procedural runner;AgentGraph::Customrunners still plug in as alternaterun_childleaves. - Child lineage: run with parent depth/events (
invoke_in_parentsemantics) soroot_run_idrollup +SubAgentStarted/Completed/Reusedevents are native; usage rollup viaChildRun.usage(feeds 06.3). - Fold
ops/{provider,prompt,checkpoint}.rsplumbing into node implementations;ops/graph.rsshrinks to the leaf. - Reusable child sessions: map the follow-up/continue flows onto
SubAgentSession(send,transcript(),reset()).
Deletions
- Deleted:
subagent_runner/ops/usage.rsglue. - Deleted:
subagent_runner/ops/handoff_helper.rsglue;apply_handoffmoved tosubagent_runner/handoff.rs. - Remaining: parts of
ops/runner.rs/ops/graph.rsabsorbed by nodes (target:ops/*shrinks to policy nodes + tests).
Acceptance
- Sub-agent e2e parity (ops_tests 1689-line suite green or rewritten against graph events); topology export validates; checkpoint/handback and worker-thread mirroring unchanged from the outside.