Repository navigation
feat(FIX-2159): a person's running turn hears the tasks that finished while it answered - #3823
Conversation
… while it answered
- orchestration: takeOwedNotice takes an owed notice in the running
request's name through onTaskSettled's take record (shared takeFor).
- workforce: takeFinishedTasks (person's turn only), handled by the same
steps as the queued onTaskSettled (settleTakenNotice), and
finishedTasksAnswerAgain, the pre-built source.
- planned's answer-once-more becomes one answer-again step with two
sources (the plan, the flow's) under MAX_ANSWERS_AGAIN, on doWhile.
- defineAgentWorkerFlow({ answerAgain: true | block }).
- Goal: goals/hand-offs/result-reaches-the-running-turn.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
…ce (FIX-2159) Workforce README: the answerAgain option, the finished-tasks source, its limits and exports. Orchestration README: taking an owed notice in a running request. Goal verdict log: PASS at af14e78b. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
@codex review Please pay special attention to:
Generated by Claude Code |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second-look + architecture review (code against the approved direction)Verdict: The approach is right and I'd keep it: one take record shared with Worth fixing in this PR
Second look: a leaner shape for
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
Simplify review (FIX-2159)
Problem this PR solves: task results that land while the worker is still answering should show up in the same person-started request (once), not as a later turn.
Verdict: The shape matches what the spec already chose — one take record (takeOwedNotice / FIX-2123), one acknowledge pipeline (settleTakenNotice), two delivery modes (queued onTaskSettled vs in-turn takeFinishedTasks + answerAgain). I would not collapse this into “just call onTaskSettled from inside the turn”: that re-enters heldFor/defer admission and the wake-turn path, which is the wrong product behavior for a person turn (D1/D3 in the issue spec).
Extracting takeFor + exporting takeOwedNotice is a real simplification over duplicating take logic at the workforce layer. Wiring finished tasks through the existing planned(turn, answerAgain) loop is also the right reuse story vs inventing a second answer-again mechanism.
Where complexity is “real” vs “optional”
| Area | Assessment |
|---|---|
plan.ts answer-again state machine |
Heavy, but it generalizes plan-brief + answerAgain under one cap (MAX_ANSWERS_AGAIN). Shrinking it without dropping plan+finished composition would mean a different spec. |
take-finished.ts ledger scan |
O(rows × rounds) with committed reads; acceptable at conversation scale and aligned with snapshot semantics. Worth documenting; premature optimization would be a request-scratch index unless boards get large active footprints. |
| 340-line goal + large vitest files | Cost is test/verification surface, not production architecture. The goal’s anti-game (grade session items, controls for read-only / no-source) is doing real work. |
Cleaner alternatives considered (and why I’d stay on this PR)
- Steer-style “read finished rows before every model call” — fewer moving parts in
plan.ts, but hides the loop from apps and can’t compose custom messaging (spec D3 rejected this). answerAgain: trueonly, notakeFinishedTasksexport — smaller API, loses the lab/trace composition the spec wants.- Parameterize
task-settled.tswith adeliverymode — could reduce drift between queuedsettleand in-turn take long term; larger refactor than this issue needs. Optional follow-up, not a blocker. - Third-party package — nothing obvious; this is framework notice/take semantics, not generic queueing.
Non-blocking nits (inline)
- Centralize “which notices are eligible for in-turn take” with the
settleguard /decideNoticestory (takes()duplication). - Consider deriving
answerRoundOpenfromanswersAgain < MAXinstead of a second request-state flag (if you trust one source of truth). - Narrow the
settleTakenNoticecatch or classify expected vs unexpected failures. takeOwedNotice+readCommittedTaskintakeFinishedTasksduplicates a committed read per notice — fine at low N; pass row through if you ever optimize.
No changes requested for merge from a simplify lens; approving direction.
Sent by Cursor Automation: Review For Best Approach
…test (FIX-2159) "user" for the signed-in user, and a test helper not named like the retired ask mark, so the Process guards pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
|
Engineering review: FIX-2159 ( Verdict: good to merge once CI is green. No blockers. In scope against the merged spec (#3799, with epic amendments #3797 / #3803). The merged #3799 keeps What I checked:
Notes (none blocking):
CI at — FSD Head of Engineering |
…out takeNotice (FIX-2159) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
|
Thanks. Taking your notes in order:
Generated by Claude Code |
There was a problem hiding this comment.
Code Snob: the cap is a second flag.
answerRoundOpen lets a round past MAX_ANSWERS_AGAIN start and then skip its sources. The loop already stops when again is false, so that flag is the cap. After the last counted answer, again is false and no further source runs. The open flag, roundOpen, and answer-again-open-round go away. Clearing the messages that round consumed, in the same write that counts the answer, is what stops the plan's message being asked again.
POC, and it does not merge: #3825
Fold fdf786323 onto 0f06609ec. Do not fold 4b746f18c (that commit sits on ba5415c6; the POC body still names it, and gh pr edit could not update the body). Do not reset onto the POC. Close the POC unmerged after this PR lands.
What still passes there: answer-again-finished-tasks 9, and the cap case again on fdf786323. worker-plans-its-steps 22 on the same plan.ts change. eslint on plan.ts. answered <= MAX_ANSWERS_AGAIN answered 4 times (expected 3). Net −12 in plan.ts (+16/−28).
Sent by Cursor Automation: Code Snob
The round-open flag only let a round past MAX_ANSWERS_AGAIN start and then skip its sources. The loop already stops when a round says not to look again, so the last counted answer says so and no further source runs. A round's consumed messages are cleared with the answer that used them, and decidePlan clears them for a fresh turn. Folds the subtraction proposed in #3825. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
…tice (FIX-2159) The take now leaves what the queued handling would not deliver to the turn by asking decideNotice, so the two can't drift, and a test pins each case. takeOwedNotice takes and returns a TaskNotice, which drops the casts. The docs say which endings are taken (not yet heard), and decidePlan's comment says once per request again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
|
Replying to the second-look review (comment 6377381499), which I missed earlier. Point by point, at 71f267d:
Verified at this head (with Generated by Claude Code |
… spelling (FIX-2159) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9RvCHba2QKPohNxnZNzct
FIX-2159 (#3823) ships finishedTasksAnswerAgain, so the lab writes no block of its own for a result to reach the running turn. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn
* spec(FIX-2153): Claude Code-style lab, session mode Spec and UI design for the first lab of FIX-2152: sessions left, main thread center, read-only background tasks right. The main worker is a manager on the agent flow; sessions ride the more-conversations gap; a background result reaches the running turn through the mid-turn gap. Plans for FIX-2157's threads mode as a per-session mode. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): follow corrected epic D3; cite FIX-2158 and FIX-2159 Sessions are ordinary sessions on the worker's flow, listed through FIX-2158, with no new criteria key. The control is the absence of FIX-2159's delivery. Mode is derived from the main worker. Adapter names verbs only; fixtures carry a plain marker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): bind signal 4 to the first request; FIX-2159 must step after a late settle Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): mode comes from the view; result reaches the turn through the lab's loop-back flow Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): the loop-back takes through FIX-2159 on FIX-2078's path, so an ending is heard once Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): a long task that ends before the stop is a bad input, rerun Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): a project per session (D3) and a coding harness on delegated workers Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): cite FIX-2161 for a session on a project Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2153): one coding worker flow, harness picked by the worker's setting (epic ER-9) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2153 spec: a session opens only on a project the person may work in Reading a shared project is org-wide, but a run by a non-member is refused not-a-member, so the picker and FIX-2161 admit members and owners only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2153 spec: align the result-in-turn path to FIX-2159's answerAgain source FIX-2159 moved the answer-again loop into the package: the lab supplies only an answerAgain source block that calls takeFinishedTasks, and the control leaves that block out. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2153 spec: name FIX-2161's setWorkProject call for the session's project Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2153 spec: say 'kind of worker', not 'role'; main worker on the agent flow Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * spec(FIX-2157): Claude Code-style lab, threads mode (#3792) * spec(FIX-2157): Claude Code-style lab, threads mode Threads mode for FIX-2153's app: the main worker is a coordinator that hands each request to threads, each in a session of its own, and the right pane is a status board read from task rows. Two decisions for sign-off (a thread's own session; ready for review as a review the task waits on), two package gaps for the epic to file. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * spec(FIX-2157): pin gap A's thread session to epic D3's shape Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * spec(FIX-2157): gap A amends epic ER-7; thread sessions stay off the session list; gap B uses the existing deadline Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * spec(FIX-2157): a thread is an ordinary task the coordinator files; drop the routed-session gap The coordinator's turn already files plain tasks in a new session each (board.ts addTask intercepts only a conversation result on a routing turn), so threads run side by side with no gap. D1 now says leg c does not prove routing. The review gap is gap A; review notes recorded for the implementer. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * spec(FIX-2157): review through FIX-2131's model tool; no blocking gap left Codex: FIX-2131 already gives a model on a task turn waitForUser({ kind: "review" }), so the thread worker asks for review from its WORKER.md and the review gap is dropped. Same-delegate routing finding is moot after D1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * spec(FIX-2157): one table for the board's columns; fixture marker as in FIX-2153 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: say worker, not role Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: threads mode is the Projects view Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: lead files ordinary tasks; control shares one session Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: threads work in the session's project; harness threads (D5) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: step 6 controls that really fail Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: state the session project rule here, not by citation Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: a harness run with changes waits for review; gap blocks step 6 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: the debt names the one blocking gap Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: match the shared session directory rule; name FIX-2161 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: step 6 checks the worktree's repository, not the mapped path Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: one harness-thread flow, harness chosen by a worker setting (ER-9) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a * FIX-2157 spec: a session gets its project through FIX-2161's setWorkProject Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RNUDVs3QxrstrvHVDuS9a --------- Co-authored-by: Claude <noreply@anthropic.com> * Lab specs: a task works in its session's project, never another ownProjectIn overwrites a named project with the filing session's, and projectWorkspace() refuses a different one other-project. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2157 spec: amend D5 for FIX-2163's not-reviewed mark on harness threads Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn * FIX-2153 spec: the main worker sets answerAgain: true (FIX-2159 merged) FIX-2159 (#3823) ships finishedTasksAnswerAgain, so the lab writes no block of its own for a result to reach the running turn. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Afupg1DNVRUaS1VEW2HnMn --------- Co-authored-by: Claude <noreply@anthropic.com>


Requested by Jake · project thread
The problem
A person asks the main worker for something that starts background tasks. A task ends while the reply is still running. Today the person hears that result only after the reply, as a turn of its own in a later request. The reply they are reading can't use it.
What this does
A worker on the built-in
agentflow can now opt in withanswerAgain: true. After each answer, the flow takes the tasks its conversation filed that finished since the turn began. It says each one under the delegate's name in the person's own request, and the worker answers again with them. Each result is heard once: the copy that would have arrived after the turn finds it already taken and does nothing. Any block can be the source instead oftrue, which is how FIX-2153's lab plugs in its own.The plan's own "answer once more" step and this one are now the same step, with one cap (
MAX_ANSWERS_AGAIN, 3), and the plan's answer counts toward it.What's asked of you
This implements the approved direction in the spec (#3799). Nothing here is new for you to decide.
Parts worth reviewing closely
takeFinishedTasks(packages/workforce/src/conversation-board/take-finished.ts) takes through orchestration's newtakeOwedNotice, thensettleTakenNoticeacknowledges atnoteSeen. A stop before the acknowledgement leaves the notice taken by this request for the queued copy to take over. A stop after it drops the line. Check that this matches whatonTaskSettleddoes (task-settled.tsnow sharesbeforeAcknowledge/acknowledgeOncewith it).plan.ts. The round loop runs ondoWhile,decidePlanresets the counters each turn, and the app source receives the worker's answer through a connector. The cap leg in the tests pins the plan counting toward the cap.isUserTurngates it. Task sessions, woken turns and worker-to-worker turns hand over nothing.answerAgain(coordinator-flow.tsomits it).Links
Spec:
specs/issues/FIX-2159/on main (#3799) · Linear: FIX-2159 · Epic: FIX-2152 · Goal:goals/hand-offs/result-reaches-the-running-turn/· Merges when approved. Fixes FIX-2159.How to review this
How to review this. This implements an approved spec. The approach and the numbered decisions in its
DECISIONS.mdare already signed off by a human, so please review the code against that direction, not the direction itself. The canonical set is retained atspecs/issues/FIX-2159/onmain; Linear links to it and the original merged spec PR, which keeps review history. Follow-up amendment PRs explain later direction changes. Current architecture docs remain the authority for shipped behavior (BP-037).Most valuable here: correctness on the second path (the legacy shape, the null boundary, the concurrent case, the cancel path), anything deriving an auth or routing decision from caller-controllable input, and a behaviour the tests assert around rather than on.
Already settled upstream: the approach and every decision in the spec's
DECISIONS.md(human-approved; if one is wrong, say so as a spec finding and it gets folded back; don't re-argue it inline), and the conventions indocs/contributing/best-practices.md.Engineering calls
takeForwas extracted from the admit path intask-settled-entry.tsso the take andonTaskSettleduse one take.readCommittedTask), not from the turn's snapshot. Rows the snapshot shows ended and acknowledged are skipped.resultTo: "conversation"), a retry and a park that asks keep their own paths.answerAgainis ignored withoutinstallation(no session board), and documented as such.Everything else: verification
Goal (
goals/hand-offs/result-reaches-the-running-turn/, real model): PASS on this branch and withGOAL_ORDER=reversed. Controls:read-onlyfailsonce(each code said 4 times),no-sourcefailsrequest-id, andmainbefore this change failsrequest-id. The verdict log is ingoal.md.Red states (each control reverted, then restored):
Suites: orchestration and workforce test suites, typecheck, eslint and validate scripts green locally.
Files: orchestration
task-settled-entry.ts(takeOwedNotice), workforcetake-finished.ts(new),task-settled.ts,plan.ts,agent-worker-flow.ts,coordinator-flow.ts, exports, tests (answer-again-finished-tasks.test.ts,take-owed-notice.test.ts), both READMEs, the coordination concept doc's rule 7, and a changeset (minor, workforce + orchestration).Generated by Claude Code