Skip to content

feat(agent): add runSubagent primitive for subagent spawning#23

Merged
codex-mohan merged 1 commit into
mainfrom
feat/subagent-primitive
Jun 23, 2026
Merged

feat(agent): add runSubagent primitive for subagent spawning#23
codex-mohan merged 1 commit into
mainfrom
feat/subagent-primitive

Conversation

@codex-mohan

Copy link
Copy Markdown
Owner

Adds a reusable
unSubagent() function to the agent SDK that creates a fresh-context child Agent with:

  • Model override: modelOverride ?? model for delegating to cheaper models
  • Optional Budget: maxTurns / maxTokens / imeoutMs — all uncapped by default
  • Signal forwarding: parent abort propagates to child
  • Separate event stream: onEvent callback for child events (keeps parent stream clean, background-ready)
  • Structured result: SubagentResult { text, usage, messages, aborted, error? }

The parent agent only sees
esult.text via the tool result. The full transcript (
esult.messages) is available for the caller to persist — it's isolated from the parent's context.

Layer 1 only (SDK). App-layer persistence (child sessions), background mode, and task resumption deferred.

Adds a reusable runSubagent() function to the agent SDK that creates
a fresh-context child Agent with model override, optional Budget
(maxTurns/maxTokens/timeoutMs — all uncapped by default), signal
forwarding, and a separate onEvent event stream.

Returns SubagentResult with final text (for parent), full transcript
messages (for caller persistence), and accumulated usage. The parent
agent only sees the final text — the full transcript is isolated and
available for the caller to persist to a child session.

Background mode and task resumption are deferred to the app layer;
permissions stay in the code layer.
@codex-mohan codex-mohan merged commit 2c8c32a into main Jun 23, 2026
1 check passed
@codex-mohan codex-mohan deleted the feat/subagent-primitive branch June 23, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant