Skip to content

fix(background-agent): suppress redundant parent wakes during gate hold#4325

Merged
code-yeongyu merged 2 commits into
devfrom
fix/background-parent-wake-live-session-20260523
May 23, 2026
Merged

fix(background-agent): suppress redundant parent wakes during gate hold#4325
code-yeongyu merged 2 commits into
devfrom
fix/background-parent-wake-live-session-20260523

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented May 23, 2026

Summary

  • Suppress redundant background-agent parent wakes while the promptAsync gate is still holding the already-dispatched wake.
  • Preserve meaningful follow-up wakes: new notification content, reply-mode upgrades, and prompt-context changes still requeue and dispatch after the hold.

Root Cause

The parent wake notifier tracked the last dispatched wake, but the same-source reserved-path check only suppressed byte-for-byte identical pending wake arrays. Duplicate background completion edges could collect repeated copies of the already-dispatched notification during the post-dispatch hold, turning ["wake A"] into ["wake A", "wake A"]. Strict equality treated that as new work, requeued it, and launched a second internal parent prompt after the hold released.

Changes

  • Replace strict same-wake comparison with redundant-wake coverage semantics.
  • Add regression coverage for redundant duplicate bursts.
  • Add boundary coverage proving reply upgrades and prompt-context changes are preserved.

Testing

  • bun test src/features/background-agent/parent-wake-same-source-requeue.test.ts - 6 pass, 0 fail, 41 expectations.
  • bun test src/features/background-agent/parent-wake-same-source-requeue.test.ts src/features/background-agent/parent-wake-active-turn-event.test.ts src/features/background-agent/parent-wake-user-message-race.test.ts src/features/background-agent/task-completion-cleanup.test.ts src/shared/prompt-async-route-audit.test.ts - 52 pass, 0 fail, 176 expectations.
  • bun run typecheck - pass.
  • bun run build - pass.
  • bun test > /tmp/omo-bugfix-bun-test-after-merge.log 2>&1 - exit 0, 3,401 pass lines, no fail/error lines.

Evidence

  • Investigated live session ses_1ace82b4dffeDeez3U2yA4eONr and child sessions from the transcript/logs.
  • Updated sibling OpenCode checkout with git fetch --all --prune && git pull --ff-only; current OpenCode promptAsync still returns before the prompt run durably settles.
  • Git history/blame identifies the relevant sequence: same-source requeue in 11d2cfb8a and strict duplicate suppression in 560569e36.

Summary by cubic

Prevents duplicate parent prompts by suppressing redundant background-agent wakes while promptAsync holds a reservation. Keeps meaningful follow-ups (new notifications, reply upgrades, and prompt-context changes) so they dispatch after the hold.

  • Bug Fixes
    • Switch from strict equality to redundancy coverage: same prompt context, reply mode coverage, and notification subset.
    • Suppress duplicate bursts collected during the hold to avoid a second parent prompt.
    • Preserve meaningful changes and add regression tests for duplicates and upgrades.

Written for commit 1023841. Summary will update on new commits. Review in cubic

@code-yeongyu
Copy link
Copy Markdown
Owner Author

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 23, 2026

@cubic-dev-ai review this PR

@code-yeongyu I have started the AI code review. It will take a few minutes to complete.

@code-yeongyu code-yeongyu merged commit 13b6813 into dev May 23, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/background-parent-wake-live-session-20260523 branch May 23, 2026 12:42
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.

1 participant