feat(agent): add durable agent invocations and spawning - #1065
Draft
dcramer wants to merge 7 commits into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds durable agent invocations and a
spawnAgenttool 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
SpawnAgentfunction 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