Repository navigation
fix: queue subagent completion handoffs - #88613
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2612603888
ℹ️ 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".
| if (entry.cleanupHandled === true && !staleLease) { | ||
| continue; | ||
| } | ||
| if (payload.requesterSessionKey !== requesterSessionKey) { |
There was a problem hiding this comment.
Route queued handoffs through ancestor requesters
When a nested subagent finishes after its immediate parent session has ended, runSubagentAnnounceFlow() can fall back via resolveRequesterForChildSession() and attempt delivery to the ancestor requester, but the durable PendingFinalDeliveryPayload still names the inactive immediate requester. This exact key comparison means the next turn in the active ancestor session never leases that suspended payload, so the queued completion remains stuck until suspended-delivery expiry instead of being surfaced to the orchestrator. Please either persist the resolved fallback requester in the payload or select handoffs through the requester ancestry.
Useful? React with 👍 / 👎.
Summary
Refs #88312, #87744, #88352, #88580.
Verification
node scripts/run-vitest.mjs src/agents/subagent-handoff-queue.test.ts src/agents/subagent-registry.test.ts src/agents/subagent-registry.persistence.test.ts src/agents/subagent-registry.lifecycle-retry-grace.e2e.test.ts src/agents/embedded-agent-runner/run/attempt.queue-message.test.tsnode scripts/run-tsgo.mjs -p tsconfig.core.json --incremental falsepnpm check:import-cycles.agents/skills/autoreview/scripts/autoreview --mode localBehavior addressed: pending subagent completion reports can be merged and injected on the requester's next turn instead of depending only on an active streaming parent run.
Real environment tested: local OpenClaw checkout on macOS plus Blacksmith Testbox attempt.
Exact steps or command run after this patch: focused Vitest shards, core tsgo, import-cycle check, Codex autoreview;
pnpm check:changeddelegated to Blacksmith Testbox.Evidence after fix: focused tests passed, tsgo passed, import cycles reported 0 runtime value cycles, autoreview reported no accepted/actionable findings.
Observed result after fix: queue leases only reports that fit, leaves overflow pending, releases failed prompt submissions, acks delivered injections, and schedules existing cleanup finalization.
What was not tested: full
pnpm check:changeddid not run because Testbox failed duringpnpm installbefore checks; postinstall could not resolve optional deps including@esbuild/linux-x64andhttps-proxy-agent.