Skip to content

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

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

feat(agent): add durable agent invocations and spawning#1065
dcramer wants to merge 8 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 use isolated child conversations; named agents reuse their child conversation and prior agent history. Different named agents can run concurrently, repeated tool calls are 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. The runtime keeps parent identity, actor, credentials, routing, and idempotency bound to the active run, and the tool returns only a durable invocation handle. Child creation shares the root conversation mutation lock with retention purge, and bindings and invocations are deleted with the conversation tree.

Child work uses the existing provider-neutral mailbox worker. Local chat processes child wakes in-process, while production continues to use Vercel Queues. The rebased schema change is generated as migration 0012_sour_vargas after the newer conversation-history and reporting migrations on main.

SQL-backed regression coverage exercises isolated and named agents, history and reasoning reuse, concurrent replay, overlap rejection, sibling failure isolation, validation failure, recovery, and retention cleanup. 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 30, 2026 5:50pm

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

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 b3aea1f. Configure here.

}
if (!context.attempt.isFinalAttempt) {
throw error;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stranded child never terminates

High Severity

recoverRunningSession throws when a stranded running child has no model or no resumable boundary, but empty resume wakes set isFinalAttempt to false, so the catch rethrows instead of failing the invocation. The worker then re-wakes forever while status stays running, which also keeps a named agent permanently busy.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b3aea1f. Configure here.

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