Skip to content

fix: queue subagent completion handoffs - #88613

Merged
steipete merged 1 commit into
mainfrom
codex/subagent-handoff-queue
May 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/subagent-handoff-queue

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Add a persisted next-turn subagent handoff queue over existing subagent delivery state.
  • Merge pending completion payloads into one parent-turn runtime prompt injection, with lease/ack/release ownership so normal announce retries do not race it.
  • Keep overflow reports pending, sanitize handoff metadata, and route acked handoffs through existing cleanup finalization.

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.ts
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental false
  • pnpm check:import-cycles
  • .agents/skills/autoreview/scripts/autoreview --mode local

Behavior 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:changed delegated 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:changed did not run because Testbox failed during pnpm install before checks; postinstall could not resolve optional deps including @esbuild/linux-x64 and https-proxy-agent.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels May 31, 2026
@steipete
steipete merged commit 1e54e90 into main May 31, 2026
156 of 166 checks passed
@steipete
steipete deleted the codex/subagent-handoff-queue branch May 31, 2026 12:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 1, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant