Subagents in the unrolled agent loop
- Lenguaje dominante
- Rust
- Estrellas
- 54.2k
- Forks
- 6.2k
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 240
Descripción
Summon remains a platform tool that schedules subagents, while other callers may schedule them through the same interface. Scheduling creates a child session containing its provider, model, extensions, recipe, working directory, parent session, and execution mode. Execution mode is a new persisted session field; everything else is already stored on the session. The delegate call answers immediately with the child session ID, so the parent tool request is never left pending and later results are correlated by session ID.
Every child receives the existing final-output tool. A recipe may define its schema; otherwise the tool uses a default object schema with one required summary string. A successful final-output call is the persisted signal that the child has finished, and its arguments are the result returned to the parent. Results are always read from the child conversation rather than live runtime state, so completed children behave the same whether their runtime still exists or not.
ForegroundSubagentOperation discovers foreground children from their sessions. It runs after tool execution, allowing sibling tool calls to keep their current priority, but before the machine would otherwise end the parent turn. It reconstructs unfinished child pipelines and steps them concurrently, applying each completed step to its child session. When a child produces its final output, the operation appends an agent-visible, user-hidden message containing the child session ID and result, then lets the parent react. An operation note on that message records delivery. If the parent yields, the remaining children stay at their last persisted boundaries and are reconstructed when it resumes.
Both subagent operations receive a shared registry of live child runtimes keyed by session ID. The registry keeps expensive runtime resources, such as loaded extensions, but contains no conversation, configuration, or result state. ForegroundSubagentOperation rebuilds child pipelines around these runtimes. A cold start constructs a runtime only when none exists, such as after a process restart. A runtime is removed when the child produces its final output or is cancelled.
BackgroundSubagentOperation also receives a manager supplied by the caller. The manager keeps the running task, cancellation token, and completion signal for each background child, allowing it to continue after the parent yields or its pipeline is dropped. The operation starts scheduled children and reconnects to existing tasks, while Summon exposes their status, result, and cancellation through its tools. A successful final-output call means completed, a recorded failure means failed, and a live manager entry means running. An incomplete foreground child without a runtime is reconstructed; an incomplete background child without a task after restart is recorded as failed.
Until the legacy loop is retired, delegate keeps its current blocking implementation outside the state machine. Under GOOSE_STATE_MACHINE=1, it schedules the child and lets the two subagent operations manage execution and delivery.
Guía de contribución
Línea de trabajo
The issue describes implementing subagents in an unrolled agent loop. Start by examining the existing delegate implementation and the session structure. Look for the state machine flag GOOSE_STATE_MACHINE=1 and the planned ForegroundSubagentOperation and BackgroundSubagentOperation. Understanding the session lifecycle, tool execution order, and how child runtimes are managed is key. 'Done' means subagents can be scheduled, executed concurrently, and their results delivered to the parent agent via the described operations.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- ai-infra-agents
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100