refactor(coding-agent): publish session action protocol - #575
Merged
snimu merged 5 commits intoAug 3, 2026
Merged
Conversation
This was referenced Aug 1, 2026
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 1, 2026 20:11
0655b80 to
82809ee
Compare
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 1, 2026 20:25
82809ee to
de175b9
Compare
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 1, 2026 21:06
de175b9 to
fae12c1
Compare
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 1, 2026 21:20
fae12c1 to
5fc996b
Compare
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 2, 2026 10:14
92c7044 to
51ac188
Compare
snimu
force-pushed
the
refactor/session-action-protocol
branch
from
August 2, 2026 13:43
51ac188 to
415fc79
Compare
alexzhang13
force-pushed
the
refactor/session-action-protocol
branch
from
August 3, 2026 02:59
415fc79 to
14dd5ca
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bf28a76. Configure here.
alexzhang13
approved these changes
Aug 3, 2026
alexzhang13
force-pushed
the
refactor/session-action-protocol
branch
from
August 3, 2026 04:03
bf28a76 to
ea5e528
Compare
snimu
added a commit
that referenced
this pull request
Aug 3, 2026
* refactor(coding-agent): harden session action races * fix(coding-agent): revalidate turn batches after commit fence acquisition * fix(coding-agent): reschedule pump after batch revalidation deferral * fix(coding-agent): restore cross-lane queue-key coalescing and compaction pending checks The underlying bugs originate in PR #573, but this fix lands at the stack head in PR #576 to avoid rebasing three dependent PRs immediately before release. * refactor(coding-agent): delete compensating scheduler state * fix(coding-agent): count only pending successors after compaction * fix(coding-agent): honor prompt abort during fence wait and fix compaction test await * test(coding-agent): remove flaky post-compaction continue regression The fake-timer event-await combination never completes under CI timing. The production change it covered (pending-successor counting after threshold compaction, 697fcf4) remains covered by the passing 'resumes after threshold compaction when only agent-level queued messages exist' test exercising the same projection. * fix(coding-agent): reject fence waiters on session disposal * fix(coding-agent): restore settlement, ordering, and idle guards Several fixes originate in #574/#575 but land at the stack head to avoid rebasing the whole chain. * fix(coding-agent): serialize injected admission with the commit fence * fix(coding-agent): release fence on admission failure and unify pause-aware admission * fix(coding-agent): stabilize waitForIdle event-queue wait and drop dead queue-key probe * fix(coding-agent): preserve batched action message order (fixes #576) * fix(coding-agent): revalidate commands after commit fence (fixes #576) --------- Co-authored-by: Alex Zhang <alex.lx.zhang@gmail.com>
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
- Add systemPrompt to BeforeAgentStartEvent so extensions can see current prompt - Change systemPromptAppend to systemPrompt in BeforeAgentStartEventResult for full replacement - Extensions can now chain modifications (each sees the result of previous) - Update ssh.ts to replace local cwd with remote cwd in system prompt - Update pirate.ts, claude-rules.ts, preset.ts to use new API fixes PrimeIntellect-ai#575
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
…ct-ai#575) * refactor(coding-agent): publish session action protocol * fix(coding-agent): restore queue projection guards and recovery validation * fix(coding-agent): repair test migrations for session action snapshots * correcting when multiple messages are sent, how it's counted * fix(coding-agent): await update supervisor teardown (fixes PrimeIntellect-ai#575) --------- Co-authored-by: Alex Zhang <alex.lx.zhang@gmail.com>
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
…i#576) * refactor(coding-agent): harden session action races * fix(coding-agent): revalidate turn batches after commit fence acquisition * fix(coding-agent): reschedule pump after batch revalidation deferral * fix(coding-agent): restore cross-lane queue-key coalescing and compaction pending checks The underlying bugs originate in PR PrimeIntellect-ai#573, but this fix lands at the stack head in PR PrimeIntellect-ai#576 to avoid rebasing three dependent PRs immediately before release. * refactor(coding-agent): delete compensating scheduler state * fix(coding-agent): count only pending successors after compaction * fix(coding-agent): honor prompt abort during fence wait and fix compaction test await * test(coding-agent): remove flaky post-compaction continue regression The fake-timer event-await combination never completes under CI timing. The production change it covered (pending-successor counting after threshold compaction, 697fcf4) remains covered by the passing 'resumes after threshold compaction when only agent-level queued messages exist' test exercising the same projection. * fix(coding-agent): reject fence waiters on session disposal * fix(coding-agent): restore settlement, ordering, and idle guards Several fixes originate in PrimeIntellect-ai#574/PrimeIntellect-ai#575 but land at the stack head to avoid rebasing the whole chain. * fix(coding-agent): serialize injected admission with the commit fence * fix(coding-agent): release fence on admission failure and unify pause-aware admission * fix(coding-agent): stabilize waitForIdle event-queue wait and drop dead queue-key probe * fix(coding-agent): preserve batched action message order (fixes PrimeIntellect-ai#576) * fix(coding-agent): revalidate commands after commit fence (fixes PrimeIntellect-ai#576) --------- Co-authored-by: Alex Zhang <alex.lx.zhang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fourth PR of the session-action stack: the deliberate wire break. Queue state and session activity become separate, explicitly named projections on the daemon protocol; the executing-command queue display bug is fixed; headless completion waits for scheduler work; the restart manifest is versioned; and all transitional compatibility projections from #2/#3 are deleted. Daemon protocol 6 -> 7, schema 7 -> 8, envelope minimum raised to 7.
Stack: #572 contracts <- #573 kernel <- #574 admission <- #575 protocol (this) <- #576 cleanup
Motivation
pendingMessageCountserved incompatible questions - queued future work, scheduler activity, UI rows, restart contents, busy status - and its consumers each picked their own interpretation. That ambiguity produced the "Steering /compact" display for a command that was already executing, headless modes that could exit while a command was still running, and the cross-cutting compensation attempts seen in earlier fix attempts (#565). Everything is team-internal, so rather than dual-writing old semantics, this PR makes one clean break: old clients are rejected before state exchange.Code changes
SessionActionSnapshoton the wire: literalqueuedCount+steering/followUpspreviews (queued actions only), plus optionalactive { kind, phase, label }.queue_updatereplaced bysession_action_update.pendingMessageCountremoved everywhere; every consumer audited and routed to the semantically correct projection (queuedActionCount,unfinishedActionCount,isSessionActive): cron, agent-observe/agent-message discovery and capacity limits, daemon summaries, RPC, Agents View, supervisor sync, shutdown, and update paths./compactrenders as activity, never as a queued row.waitForHeadlessCompletion) and extensionwaitForIdlebindings now use session-level idle (scheduler + lower agent), with wakeups on pause release, queue clear, and dispose (no microtask livelock, no stranded waiters).DAEMON_PROTOCOL_VERSION7,DAEMON_SCHEMA_REVISION8, envelope minimum 7; compatibility maps updated; both direction tests are real socket-level tests (new-client/old-daemon rejects before writing; old-client/new-daemon receives parse rejection from a real supervisor before any state exchange).SessionActionRecoverySnapshot(formatVersion, structural validation, explicit unknown-version rejection on restore; stale/unreadable manifests treated as "nothing restorable" at probe sites and cleared); daemonrestore_actionscommand; per-policy FIFO + correlation preserved on restore.legacyPendingProjection, the old-manifest recovery adapter, the legacy attachment fallback to incompatible daemons, and the deadrequestLegacy/useLegacyProtocolupdate-restart plumbing.LOC: +524/-567 production (net -43), +1075/-667 tests, changelog entry (includes review-fix commits: projection guards, recovery validation, test-fixture migrations).
Note
Publish session action protocol replacing legacy queue API in daemon and session
queue_updateevent andpendingMessageCount/pendingMessageCountfields across the daemon, RPC, interactive, and agents-view layers with a structuredsession_action_updateevent carrying aSessionActionSnapshot(queuedCount, steering, followUps, active phase).AgentSession.restoreSessionActions()to rehydrate session queues from a versionedSessionActionRecoverySnapshot, replacing the former piecemeal steering/follow-up/accepted-prompt restore paths.DAEMON_PROTOCOL_VERSIONto 7 and schema revision to 8; adds arestore_actionsdaemon command; enforces command envelopes and rejects unenveloped commands.Changes since #575 opened
waitForProcessExitasync utility function for awaiting process termination in tests [761439f]Macroscope summarized ea5e528.
Note
High Risk
Breaking daemon protocol and session wire shape; stale clients and daemons are rejected, and update-restart recovery depends on the new manifest format.
Overview
Breaking wire change (daemon protocol 6→7, schema 8): queue state is no longer folded into
pendingMessageCountorqueue_update. Clients getsession_action_updatewith aSessionActionSnapshot: literal queued steering/follow-up previews (queuedCount) plus optionalactivework (kind, phase, label). Session summaries exposesessionActions,isSessionActive, andunfinishedActionCountso UI, cron, agent messaging, and busy detection use the right projection instead of one ambiguous counter.Session core:
AgentSessionaddsgetSessionActionSnapshot,restoreSessionActions, and a versionedSessionActionRecoverySnapshotfor update-restart; legacy recovery adapters and steering/follow-up snapshot APIs are removed.waitForIdlenow waits on scheduler + agent work (used by headless completion and extension bindings).Daemon / CLI: New
restore_actionscommand; update-restart manifests storequeue.actions(not per-queue message lists / accepted prompt).requestLegacy, compatible stale-daemon fallback, and legacy owned-worker frontend routing are deleted; unenveloped commands and pre-v7 daemons are rejected.Reviewed by Cursor Bugbot for commit 761439f. Bugbot is set up for automated code reviews on this repo. Configure here.