Repository navigation
feat(workforce): a task's midway question is told to its filer (FIX-2241, part 2) - #4022
Conversation
…essage (FIX-2241, part 2) The conversation board's onMidwayQuestion sends one message per question from the task's worker to the filer, under the id q:<task>:<question>, landing in the filing session (or, from a workstream's session, the conversation the row was filed from). sendMessage takes exempt: true for the server's own message, which pays no budget. messageReceivedEntry's mark carries its installation and flow kind, so the asking request finds its sender. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
…ntrol (FIX-2241) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
…241) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
…241) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
…-2241) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
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 pass (read-only; nothing run beyond reading the diff)Verdict: the approach earns its scope. A hook in orchestration, one workforce sender, and a server-message exemption is about as lean as this gets. Nothing blocking. Three items worth the implementer's call, ranked. 1.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a596e197a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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 / architecture pass (FIX-2241)
Verdict: The direction looks right — orchestration keeps the onMidwayQuestion hook and timing; workforce tells via the existing message log + onMessageReceived path instead of inventing a parallel notice channel. Reusing sendMessage with a stable q:<task>:<hold> id and exempt: true is the smallest way I see to get budget-free, idempotent server tells without forking delivery. I would not block on this shape.
What follows is where the implementation feels heavier than the product story, and what a cleaner diff might look like if you want to trim before merge.
What I’d keep
DeclaredDelivery.onMidwayQuestion— matchesonTaskSettled/onUndeliverable; orchestration stays transport-agnostic.midway-question.tsas a thin adapter — text, filer target, loop over holds; easy to read in review.payPlaceextraction — mechanical, but it makes theexemptbranch obvious and avoids duplicating budget rollback logic.- Focused vitest file (
midway-question-to-filer.test.ts) — good layer for log id + budget edge cases without dragging the whole goal walk in.
Where complexity crept in (and simpler options)
1. messageSenderOf + ReceivedMark.sender
Stamping installation + flowKind on the same symbol mark as hears works, but it mixes “who can hear” with “how the server sends as this flow.” Today midway question is the only consumer.
Lighter options (if you want less metadata on the entry):
- Resolve sender from session keys you already carry on task sessions (
TASK_FLOW_STATE_KEY/ worker id +installation.workerFlows()[kind]) insidesendQuestionToFiler, same asmessageHearingOfdoes for recipients insend-message.ts— ifinstallationis reachable fromBlockContextwithout miningctx.flow.internal. - Or a one-line
sendServerMessage(ctx, …)wrapper around{ id, exempt: true }soexemptstays an implementation detail and call sites read as “server tell,” not “model send with a flag.”
I’m not sure session-based resolution is available everywhere midway runs; the mark may still be the pragmatic choice. Worth a quick check whether the (ctx as { flow?: unknown }).flow path is guaranteed to expose internal.actions at runtime (typed FlowContextView is config-only).
2. sendMessage public surface: exempt
Reasonable for one feature. If you expect more server-authored tells, a discriminated options shape or a dedicated internal entry point would make misuse (models passing exempt) easier to grep in review. Not required for this PR.
3. exemptPlace hop semantics
Multiple midway questions in one ask each call exemptPlace with the same turnHopOf(ctx) + 1, while paid sends bump via placeAfter(chainRow.sent.length). Probably fine for budget hints on exempt rows, but if recipient budget ever reflects hop literally, multi-question asks might look like one hop. Consider documenting as intentional or mirroring placeAfter without touching chain state.
4. Dynamic import() on every onMidwayQuestion
Cycle break is justified; micro-nit: a module-level lazy handle (const load = () => import(...)) avoids awaiting the import promise on every tell (ESM cache makes this small).
5. Goal walk j1 + harness growth
receivedFrom loading all requests with includeItems: true inside until polls will get expensive as the conversation grows. For a long-lived goal host that may be acceptable; a narrower API (filter by component / since request id) would be a cleaner assertion helper if the client supports it.
Adding j1b coder-heard + rewriting j1 so the filer answers from the automatic message (not Alice narrating the answer) is the right behavioral proof, but it materially expands an already heavy goal — the split to model-free tests in project-coordinator / midway-question-to-filer is good; I’d resist duplicating more routed/budget scenarios in both places.
6. project-coordinator.test.ts hears flag + inline askMidway
Fine for one routed FIX-2241 case; if more tests need “lead hears messages,” consider sharing the [ask] / askMidwayOnceInTurn pattern with conversation-board-harness rather than growing bespoke lead-task handlers.
Alternatives considered (and why I’d still ship this approach)
| Alternative | Why it’s simpler on paper | Why this PR’s approach still wins |
|---|---|---|
Inbox / getTask only (pre-2241) |
No messaging changes | Spec wants filer onMessageReceived + teach updateTask without a read |
Notice-style dispatchThroughSeam only |
No log/budget | Loses message log, idempotent row, and the same turn UX as worker mail |
Inline tell inside askMidway |
One file | Violates workforce/orchestration boundary |
| Third-party package | N/A | No off-the-shelf fit for your delivery + budget + session seam |
Performance (non-blocking)
Serial await sendMessage per hold extends the asking request until all filer dispatches finish — correct for consistency, worth knowing for multi-question asks. Repeated recipient resolution per hold in the same request could be memoized later; K is usually 1.
Summary
No major architectural red flags. The main simplify lever, if you want a smaller conceptual footprint, is whether MessageSender on RECEIVED_MARK is worth it vs session + installation resolution like the rest of the messages package. Everything else is polish, test-harness DRY, or goal-walk ergonomics.
Happy to approve once you’re satisfied the ctx.flow / sender path is a supported runtime contract (or you document the assumption).
Sent by Cursor Automation: Review For Best Approach
…ark, with no import cycle (FIX-2241) Fallow's audit flagged the board's delivery importing the messages modules, which import the board. The mark messageReceivedEntry puts on its entry now lives in a leaf (received-mark.ts) and carries the flow's teller; the board reads it from the running flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
There was a problem hiding this comment.
Code Snob. A smaller shape is on #4023 (draft, do not merge).
Fold 02615b277 onto a596e197a. Do not reset onto the POC. Close #4023 unmerged after this PR lands.
exemptPlace, isRouted, and filerOf each have one caller. The exempt arm is the object at the budget line. The routed check and the two-arm address stay where they are used. payPlace stays: moving that block into an else only indents it. MessageSender does not need export. Nothing outside the file names it.
The file header, the delivery import comment, messageSenderOf's comment, and the test header repeat the send. The short versions keep the replay id, the budget skip, the cycle, and the Inbox as the one stop.
Net −54 (+28/−82). The text, the id, who is told, and the budget skip are unchanged.
Passed: midway-question-to-filer 5, worker-messages 35, project-coordinator 41, coordinator-agent-delegate 5, conversation-board-notices 17. eslint on the five files, exit 0.
Red: forcing the exempt check false failed the spent-budget case. One message arrived. The second was per_request_limit.
Left as recorded: the exempt send, q:<task>:<hold>, the dynamic import, the sender mark, the routed sentence, one message per hold, the goal, and the docs.
Agent on this PR: fold that subtraction, then close the POC unmerged after this lands.
Sent by Cursor Automation: Code Snob
…ong task goal fits the question (FIX-2241) A flow with no pass (the coder) sends on its own dispatch only, so a send repeated under its id after the first ended between the row and the dispatch now dispatches the untaken row again; the take keeps it once. The task label in a midway question's text is cut to 200 characters, so a long goal never pushes the message past its limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq
|
On the simplification proposal (POC #4023): most of it no longer applies after c514080. Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4488646c44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…(FIX-2241) The answer tool refuses a confirm answered with a message alone (confirm_takes_done), so the text told to the filer now names done: true or false for a confirm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq


Requested by Jake · project
Implements part 2 of the merged spec specs/issues/FIX-2241, a child of epic FIX-2070. Part 1 (orchestration's
onMidwayQuestionhook) merged as #4003.Stacked on #4020 (FIX-2239). This diff is FIX-2241's work only. When #4020 merges, this PR's base moves to main.
What changes
askQuestion,askMidway, a coding run's marker)updateTask({ id, question, message })answers it withoutgetTaskquestion_is_the_users)conversationDelivery.onMidwayQuestionreads a teller off the running flow'sonMessageReceivedmark (messages/received-mark.ts, a leaf) and calls it;messageReceivedEntrybuilds the teller with its installation and flow kind, so any worker flow can send, the coder included. The mark and its readers (messageHearingOftoo) moved to the leaf so the board imports no messages module: Fallow flagged the cycle a direct import made.{ session: row.filer.sessionId }.q:<task>:<hold>: a replayed asking turn writes nothing new (FIX-2240's take on the row). The coder has no session board pass, so it is fast path only and the replay is the resend, as approved in the cross-spec review.sendMessage(…, { exempt: true }): the server's own message takes a place one past its turn's hop without writing the chain row or the request count. The old budget block moved verbatim intopayPlace.Evidence
packages/workforce/test/midway-question-to-filer.test.ts(5 tests): one message naming task and question, one row underq:…, a later touch sends nothing more; two questions atperTurn: 1both arrive (control: dropexempt, the test fails, run here); the routed text, the title, the shortening.project-coordinator.test.ts: a task routed to a workstream whose lead asks midway tells the coordinator's conversation once, with the Inbox wording and noupdateTask.conversation-board-notices.test.ts(FIX-2131's held-question test) andcoordinator-agent-delegate.test.tsnow expect the told question where they expected nothing.packages/shift-manager/test/devteam-chief-of-staff-tasks.test.ts: the coder's own question (marker) reaches the chief of staff's conversation once. Red with the hook removed (run here).command.test.ts › getAssetPath(), which needsdist-clientbuilt (same as on feat(workforce): a worker can call another worker and wait for the reply (FIX-2239) #4020). Typecheck clean for workforce, shift-manager and goals;guard:control-shape,fallow:auditandfallow:new-dead-codepass locally against the base.goals/shift-manager/every-stop-is-one-inbox-item, j1 amended:j1:filer-hears,j1:filer-answers-own(now with no line from Alice after the filing),j1:one-item,j1b:coder-heard(desk.front's model files the coder's task), plus controlno-question-message.openai/gpt-6-luna) + Claude Code: PASS 3 of 3 (GOAL_LEGS=j1), before the cycle refactor; after it, j1 PASS again on the scripted harness and the control still fails its two tags.no-question-messagefailedj1:filer-hearsandj1b:coder-heard, as it must.j1:routed-toldand thequestion-payscontrol are not walked in the goal. The desk Lab has no project or workstream to route to, and the walk never spends a budget. Both are pinned model-free instead (the project-coordinator test and the perTurn test above). goal.md says so.ask-tool-onlywas not added: every path goes throughaskMidway, so it would test nothing separate fromno-question-message.Docs
apps/docs/docs/workforce/messaging-workers.md(new "When a task asks a question", budget note),packages/workforce/README.md, one link in the task-board page. Written and edit-reviewed by the docs agents. Changeset:a-filer-is-told-its-tasks-question.md(workforce, minor).🤖 Generated with Claude Code
https://claude.ai/code/session_01NczDiGpFCnt8J8YxSM1pHq