Skip to content

feat(agent): add durable agent invocations and spawning - #1065

Draft
dcramer wants to merge 7 commits into
mainfrom
codex/durable-agent-invocations
Draft

feat(agent): add durable agent invocations and spawning#1065
dcramer wants to merge 7 commits into
mainfrom
codex/durable-agent-invocations

Conversation

@dcramer

@dcramer dcramer commented Jul 27, 2026

Copy link
Copy Markdown
Member

Adds durable agent invocations and a spawnAgent tool so a parent agent can schedule named or one-off child work through Junior's existing conversation mailbox and lease worker. Unnamed invocations get isolated child conversations; completed named children reuse their conversation and prior Pi history. Different children run concurrently, replaying the same tool call is idempotent, overlapping work for one name is rejected, and one child's failure does not affect its siblings.

The model supplies only the task, optional name, and optional reasoning level. Runtime-owned parent identity, actor, credentials, routing, and idempotency stay bound to the active run. The tool returns only a durable invocation handle; child identity and lifecycle state remain internal. The implementation uses one bound SpawnAgent function rather than creator/control objects or service-style wrappers.

Child creation shares the root conversation mutation lock with retention purge. Bindings and invocations are retained and deleted with the conversation tree. Local chat processes child wakes in-process through the same provider-neutral mailbox worker; production continues to use Vercel Queues.

The SQL-backed integration coverage exercises the real mailbox, routing, lease, session, and terminal-state paths for isolated unnamed agents, named-agent reuse with history and inherited reasoning, parallel named agents, concurrent idempotent replay, same-name overlap rejection, sibling failure isolation, final-attempt validation failure, and retention cleanup. Live QA also ran a real parent with two real children concurrently and verified both terminal results. The full Junior suite passes: 302 files and 2,255 tests, plus typecheck, lint, dependency-boundary checks, and the production build.

This slice returns invocation handles. Parent result delivery, deterministic result recovery, cancellation, and recursive children remain follow-up work on #880.

Fixes #879
Refs #880

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Jul 27, 2026 11:57pm

Request Review

@dcramer dcramer changed the title feat(agent): add durable agent invocations feat(agent): add durable agent invocations and spawning Jul 27, 2026
Comment thread packages/junior/src/chat/agent-invocations/store.ts Outdated
Comment thread packages/junior/src/chat/conversations/sql/purge.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f059311. Configure here.

Comment thread packages/junior/src/chat/agent-invocations/work.ts Outdated
Comment thread packages/junior/src/cli/chat.ts
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.

Add durable agent bindings and child execution

1 participant