Skip to content

Queue system notices during manual compaction - #6334

Merged
ymichael merged 2 commits into
mainfrom
slopcop/issue-6333
Oct 27, 2026
Merged

ymichael merged 2 commits into
mainfrom
slopcop/issue-6333

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · new-issue-autopilot

Human comments

What was wrong

Parent system notices (child completed, ownership changes, detached tool results) are delivered through their own path, not the ordinary message checkpoint. That path checked for pending interactions but not for manual compaction. Once the provider had accepted a /compact turn, a notice was sent into that turn as an auto-targeted steer. Codex rejected it with cannot steer a compact turn, the parent ended in error, and the notice was lost: it was never queued and never delivered.

User messages are not affected, because the checkpoint already queues them during compaction (dispatch-attempt.ts).

Report: https://get-bb.github.io/reports/issues/6333.html

What changed

  • parent-system-messages.ts: the transaction that records the steer for a notice now checks isManualCompactionActive first. If a compaction is running, it throws ParentSystemMessageCompactionActiveError. Because the check runs in the same immediate transaction that appends the steer, a compaction that starts concurrently can't slip between the check and the write. The per-thread send guard can't prevent that, since it does not serialize concurrent sends.
  • queueParentSystemMessage: treats that error the same way as ThreadContextClearInProgressError. It writes a durable thread-busy queue row with the notice's kind and subject, which is delivered as a new turn once compaction finishes.
  • queued-messages.ts: both queue drains, auto and explicit send, treat the error as "leave it queued". A notice being drained when a compaction starts stays queued and isn't recorded as a failure.
  • Before acceptance: before the provider accepts the compact turn, notices already wait as turn-starting and the drain's existing compaction guard holds them. That behaviour is unchanged.
  • Test: regression coverage for both the not-yet-accepted and accepted cases. It checks deferred dispatch, that kind, subject and sender are preserved, delivery as a new turn, and that a second drain sends nothing.

Scope: 174 changed lines (170 additions, 4 deletions) across 3 files: two server thread-dispatch files and one test. No dependency, generated file, stored-data, schema or protocol changes. No new UI, CLI or SDK surface.

How you verified

  • Unit tests: the new regression fails on main in the accepted-compaction case and passes on this branch. pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-compaction.test.ts test/threads/parent-system-message-dispatch.test.ts test/threads/thread-send-dispatch.test.ts: 54 passed.
  • Full server suite: pnpm exec turbo run test --filter=@bb/server gave 3,681 passed and 2 failed, both in builtin-plugins.test.ts. That test waits on a fixed timer for a plugin file watcher. It passed in 3 of 3 reruns and doesn't touch thread code.
  • Typecheck: pnpm exec turbo run typecheck --filter=@bb/server passed.
  • Live reproduction with real Codex threads on a pnpm start:worktree server. A child ran sleep 20, and the parent's /compact was fired so that the compaction overlapped the 2-second batch delay before the child-completed notice is sent:
    • main: the notice was sent as an auto steer into the compact turn. Codex returned client/turn/rejected with "cannot steer a compact turn" and a system/error thread_command_failed. The parent's status became error, and the notice was never queued or delivered.
    • this branch:
      • The compact turn ran from 26.386 to 28.667.
      • The notice was queued at 27.39 (child-completed, waiting on thread-busy).
      • It was delivered at 28.916 as a new turn, exactly once.
      • There was no rejection or error, the parent ended idle, and the queue was empty.

Fixes #6333

AGENT GENERATED

The pre-delivery compaction check ran outside any lock, and the send guard
does not serialize concurrent sends, so a compaction that started between
the check and the steer could still be steered into. Check inside the same
immediate transaction that appends the steer, and treat the resulting error
as "stay queued" in queueParentSystemMessage and both queue drains.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit bc93950 into main Oct 27, 2026
53 of 54 checks passed
@ymichael
ymichael deleted the slopcop/issue-6333 branch October 27, 2026 03:56
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Oct 27, 2026
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.

Child-completed notification steers an active Codex /compact turn → "Command turn.submit failed: cannot steer a compact turn"

2 participants