Repository navigation
FIX-2113: a steer reaches the turn that answers, and a task runs one turn at a time in its session - #3696
Conversation
…n (FIX-2113) A steer sent while a task waits on the work it filed starts a turn at once, which takes the steer as its message. That message is not kept in the session, and the take showed nothing, so the turn that answers once the work ends (the notice's, a later request in the same session) never read the steer, and the draft lacked what it asked for. The steer turn's take now shows the steers it takes as lines from their senders, as a model call's take already does, so every later turn in the session reads them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 435010b5-efe2-4d3c-abf5-a82d926ba893) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
A steer's turn that files a step in a session of its own waits on it, and while it waits it doesn't hold the session. The research notice's turn then ran beside it and planned too, over the session's one plan ledger, and the task stalled until a lease ran out. Now a request whose plan has a step in a session of its own marks the session (its state, `planWaitingRequest`) until it answers. While another request holds that mark, a notice is left owed (`taskSettledEntry`'s new `defer`) and a steer's turn runs nothing. When the marked request answers, after the task's check, it drops the backoff on the notices left owed (`resendNowPatch`) and runs the session's pass, so they are heard at once, one turn at a time. A request that died holds nothing. The mark is session state, not a read of the plan ledger: a request reads a ledger as the snapshot it first took, and an early read made the notice's own plan wait on a step another request had finished. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 94af9e66-b52b-46d4-8d9c-81dc14fcab5b) |
jhoffner
left a comment
There was a problem hiding this comment.
Review of part 2 (24744afaf, the delta since 3f92a61)
Lenses: correctness, coherence, restraint. Head reviewed: 3942aad08.
Verdict: the diagnosis holds, and the two pieces the test exercises are proven. Nothing here strands a session for good on a durable host. There are three 🟡 to settle before this leaves draft: an in-flight steer turn at deploy, the single-slot mark, and deferred notices aging out. The steer gate also needs a test.
Red checks I ran (steer-while-filed-work-open.test.ts, "runs one turn of the task at a time")
| Removed | Result |
|---|---|
defer on the notice entry |
❌ timed out waiting for the task to complete. Proves the notice gate. |
resendNowPatch in sendWaitingNotices |
❌ expected 5580 to be less than 2500. Proves the send-at-answer. |
steer busy gate (forced false) |
✅ still passes. Steer gate untested. |
.tap(endPlanWaiting) |
✅ still passes, because waits.ended covers it. |
The dead-request branch (waits.ended → true) and orchestration's taskSettledEntry({ defer }) have no unit test of their own.
Findings
| Finding | Where | |
|---|---|---|
| 🟡 | BP-030: the steer entry's restructure moves every step of an in-flight steer turn. Replay is keyed by structural path, so a steer turn parked on its own step at deploy (this PR's own scenario) won't resume cleanly. Keep the shape: do the check inside take, or append it after the existing steps. |
inline, steer.ts:231 |
| 🟡 | The mark is one slot, last writer wins, and hold entries aren't gated. A follow-up or chat turn can overwrite it and clear it early, which reopens the gate while the first request still waits. The docs line "one turn at a time" also says more than the code does. |
inline, plan.ts:310 |
| 🟡 | A deferred notice still ages toward undeliverable (24 h maxDebtAgeMs), with a no-op resend about every 5 min while it waits. |
inline, task-settled.ts:365 |
| 🟡 | Tests: the steer gate, the dead-request path and defer itself are unproven (table above). Add a case where a second steer arrives while the mark stands, and one where the marked request fails. |
— |
| 🟡 | Coherence, a second way to serialize turns. A session-state mark now sits beside the concurrency arbiter's reply-line key, which already serializes notice and steer turns but lets go on a park. This is a bug-route PR, so per the review skill's job check, that belongs in the ask. "What's asked of you: nothing" should become one line on why the key can't be held across a park, or why a mark is better than doing so. | PR body |
| 🟣 | ended === undefined → true fails closed. That's unreachable today, because session: "new" needs waits, but it's worth a comment. |
inline, plan.ts:153 |
Considered and clean
- Mark on a cancel, error or crash path: no explicit clear, but
waits.endedtreatsfailed,aborted,incompleteandinterrupted-not-driven-again as ended (wait-chain.ts:235). So a dead request holds nothing, and the notices it turned away go out on their normal backoff. That costs some delay but nothing is lost. - Two gated requests racing to set the mark: notice and steer turns are serialized on the
deferreply-line key, anddecidePlanwrites the mark before the drain parks. No race among gated entries; the ungated case is above. - BP-030, session state: the new key is optional and nullable, and old sessions read as unmarked. A request parked under old code replays
decidePlan's record, so it never marks. It keeps the old behaviour once, and that's acceptable. sendWaitingNoticesscope: it reads this session's own filing partition only, so it doesn't reset backoff on notices owed to other sessions.- BP-007:
resendNowPatch,deferandafterPlanhave JSDoc, and the orchestration README documents both new APIs. - BP-022:
patchis correct, notminor. Pre-1.0, additive API ispatch(best-practices.mdBP-022,.changeset/README.md:17). The fragment cites FIX-2113. - Restraint: the surface is proportionate.
endPlanWaitingisn't load-bearing, but it's cheap hygiene (see theplan.ts:153note).
Generated by Claude Code
…n, keep held notices (FIX-2113) Review of #3696: - The steer turn's gate moves into its admission (`admitOwnTask`'s `unlessAnotherTurnWaits`), so the entry's step paths are as they were and an in-flight steer turn replays across a deploy. - The plan mark is keyed by request (`planWaitingRequests`): each request sets and clears only its own key, so two that plan in one session never overwrite or clear each other's. Keys left by dead requests hold nothing, and the next plan clears them. - A notice a busy session turns away records when (`deferredAt` on its marker), and its age, which ends it as undeliverable, counts from then: being turned away is no failed delivery. Its resends stay bounded by the 5-minute backoff cap. - Tests: a second steer while the steer's turn waits on its step; the dead-request branch; `taskSettledEntry`'s `defer` on its own; the age. - Docs: task-board.md's message cases (narrowed to notice and steer turns) and the orchestration README's own paragraph on `defer` and `resendNowPatch`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: b14b42b5-55a4-4be3-9b2f-31fc3e42e9da) |
|
Stand-in review and docs-editor round: all addressed in cdcb493. Each finding has a reply on its thread.
Generated by Claude Code |
jhoffner
left a comment
There was a problem hiding this comment.
Stand-in delta re-review of 3942aad08..cdcb49340 (one commit).
Verdict: three of the four 🟡 from last round are fixed properly: the steer gate's shape, the single-slot mark, and the aging of held notices. The open one is the tests. The per-request mark and the new aging rule are both unpinned: I reverted each and every test still passed.
Checked and clean
- The steer entry has main's step shape.
git diff $(merge-base main) -- steer.tsshows the same.tap(admission) → .step(take) → .stepIf(run) → .tapIf(noteTaskAnswer) → .tap(settleWake)chain. Only two arguments differ: the admission's options and thectxpassed totakeRunningSteers. No replay path moved, so the BP-030 concern from last round is closed. While a mark is live, the admission admits nothing,takereturns SKIP, andsettleWakeleaves the wake because the row still waits on"steer". That is what main does for an un-admitted start. - The per-request mark is safe. Each request writes and clears only its own key, through
setStateRecord/deleteStateRecord.endPlanWaitingdeletes onlyctx.request.identity.id. The dead-key sweep deletes only keys thatwaits.endedanswerstruefor, and a dead request never writes again, so racing it is harmless. Growth is bounded: one live key per in-flight plan request, plus dead keys left since the last plan, which that plan sweeps.endedanswerstruefor a missing record (pruned by retention), so a deleted request can't pin a key. Old sessions have nothing to tolerate (BP-030): the single-slot key never reached main. deferredAtcan't keep a notice owed forever on its own. A notice can be turned away indefinitely only whileanotherTurnWaitsOnItsPlanis true, which needs a marked request that hasn't ended. The drain does re-wait at each deadline, so a step that never ends keeps that wait, and the notice, alive. That is the acceptable case. When the marked request dies,endedreturnstrue(failed/aborted/incomplete, orinterruptedand not driven again). The gate opens and the notice goes out at its next resend. That resend can be up to 5 min later, because a dead request never appliesresendNowPatch. The delay is acceptable; nothing is lost.- Two red checks hold. With
{ unlessAnotherTurnWaits: true }removed, "runs one turn of the task at a time" goes red (timeout at 40 s), so the steer gate is now pinned. WithdeferredNoticePatchnot written,notice-defer.test.tscase 1 must go red, since it assertsdeferredAt(checked by reading the test, not run). - BP-007 / BP-022.
deferredNoticePatch,noticeTimes().since,OwedMarker.deferredAt,markedRequestsandadmitOwnTask's new option all have JSDoc. None are exported publicly (onlyresendNowPatchis), and the README covers the new aging rule under "Holding a notice back". Thepatchchangesets are right for this.
Findings
-
🟡 Nothing pins the per-request mark or the new aging rule. All three mutations below ran in an isolated worktree and every test stayed green:
Mutation Result setStateRecordreplaced withpatchState({ planWaitingRequests: { [me]: true } }), the old last-writer-winsworkforce 1557/1557 pass dead-key sweep removed, and endPlanWaitingwiping every keyworkforce 1557/1557 pass pass.tsback totooOld(times.due)orchestration 2077/2077 pass The unit test of
anotherTurnWaitsOnItsPlancovers the reader only, not the writers.noticeTimes().sinceis tested, but nothing tests thatpayBoardDebtsuses it. Two small cases would close this: two requests that each mark and then each end, where the first one's end leaves the second's key; and apayBoardDebtscall withmaxDebtAgeMswhere a notice whosedueis old but whosedeferredAtis recent is not marked undeliverable. -
🟣
deferredNoticePatchrewrites the whole marker from the entry's row snapshot. If a resend (resentRecord) or aclearNoticelands between that read and this write, the stale copy wins. A lost resend count only shortens the backoff. A cleared marker comes back and the notice is sent again, and on Workforce thenoticeKeydedupe catches it. It's benign today, but anyone else who passesdeferwould see the block run twice. Writing onlydeferredAt, or re-reading just before the write, would close it. -
🟣 The sweep can drop a key that will come back to life.
endedanswerstruefor a request that isinterruptedand not driven yet. If another plan in the session sweeps that key, and the sweeper then re-drives the request into its step's wait, it waits with no mark, so the gate stays open for the rest of that wait. Without the sweep, the gate would close again once it was driven. This needs a crash betweendecidePlan's mark and the drain's park, with a second plan in the window, so it's narrow. A one-line comment would do. -
🟣
planWaitingRequestsisn't inSESSION_BOARD_SERVER_OWNED. As far as I can tell, a caller's seed is stripped by the flow'sstateSchema, which doesn't declare the key, so I didn't find a way in. But a seeded key naming another session's request would read as "not ended" forever, and that is the one way a notice is held forever with no live wait. Listing it as server-owned makes that explicit (BP-031).
The coherence ask from last round, a mark rather than holding the reply-line key across a park, is a PR-body item. I didn't re-check it here.
Generated by Claude Code
…age (FIX-2113) Delta review of #3696: - The mark's writers are `markPlanWaiting` / `clearPlanWaiting`, and a test has two requests mark one session and end in either order: the first to end leaves the other's key, and the gate stays shut until both end; a dead request's key is dropped by the next plan. Red with the writer back to last-writer-wins, and with the sweep removed and the clear wiping every key. - `payBoardDebts` with the 24 h maximum debt age doesn't end a notice whose due time is old but which a busy session turned away a minute ago. Red with the pass back to `tooOld(times.due)`. - The turned-away time is a record beside the marker (`noticeDeferred:<attempt>:<ending>`), as a resend record is, not a rewrite of the marker from a stale snapshot; callers' metadata can't write it. - `planWaitingRequests` is server-owned session state (BP-031). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
|
Delta re-review 5628219978: addressed in 29e1542.
Checks: orchestration 2078 tests and workforce 1558 tests PASS; typecheck (forced past turbo's cache), lint and fallow:ci PASS. Generated by Claude Code |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 4b508548-29b8-4aee-b1d1-33cc14e24b93) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: d24c4675-f3e9-44cf-a74a-ebee3343c8c0) |
There was a problem hiding this comment.
Simplify / architecture pass (FIX-2113)
Verdict: approve. The concurrency story is the right shape for the invariant (“one task turn at a time in its session” + “the notice turn sees steers from history”). I don’t see a materially simpler design that preserves durable waits, steer admission, and notice backoff without re‑inventing the pass rail.
What had to exist (and did)
| Mechanism | Role |
|---|---|
planWaitingRequests + anotherTurnWaitsOnItsPlan |
Cross-request signal while a session: "new" plan step is in flight — can’t live in request state alone |
taskSettledEntry.defer + deferredAt / since |
Reuses existing owed-notice + max-age semantics instead of a second queue |
takeRunningSteers(..., ctx) on the steer turn |
Minimal fix for notice turn reading session history |
afterPlan + resendNowPatch + pass |
Needed so a turned-away notice doesn’t sit behind multi-minute resend backoff after a ~9s plan step (second harness test) |
Where complexity crept in (follow-ups, not blockers)
- Three wires for one predicate —
defer,unlessAnotherTurnWaits, andsendWaitingNoticesall express “session busy for another plan wait.” Consider a single exported helper (e.g.conversationSessionTurnBusy) colocated with the marks, and optionally extractsendWaitingNoticesout ofboard.tsnext totask-settled.ts/task-admission.ts. sendWaitingNoticesis broader than the bug — it clears backoff for every row with any owed notice, then triggers a full pass. Safer narrowings (if you touch this again): only rows withdeferredAt, or only when!anotherTurnWaitsOnItsPlan.- Duplicated stale-mark cleanup —
decidePlanprunes dead keys viawaits.ended;anotherTurnWaitsOnItsPlaninterprets the same marks. One sharedpruneEndedPlanWaitingMarkswould reduce drift. - Comment duplication — FIX-2113 narrative is repeated across
board.ts,steer.ts,task-admission.ts,task-settled.ts, and orchestration README; one canonical module header is enough. - Harness cost — the 40s / 9s sleep test is valuable but heavy; most of backoff/immediate-resend is already covered in
notice-defer.test.ts/task-notice.test.tsif you ever want to slim CI.
Alternatives considered (not recommended here)
- Single session turn serializer — one lock checked by work, steer, and notice — cleaner mentally, but a new primitive that must compose with
AFTER_REPLY_CONCURRENCYand existing wakes; too wide for this fix. - Only engine concurrency — doesn’t encode “plan turn still open across requests” without session marks.
- Separate
noticeDeferred:*sidecar (early sketch) — HEAD’sdeferredAton the owed marker is simpler; keep that.
Skipped (uncertain / product)
- Whether
ended === undefinedshould gate closed (true) vs open for minimal test hosts — document the host contract in JSDoc rather than changing semantics without an inventory. - Adding
planWaitingRequeststoSESSION_BOARD_SERVER_OWNED— only if client session seeding can overwrite handlersessionStateSchemakeys today (I didn’t prove that either way).
Nice reuse of afterTaskCheck, admitOwnTask, and takeRunningSteers; orchestration/workforce boundaries look intentional.
Sent by Cursor Automation: Review For Best Approach
| execute: async (_input, ctx) => { | ||
| await afterTaskCheck(ctx as never, async () => { | ||
| const own = await conversationLedgerAt(ctx as never, await filingSessionIdOf(ctx.session)); | ||
| const owed = (own?.list() ?? []).filter((row) => noticeDueAt(row) !== undefined); |
There was a problem hiding this comment.
Simplify (optional): This filters every row with any owed notice, clears all noticeResent:* backoffs that exist, then runs a full pass — on every plan answer. That’s broader than “notices we deferred while anotherTurnWaitsOnItsPlan.”
If this ever causes surprise (unrelated rows on a busy conversation), consider narrowing to markers with deferredAt, or gating the pass on !await anotherTurnWaitsOnItsPlan(ctx) so you only flush when the session is actually free.
| @@ -775,7 +776,32 @@ export function defineConversationBoard(options: ConversationBoardOptions) { | |||
| ); | |||
|
|
|||
| /** The flow's planning: its turns, wrapped so the steps they file run in their request (FIX-2076). */ | |||
There was a problem hiding this comment.
Two adjacent block comments (FIX-2076 one-liner + FIX-2113 block) — merging into one short header would match the “one canonical doc” goal and shrink noise in an already large file.
| // filed `session: "new"` is refused there, so no request marks the session; | ||
| // reading a mark anyway, take it as live. | ||
| const ended = ctx.requestHost?.waits?.ended; | ||
| if (ended === undefined) return true; |
There was a problem hiding this comment.
When requestHost.waits.ended is missing, this returns true (gate closed). That’s conservative for production hosts with durable waits, but minimal harnesses without ended will defer steers/notices whenever a mark exists. Worth a line in the exported JSDoc so callers know this predicate assumes a wait host — not necessarily a behavior change.


The problem
Alice steers a routed task while the task waits on research it filed: "Also use the word X". The steer is taken, but the finished draft does not carry X. In the closure walk this happened on 3 of 3 runs. In one run the task also stalled for about two minutes before it completed.
There are two causes, and this PR fixes both.
What this does
Cost (the coordinator's call): a result that comes back while another turn of the task waits on its own step is acted on later, after that turn answers.
What's asked of you
Nothing here is yours to decide. The coordinator decided part 2.
Parts worth reviewing closely
anotherTurnWaitsOnItsPlanand theplanWaitingRequestsmarks inpackages/workforce/src/conversation-board/plan.ts.deferoption anddeferredAtin orchestration's notice code (task-settled-entry.ts,task-notice.ts,pass.ts).admitOwnTask'sunlessAnotherTurnWaits(task-admission.ts), which the steer entry uses, andsendWaitingNoticesinboard.ts.FIX-2113 · epic FIX-2056 · found by FIX-2087 · draft, for review; do not merge until approved
Docs note: the
apps/docschange (orchestration/task-board.md: the "Waiting on tasks it filed" case and the line on steers shown in the session) has the docs-editor's revisions. It needs that pass again after this push.How to review this: a bug fix on the direct route
This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope — nothing here was signed off upstream.
Most valuable here: the diagnosis chain — does the repro actually reproduce the reported failure, is the named cause the real one, does the fix address that cause rather than the symptom, and does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).
In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.
Engineering calls
showTakenSteers). The other way, keeping the steer turn's message as a user message, needs an engine change:userMessageis a pure function of the entry's input, and the steers are taken inside the block.holdrequest (theworkentry, a chat turn) that plans beside a marked one can't overwrite or clear its mark. Such a request is not gated itself: only a notice's turn and a steer's turn wait.docs/architecture/execution-and-errors.md), so the entry's steps are as they were.deferredAt, and its age (which ends it as undeliverable pastmaxDebtAgeMs) counts from then. Resends while it waits stay bounded by the existing backoff, at most one every 5 minutes per owed notice. The marked request's answer drops that backoff (resendNowPatch) and runs the pass. Notice order is otherwise as it was (FIX-2077, FIX-2078, FIX-2082). A request waiting on a person or ongetTaskdoes not mark the session.session: "new"is refused there, so no request marks the session.taskSettledEntry({ defer })andresendNowPatch, documented in the orchestration README in their own paragraph. Changeset: patch, for@flow-state-dev/orchestrationand@flow-state-dev/workforce.Everything else: evidence
Part 1, red then green.
packages/workforce/test/steer-while-filed-work-open.test.ts, "reaches the turn that answers after the work ends, and is taken once". Without the fix, the notice's model call has the steer turn's answer in its history but not the steer. With the fix: PASS.Part 2, model-free (same file, "runs one turn of the task at a time"). On a durable host, the steer's turn files a step
session: "new", held 9 s. A second steer arrives while it waits. The research ends meanwhile, and its notice's turn files a step too.expected 6769 to be less than 2500(the notice waited for its next backoff).Units:
waits.endedcheck removed it is red:expected true to be false.orchestration/test/tasks/notice-defer.test.tsrunstaskSettledEntry({ defer })on the real engine. A held notice runs nothing and stays owed withdeferredAt; one not held runs and is acknowledged. Withdeferignored it is red: the block ran.task-notice.test.tscoversresendNowPatchand the age counting fromdeferredAt.Closure goal (
goals/workforce-coordination/runs-on-one-task/fromfix/FIX-2087, real model, on24744afaf, before this review push):j2:steer-showsPASS, with no stall. That run's model did not file a step from the steer turn, so part 2 is covered by the model-free test above.Other goals, all PASS on this head:
task-board/every-ending-reaches-its-filer,task-board/settles-when-its-work-is-over,task-board/waits-on-a-task-it-filed,task-tools/steer-and-follow-up.Checks:
pnpm typecheckPASS, run withTURBO_FORCE: turbo's cache had replayed a stale orchestration.d.tslocally.pnpm lintPASS ·pnpm fallow:ciPASS ·node scripts/check-retired-terms.mjsPASS · orchestration 2077 tests PASS · workforce 1557 tests PASS.🤖 Generated with Claude Code
https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
Note
Medium Risk
Changes task-board concurrency, notice delivery timing, and steer/session message behavior on Workforce boards; orchestration adds defer semantics that integrators may rely on.
Overview
FIX-2113 fixes steers being lost on later turns and tasks stalling when multiple turns plan at once on a Workforce conversation board.
Steer visibility: The steer turn now records taken steers as sender lines in the task session (same pattern as mid-run takes), so the notice-driven turn that finishes after filed work still sees the message in session history.
One turn at a time: When a request’s plan has a step in its own session (
session: "new"), it marksplanWaitingRequestsuntil that turn answers. While another request holds a live mark,onTaskSettleddefers (notice stays owed,noticeDeferred:*resets max-debt age) and steer admission usesunlessAnotherTurnWaits. When the waiting plan answers,sendWaitingNoticesclears resend backoff viaresendNowPatchand triggers a pass so deferred notices run immediately after the task check.Orchestration API:
taskSettledEntry({ defer }), exportedresendNowPatch, and pass logic usingnoticeTimes(...).sinceinstead of due-only for undeliverable age. Docs/changesets updated.Reviewed by Cursor Bugbot for commit 29e1542. Configure here.