Add optional async sub-agent delegation with report-back and wait control - #111
Add optional async sub-agent delegation with report-back and wait control#111TommyBez wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (5)
WalkthroughThis PR extends the sub-agent invocation system to support parent-agent completion reporting. The invocation event payload gains a ChangesParent-agent completion reporting feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 881e8e7dec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }) | ||
| await finishInvocationStreams(streamNamespaces) | ||
| await forwardPromise | ||
| await maybeReportBackToParent({ |
There was a problem hiding this comment.
Make parent report-back failures non-fatal
Awaiting maybeReportBackToParent in the main try means any dispatch error (for example, parent agent deleted/disabled between queue and completion, or a transient DB failure) is treated as a child-run failure, because control falls into failInvocation after the child result has already been finalized. This mislabels successful async sub-agent runs as failed and can break monitoring/automation that depends on run status.
Useful? React with 👍 / 👎.
| `Sub-agent "${input.childName}" completed delegated async work.`, | ||
| `Result: ${input.finalText}`, | ||
| ].join('\n'), | ||
| streamToken: `report_back_${Date.now().toString(36)}`, |
There was a problem hiding this comment.
Use collision-resistant token for report-back invocation
The report-back streamToken is derived only from Date.now(), but dispatchInvocation builds idempotency keys from parentToolCallId ?? streamToken (with parentRunId set to root here). If two async children report back to the same parent within the same millisecond, they generate the same idempotency key and one event is dropped by the unique idempotency constraint, causing a lost completion notification.
Useful? React with 👍 / 👎.
Motivation
Description
parentAgentIdandreportBackToParentthroughagent-event-store,session-events, and the eventworkflowhandler.waitForCompletionoption to the sub-agent tool (tools/sub-agents/agent-tool.ts) to control whether the parent waits for the child run or returns immediately.waitForCompletionis false, the tool queues the child run and returns immediately with a started message; when true, it collects child messages and returns the final text as before.maybeReportBackToParentin the invocation handler to dispatch a short invocation back to the parent agent with the child final text whenreportBackToParentis set, plus helpersresolveAgentUserIdandextractFinalAssistantText.Testing
Codex Task
Summary by CodeRabbit
waitForCompletionoption—tasks can run asynchronously without blocking for results.