refactor(coding-agent): cut over session action admission - #574
Merged
snimu merged 4 commits intoAug 3, 2026
Merged
Conversation
This was referenced Aug 1, 2026
snimu
force-pushed
the
refactor/session-action-admission
branch
from
August 1, 2026 20:11
f17666b to
62f410b
Compare
snimu
force-pushed
the
refactor/session-action-admission
branch
from
August 1, 2026 21:20
fe13e80 to
cabe131
Compare
snimu
force-pushed
the
refactor/session-action-admission
branch
from
August 2, 2026 10:14
cabe131 to
3007ef4
Compare
snimu
force-pushed
the
refactor/session-action-admission
branch
from
August 2, 2026 13:43
3007ef4 to
212d2be
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 212d2be. Configure here.
Prevent heterogeneous turn batches from applying the first action’s execution policy to every action in the batch.
…ions Restores the pre-handoff clear boundary for general queue operations while preserving targeted accepted-agent cancellation with abort-backed late-event capture.
alexzhang13
force-pushed
the
refactor/session-action-admission
branch
from
August 3, 2026 02:59
212d2be to
2a21d52
Compare
alexzhang13
approved these changes
Aug 3, 2026
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
…lect-ai#574) * refactor(coding-agent): cut over session action admission * fix(coding-agent): split turn batches on execution policy change Prevent heterogeneous turn batches from applying the first action’s execution policy to every action in the batch. * fix(coding-agent): stop general clears from reclaiming handed-off actions Restores the pre-handoff clear boundary for general queue operations while preserving targeted accepted-agent cancellation with abort-backed late-event capture. * batched actions had weird commit behavior when cancelled. make it consistent --------- 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
Third PR of the session-action stack, and its core: every turn-producing entrypoint now flows through the action scheduler, and the alternate ownership machinery - direct dispatch paths, direct checkpoint fencing, dispatch observers, the accepted-agent-message parallel state - is deleted in the same commit. Net -116 production LOC.
Stack: #572 contracts <- #573 kernel <- #574 admission (this) <- #575 protocol <- #576 cleanup
Motivation
After #2 there were still two authoritative owners for new work: the scheduler (queued input) and the legacy direct paths (idle prompts, injected messages, accepted agent messages, custom trigger-turns). Split ownership was the root cause of the compensating-state sprawl this stack exists to remove: every busy check, restart fence, and completion mechanism had to be implemented twice and kept in agreement by hand. This PR makes the scheduler the single owner and deletes the second implementation wholesale.
Code changes
prompt()(promptUntilAccepted,promptAndWaitincluded),_promptInjectedMessage*(heartbeats, goal context),acceptAgentMessagePrompt/queueAgentMessagePrompt,sendCustomMessagetrigger-turn and streaming custom messages, RLM child initial prompts. Idle submissions become immediately eligible actions - externally indistinguishable from the old direct path (no queued-row flash, no spurious queue events).AgentConnection.promptat acceptance/preflight;AgentSession.promptwaits for the run when idle, returns after enqueue when visibly queued;promptUntilAcceptedat ownership (and still rejects validation failures);promptAndWaitthrough delivery + completion incl. retry chain;steer/followUpat enqueue (falseon coalesce); agent-message ownership/delivery/completion remain separate; heartbeat/cron wake behavior unchanged.steer("/compact")remains model text; extension commands still execute immediately even while streaming._promptUnserialized,_promptInjectedMessageUnserialized,_dispatchPromptWithFence,_observeDirectDispatch,_directPromptSectionCount,_directDispatchObservers,_acceptedAgentMessagePrompt+ its event-filtering machinery (behaviors preserved through tickets/lifecycle: clearing an accepted-unstarted prompt restores next-turn context and rejects with the same error; late-event filtering; delivery correlation),_acceptedPromptCompletions,_queueWithPendingNextTurnMessages,_enterDirectPromptSection,_acquireDirectTurnAdmission.LOC: +865/-965 production (net -100), +390/-144 tests (includes review-fix commits: policy-split batching, handed-off clear boundary).
Note
Migrate session action admission in coding agent to action store and ticket pipeline
AcceptedAgentMessagePromptandPromptDispatchFenceabstractions with action store entries and typed tickets, unifying how all prompts (direct, queued, injected, triggered) are admitted and tracked.TurnExecutionPolicyto parameterize per-turn behavior: when to run extension hooks, drain next-turn context, and whether to await retry chains; turns with different policies no longer batch together._enqueueSessionInputto_admitSessionInput, which now returns{ accepted, disposition, ticket }and supports immediate-start eligibility without waiting on the pump._cancelSessionActionsto handle differentiated cancellation: rejected delivery for accepted/invisible turns, context message restoration, and transcript cleanup for in-flight cancelled dispatches._acceptedAgentMessagePrompt,_directPromptSectionCount,activeActionsForMessage), and queue_update events are now suppressed when visible queue content is unchanged.Macroscope summarized b17d052.
Note
High Risk
Large refactor of core prompt admission, pumping, cancellation, and restart checkpoint behavior with many entrypoint-specific settlement contracts that must stay behavior-identical.
Overview
Unifies session input so idle prompts, injected messages, agent-message acceptance, custom trigger-turns, and queued steer/follow-up all admit through
_admitSessionInputwithActionTicketdelivery/completion semantics instead of parallel directagent.prompt()paths.Adds
TurnExecutionPolicyon prepared turns (preparation barriers,before_agent_start, next-turn context timing, retry-inclusive completion) andCommitPreparationPolicyflags for optional model/auth waits. The input pump batches follow-ups only when policies match, handles preselected actions for update-restart rollback, and usescaptureRunMessageson cancel to strip in-flight transcript rows.Deletes
_dispatchPromptWithFence, direct-prompt checkpoint fencing,_acceptedAgentMessagePrompt, and_acquireDirectTurnAdmission; cancellation/clear/abort now reject tickets, restore prefix/next-turn context, and gatequeue_update/ legacy queue projections onqueueVisible.session-action-storegainsrejectDeliveredandactionsForMessage(broader than the old active-only lookup).Reviewed by Cursor Bugbot for commit b17d052. Bugbot is set up for automated code reviews on this repo. Configure here.