Skip to content

feat(workforce): a worker can call another worker and wait for the reply (FIX-2239) - #4020

Merged
jhoffner merged 70 commits into
mainfrom
claude/project-thread-ymfvzj
Oct 28, 2026
Merged

jhoffner merged 70 commits into
mainfrom
claude/project-thread-ymfvzj

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Implements the merged spec specs/issues/FIX-2239, a child of epic FIX-2070.

Base is main. #4008 (FIX-2240), which this was stacked on, has merged. Main is merged in, and the diff is FIX-2239's work only.

What changes

Someone who… Before After
needs another worker's answer to go on sends, ends the turn, and is woken later by a message back sendMessage({ to, text, wait: true, deadline? }) returns the reply as the tool's result in the same turn
calls a worker that is slow — gets { status: "running", callId } at the deadline. Nothing is stopped and the reply is kept. sendMessage({ callId }) waits again: it sends nothing, writes no row and pays no budget
messages a conversation stopped for the user, or a task held on the user's stop or question the message landed beside the stop it waits until nothing holds it. The row says queuedBehind: "user", and a call's running answer says recipient: "waiting_on_person"
watches Shift Manager — the tool line reads Asking / Asked <worker> with the reply under it. Messages marks call · waiting / waiting on the user / answered / answered late
  • Core:
    • waitOnRequest is the park half of dispatcher({ wait: true }), now exported and shared. The dispatcher uses it with its old plan key, so in-flight replays still match.
    • RequestHost.waits.userStop() returns the session's request that is parked for the user.
  • Engine:
    • userStop is backed by the suspension listing and isUserSuspension.
    • When a request ends through a run that resumed it, the request also resumes the { requestId } gates in its own session.
  • Orchestration:
    • checkWaitable is the one wait check, shared by getTask({ wait }) and a call. It runs the host guard (canHoldWait), then the deadline bounds, then depth, and claims the step (wait_already_pending) last, so a refusal leaves no claim behind.
    • It also exports toolCallOf.
  • Workforce:
    • messages/call.ts runs checkWaitable before anything is written. It then sends under runOnce and follows the acting request: dispatch, then takenBy, then deliveredAs.
    • messages/queue.ts holds the entry's admission, between FIX-2240's take and the items, and only on a host that can hold a wait.
    • The entry's request stamps the call row's repliedAt.
    • The woken turn's prompt says that a call's reply goes back as the result.

Cross-spec points (Jake approved), and changes made while building

  1. A call parks on takenBy until the message is delivered, then on deliveredAs.
  2. queuedBehind replaces heldBy. Its value is "user", not "person". The pre-push vocabulary check retires "person" where it means the signed-in user, so personStop is now userStop too. recipient: "waiting_on_person" stays as epic D3 locked it.
  3. A task's session reads its row with FIX-2160's rowsInSession and hasOpenHold.
  4. Calls have their own gate ids and keys: call: / fsd.call.*, and queue: / fsd.queue.* for a held message.
  5. Found while building: a held message parks with parkOnWait directly, because it also binds to a task row.
  6. From review: the call's wait check and getTask's are now one function, which claims the step last.

The build changes are amended into specs/issues/FIX-2239/DECISIONS.md.

One Codex point is declined, with reasons on its thread. A call whose first dispatch fails transiently answers running instead of polling for the resend. There is no request or task row to bind a gate to, and the resend timer outlasts most deadlines.

Evidence

  • Tests:
    • packages/core/test/wait-on-request.test.ts (5).
    • packages/engine/test/wait-own-session.test.ts (4): the own-session resume works; a plain request end lists nothing; other gates are left alone; userStop scope is checked.
    • packages/workforce/test/worker-calls.test.ts:
      • a call is answered in its turn;
      • wait_unavailable writes no row;
      • one wait per step;
      • out-of-range deadline and no_such_call are refused;
      • a call queued behind a stop;
      • a busy recipient is answered late;
      • wait_too_deep is refused at 6, and the refusal leaves no step claim. That last check was red before the claim moved last.
    • packages/workforce/test/message-queue.test.ts (4): a question hold; no hold; a host without a sweeper doesn't park (red without the canHoldWait guard); the user's stop; depth 6.
  • Suites on the merged tree: core 2548, engine 4108, orchestration 2149 and workforce 1634 all pass. Typecheck passes for core, engine, orchestration, workforce and shift-manager. Fallow new-dead-code, check-retired-terms and the changeset check pass too.
  • Goal goals/shift-manager/workers-message-each-other, legs 10, 10b and 10c on real models (workers openai/gpt-5.4-mini, coordinator anthropic/claude-haiku-5-5):
    • 3 of 3 runs PASS.
    • All six controls fail on their assertion, and each patch reached its code:
      • no-person-hold: 10b:queued
      • ignore-deadline: 10b:queued
      • no-default-deadline: 10:default-deadline
      • send-again: 10b:kept
      • relay-the-call: 10:no-second-line
      • no-step-guard: 10c:one-wait-per-step
    • The verdict is logged in goal.md.

No changeset for shift-manager (an app). The changesets are a-worker-calls-another.md (workforce), wait-on-a-request.md (core, engine) and export-tool-call-of.md (orchestration).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB

claude added 30 commits October 27, 2026 21:15
…ageReceived (FIX-2238)

The tool is sendMessage, the entry onMessageReceived, replyTo is inReplyTo;
no alias for the old names (FIX-2070 ER-7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…elayed (FIX-2238)

onMessageReceived lands a history-only line and a client-only
workforce:received component, and hands the flow's turn the received
message (id, from, text, call, inReplyTo, budget). The relay goes: a worker
answers with sendMessage and inReplyTo, or not at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
An answer lands in its original's session; a message to the filer lands in
the filing session (new readonly filingWorkerId). Workers that hear only in
their tasks' sessions are refused by name before the row is written. The
delegate's ongoing session is born with its filer's count, and a task held
from its filing starts a fresh chain when released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
…ure exports (FIX-2240)

takeRule/decideTake (own | busy | takeover) and nextResendAt are what the
task-notice take and pass already decide by; worker messages will decide
by the same pieces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…ure exports (FIX-2240)

takeRule/decideTake (own | busy | takeover) and nextResendAt are what the
task-notice take and pass already decide by; worker messages will decide
by the same pieces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
The send owes its session's board pass and keeps the id on an owed list,
writes the row, and dispatches once. onMessageReceived takes the message
on its row (orchestration's take rule, with take-over), lands the items,
then marks it delivered. The pass sends an owed message again by the
notice backoff until it lands, is refused (final), or passes the host's
debt age; a late failure leaves a line in the sending session. The two
tries, the tool's unconfirmed answer and the 500-id window go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…peat safely under a server id (FIX-2240)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…dn't be delivered past the debt age (FIX-2240)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…ailure line (FIX-2240)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
hireWorkforce refuses a worker flow without an onMessageReceived built by
messageReceivedEntry. The coder hears only in its tasks' sessions; the error
reporter's turn runs for a message. messageReceivedEntry and its types are
exported. Shift Manager draws workforce:received as its own item under the
sender's name, replacing the 'From X:' prefix match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…k reads its principal's session (FIX-2160)

The partitioned ledger keeps an id index written by its own add
(findTaskPartitions, taskLedgerResources); the request host gains
sessions.read, which answers a session of the running principal with its
flow and readonly state, and any other as absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… shared (FIX-2160)

The door's talk runs as a block of its own that a coder can also run for a
message: it resumes a finished task's coding session once and answers
{ reply, taskId }, and refuses a task still open (task-running), since a
message never steers. rowsInSession, in orchestration, is the one reader of
the rows that run in a session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…before the row (FIX-2160)

A { task } target finds its row through the conversation ledger's id index
and lands in the session its run named; a { session } target lands in that
conversation of the user's. Both are checked on the session's record
(requestHost.sessions.read): the user, org and tenant, the worker and its
flow now, and for { session } that it is a conversation. A coder's task
still running is refused task_running. Shift Manager names the target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
The retired-terms guard reads 'kind' as a worker-flow word on Workforce's
ground, so the row field is addressedBy, not toKind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… from the coding session (FIX-2160)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
Docs and READMEs describe sendMessage, onMessageReceived, the received
item (which now carries the budget left), the landing rules, the budget and
the refusals. The workers-message-each-other goal gets the spec's new legs,
controls and sweep. The epic's seam table, ER-6 and stack order follow the
cross-spec review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…k reads its principal's session (FIX-2160)

The partitioned ledger keeps an id index written by its own add
(findTaskPartitions, taskLedgerResources); the request host gains
sessions.read, which answers a session of the running principal with its
flow and readonly state, and any other as absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… shared (FIX-2160)

The door's talk runs as a block of its own that a coder can also run for a
message: it resumes a finished task's coding session once and answers
{ reply, taskId }, and refuses a task still open (task-running), since a
message never steers. rowsInSession, in orchestration, is the one reader of
the rows that run in a session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…before the row (FIX-2160)

A { task } target finds its row through the conversation ledger's id index
and lands in the session its run named; a { session } target lands in that
conversation of the user's. Both are checked on the session's record
(requestHost.sessions.read): the user, org and tenant, the worker and its
flow now, and for { session } that it is a conversation. A coder's task
still running is refused task_running. Shift Manager names the target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
The retired-terms guard reads 'kind' as a worker-flow word on Workforce's
ground, so the row field is addressedBy, not toKind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… from the coding session (FIX-2160)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…task; changesets (FIX-2160)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… once (FIX-2240)

Pins the case a review on #4010 found: a claim before the items made a
retry read as a duplicate. The take alone isn't a delivery, so the
sender's pass resends and the next request takes it over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
Resolve the FIX-2070 DECISIONS.md conflict by keeping both amendments:
the stack order and FIX-2160's addressedBy/toTask from this branch, the
FIX-2240 take-and-resend fields from main.

Review on #4010:
- send-message: one placeAfter helper for a send's place; the pre-read
  of the chain row is gone, since reserve, conditional update and
  give-back already refuse an over-budget send at no cost.
- messageReceivedProblem takes the flow and reads its internal actions
  itself, so the hire carries no copy of the flow's shape.
- runs-on-one-task goal: the roster's own tools are listDelegates and
  sendMessage.
- Goal leg 2b names sendMessage, since "wait" alone led the model to
  file a task and wait on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…dger's id index (FIX-2160)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…Items (FIX-2240)

The serialized queue swallows write errors, so flushItems resolved after a
failed write and the message entry's barrier marked delivered without stored
items. The filesystem store now records the item error and rethrows it from
flushItems, as flushEvents already does and the Postgres store's flush does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…2239)

Split out of dispatcher({ wait: true })'s private sendAndWait so a call, a
wait-again by call id and a held message park on the one wait gate the same
way. Takes a deadline in ms from now, the host's default when unset. The
dispatcher keeps its runOnce keys, so in-flight waits replay unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
…its deadline (FIX-2239)

sendMessage takes wait, deadline and callId. A call parks on the one wait
gate, bound to the request that acts on the message (its dispatch, then the
row's taker, then deliveredAs), and answers with that request's reply, the
final text of the recipient's onMessageReceived turn. At the deadline it
answers running with its call id, and sendMessage({ callId }) waits again
without sending. Every check runs before the row.

A message to a session stopped for a person, or to a task held on one,
queues at onMessageReceived's admission (queuedBehind: person) until nothing
holds it. The engine reads a session's open person stop
(RequestWaits.personStop) and, from a run that resumed a request, resumes
gates its own session parked on that request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
… row (FIX-2239)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
…ols (FIX-2239)

Leg 2b (no waiting) is replaced. DevTeam takes DEVTEAM_WAIT_DEFAULT_MS, so
the goal can time a call's default deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
…rose (FIX-2239)

The vocabulary check retires "person" where it means the signed-in user, so
the row's queued mark is queuedBehind: "user".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
@jhoffner jhoffner self-assigned this Oct 28, 2026
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

FIX-2239

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 28, 2026 1:19am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 28, 2026 1:19am UTC
flow-state-dev-ui Ignored Ignored Preview Oct 28, 2026 1:19am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T01:18:18.908762Z 7a80fa5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jhoffner jhoffner left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second look + architecture pass (read-only; for the picking-up agent to triage)

Overall the approach holds: waitOnRequest as the shared park half is the right cut, call stays a message rather than a task, and the tests exercise the intent. Findings below are about whether the diff earns its scope. None block on correctness that I could trace; #1 is the one place this PR is an opportunity to refactor while adding the feature.

1. Duplicated wait-check ladder (worth doing in this PR)

checkWait in packages/workforce/src/messages/call.ts:47 re-implements the ladder in check() in packages/orchestration/src/tasks/helpers/wait-on-task.ts: canHoldWait/runOnce/suspend guard → wait_unavailable, deadline bounds → wait_deadline_out_of_range, the fsd.wait.step:<stepKey> claim → wait_already_pending, and depthRefusal → wait_too_deep. Same codes, near-same prose. The PR exports toolCallOf only so workforce can copy it. Two copies of one rule (the step-claim key is a string both must agree on) will drift.

Leaner shape: extract the task-independent part (guard, bounds, step claim, depth) next to toolCallOf in orchestration (or waitOnRequest's neighbour in core) as one checkWaitable(ctx, { key, deadlineMs, step, binding }) returning refusal or { deadlineMs }; waitOnTask.check keeps its task-specific refusals and the board-slot checks, and callWorker calls the shared piece. That also makes the three-changeset footprint smaller and removes the need for the toolCallOf export to be a public surface.

2. Claim is consumed before later refusals

In checkWait, the step claim (call.ts:69) is taken before the depth check and before sendMessage can refuse (unknown recipient, budget). A refused call says "Nothing was sent", but the step is now claimed, so a second wait in the same step gets wait_already_pending though nothing waits. With parallel tool calls in one step, one bad recipient blocks a good one. Consider claiming only after the send is accepted, or releasing on refusal. (Same ordering exists in waitOnTask, so this may be a shared fix via #1.)

3. Not-admitted call can spin

queueBehindPerson returns not_admitted → entry ends with {} → the caller's awaitReply sees completed without a reply, re-reads the row, after === target (call.ts:191) → running. waitAgain then targets the same ended takenBy request, which completes at once with no reply → running again immediately. Until the sending session's pass resends, a model told to "wait again" can loop each step at no delay. Plausible, not reproduced. Worth either a test for it or a distinct running hint (e.g. not waiting again on a request that already ended without a reply).

4. Entry output schema changed from tapIf to stepIf (message-received-entry.ts:267-273)

The entry's output was the heard marker; it is now { reply? }. isHeard discriminates by heardSchema.safeParse plus an "act" in value check, so a turn whose own output happens to carry act: "none" | "heard" is read as the heard step. Low odds, but the discrimination is by shape rather than by construction. A cleaner way is to carry the heard marker in request state (you already set RECEIVED_CALL_STATE there) and let the final step read that instead of sniffing the output. Also confirm nothing outside the tests read act off the entry's output (my grep found no src/ consumers, only tests).

5. Vocabulary is inconsistent within the PR

Stored/visible values say "user" (queuedBehind: "user"), while the new public core hook is RequestWaits.personStop, and workforce has queueBehindPerson/personHoldOf. The PR text says the pre-push check retires "person" for the signed-in user; personStop is a new exported core name and is harder to rename later than the internals. Suggest userStop (and the workforce helpers) now, keeping recipient: "waiting_on_person" as epic D3 locked it. queuedBehind is also a one-literal enum ("user"), effectively a boolean; fine if more holders are planned, otherwise queued: true is simpler.

6. Smaller notes

  • replied truncates the reply silently to MAX_MESSAGE_CHARS; the caller cannot tell it was cut. Say so in the result (or in the description) rather than slicing quietly.
  • waitOnRequest takes both deadlineMs and deadlineAt; only call uses deadlineAt. Fine now, but one input (deadlineAt, with the dispatcher computing it) would be a smaller API.
  • personStop does a listSuspended on every message admission, not only for calls. The engine test shows ending a plain request lists nothing extra, but every take now pays a listing; worth a cheap short-circuit if the session has never parked.

What I'd leave alone

queue.ts parking directly with parkOnWait (documented as needed for the task-row binding) and the own-session resume in wait-chain.ts look proportionate and are tested with controls.


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify pass (FIX-2239)

Verdict: The shape of this change is the right one for the spec. A call is not a synthetic task row, and folding send+wait into a second tool would fight epic D1/ER-1. Extracting waitOnRequest from the dispatcher and keeping queue.ts on raw parkOnWait for mixed bindings (request vs task row) matches DECISIONS and avoids a parallel wait mechanism.

What reads as “a lot of code” is mostly domain surface area, not accidental abstraction:

Layer Role
waitOnRequest (core) Shared park + outcome mapping for { requestId } binds
call.ts Tool-facing checks, idempotent send, follow-the-acting-request loop
queue.ts Admission hold behind person stop / question (D3)
Engine personStop + own-session resume Extends existing wait-chain, not a new gate

The follow loop in awaitReply is the hardest block, but it is doing real work (taker handoff, copy/dead request, fresh queuedBehind for running) that dispatcher({ wait: true }) cannot subsume in one dispatch.

Could a simpler approach have worked?

  • getTask + wait on a message-shaped task — Rejected in spec/epic; would duplicate budget/row semantics and fight “calls are messages.”
  • wait: true only while recipient is idle — Rejected; breaks queue-behind-person and late-reply retention.
  • One mega-module instead of call + queue — Would still need both admission parking and caller-side wait; the split matches onMessageReceived admission vs sendMessage tool.
  • Third-party package — Nothing obvious replaces durable parkOnWait / session replay; this correctly composes engine primitives.

Follow-ups worth considering (non-blocking)

  1. Dedupe tool-step wait prechecks — call.ts checkWait parallels wait-on-task.ts (host, deadline bounds, fsd.wait.step, depth). A shared helper next to exported toolCallOf would shrink drift risk when bounds change.
  2. replyOf / replyTextOf — Same { reply } extraction in call.ts and message-received-entry.ts; one small shared helper if turn output shape evolves.
  3. gateId vs planKey docs — WaitOnRequestInput says gate id is “the same on every replay,” but callers pass a fresh UUID; replay stability is really planKey + runOnce. Clarify in core docs to avoid wrong refactors.
  4. Optional planAndPark in core — queue.ts duplicates the runOnce plan + parkOnWait shape that waitOnRequest uses; only worth it if a third copy appears.
  5. Perf (later) — waitChainDepth / personStop list all pending suspensions per user; fine at current scale, but the cost grows with concurrent parked waits. Roster fetch on every controlTools resolution in message-tool.ts predates/is amplified by calls but is unrelated to call correctness.

Organization / imports

messages/call.ts + queue.ts beside delivery/send is clean. Workforce → orchestration for holds/toolCallOf matches existing patterns; no core → workforce back-edges. Goal leg legs-calls.mts is long but encodes anti-game signals the spec demands — I would not shrink it at the expense of verification strength.

No major concerns from this pass; approving with the nits above as optional polish.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread packages/workforce/src/messages/call.ts Resolved
Comment thread packages/workforce/src/messages/call.ts Resolved
Comment thread packages/workforce/src/messages/call.ts Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Snob — already tight. No POC.

Head f417cda1e. I read packages/workforce/src/messages/call.ts, queue.ts, message-tool.ts, message-received-entry.ts, packages/core/src/blocks/wait-on-request.ts, dispatcher.ts (sendAndWait), packages/orchestration/src/tasks/helpers/wait-on-task.ts, packages/shift-manager/src/components/ToolLine.tsx, surfaces/Messages.tsx, packages/engine/src/durability/wait-chain.ts, execution/runAction.ts, and goals/shift-manager/workers-message-each-other/legs-calls.mts against act / talk.

  • waitOnRequest is the shared park, and sendAndWait already calls it. A held message stays on parkOnWait: it binds to a task row and has to see a stop (recorded on this PR).
  • checkWait is getTask's four checks with this tool's sentences ("Nothing was sent") and a request binding. Those checks in wait-on-task.ts are private and sit among the task refusals. A shared helper still carries both sentences and both bindings. The step claim is already shared: fsd.wait.step: through toolCallOf, which this PR only exports.
  • awaitReply is the follow: the dispatch request, then takenBy, then deliveredAs, at most five. The no-target read is wait-again's first step. Pulling it out of the loop repeats the ended/target checks. endedReason and replyOf have one caller; inlining drops the name. actingRequest has two.
  • The tool's four refusals belong to one strict object, so callId can omit to and text. A union replaces the strings the model reads. callAnswer is the two call sites.
  • replyTextOf accepts a string or { reply }. replyOf accepts { reply } and returns undefined when it is absent. isHeard's extra act check is the predicate beside safeParse.
  • ToolLine's label is six phrases. callOutcomeLine has one caller; inlining drops the name. callNote reads the row (waiting, waiting on the user, answered, answered late). The tool line reads the tool output.
  • talkThrough polls until the request ends and records when it left suspended. act returns on the first status outside RUNNING, which is the park. A flag on act still leaves that record.
  • The headers in call.ts and queue.ts restate the functions under them. Cutting them shortens the comment. The checks, the follow, and the two parks stay the same length.
  • The changeset, the README, and the docs page each stand on their own. The goal legs and the unit tests read different things.

Left as recorded: park on takenBy then deliveredAs; queuedBehind: "user"; rowsInSession and hasOpenHold; call: / queue: gates; parkOnWait for a held message; recipient: "waiting_on_person".

One prose mismatch, same length: .changeset/a-worker-calls-another.md still says queuedBehind: "person". The row writes "user".

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

Base automatically changed from claude/project-thread-3uc91a to main October 28, 2026 00:54
…all; userStop (FIX-2239)

- checkWaitable is the shared ladder (host, bounds, depth, step); the step is
  claimed after the depth check.
- The reply step reads whether a message landed from request state.
- RequestHost.waits.personStop is userStop, as the vocabulary check says.
- The tool says a reply is cut to 8,000 characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB

Copy link
Copy Markdown
Collaborator Author

Triage of the second-look review, as of fa03d24. Each point either changed the code or has a reason it didn't.

  1. Duplicated wait-check ladder: fixed. checkWaitable in orchestration (tasks/helpers/wait-on-task.ts, exported from /task-board) is now the one ladder: host, bounds, depth, then step. getTask's check keeps only its task-specific refusals and the board's own guard. checkWait in call.ts is now a thin wrapper around checkWaitable. toolCallOf stays exported, because a call still needs its logical id and step key.
  2. Step claimed before later refusals: partly fixed. The step is now claimed last, after the depth check, for both getTask and calls. A depth refusal no longer holds the step: worker-calls.test.ts "a call's depth" asserts this, and the test failed before the change. A refusal from sendMessage itself (unknown recipient, budget) still comes after the claim. The claim has to come before the send, because otherwise two parallel calls in one step could both send before either is refused. The cost is one refused call blocking a sibling in the same step, and that sibling can call on the next step. I judged that rare and cheap, so I left it.
  3. Not-admitted call spinning: not changed. not_admitted happens only when a message's park would be the sixth deep, or when its request was stopped while queued. In both cases running is the true answer, and FIX-2240's pass resends the message, after which waiting again finds the new taker. Each extra wait is a model step the model chose to take, not a busy loop in the engine. I didn't add a field to cover it.
  4. Entry output read by shape: fixed. The heard step writes workforceReceivedLanded to request state, and the reply step reads that. It no longer infers the heard marker from its input's shape, so isHeard is gone. Nothing in src/ reads act off the entry's output.
  5. Vocabulary: fixed. The names are now RequestWaits.userStop, queueBehindUser and userHoldOf. recipient: "waiting_on_person" stays as epic D3 locked it. queuedBehind keeps its approved name, with the one value "user".
  6. Smaller notes.
    • Reply truncation: the tool description now says the reply is cut to 8,000 characters.
    • deadlineMs alongside deadlineAt on waitOnRequest: left as is. The dispatcher passes ms and its plan key is unchanged, which keeps in-flight replays working.
    • userStop listing per admission: left as is. It is one listing per message delivery, filtered by session, and deliveries are rare next to turns.

Package suites: core, engine, orchestration and workforce all pass. Retired-terms passes, and new-dead-code passes. The goal's legs 10, 10b and 10c passed in 3 of 3 real-model runs on f6536df and f417cda. The controls are still running.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa03d24170

ℹ️ 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".

if (target === undefined) {
const next = await read(round);
if ("ended" in next && next.ended !== undefined) return { status: "failed", callId: id, error: next.ended };
if (!("target" in next) || next.target === undefined) return running();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep waiting while the initial delivery is being retried

When the initial dispatch throws or receives a retryable refusal before the recipient takes the message, sendMessage preserves the unconfirmed row for redelivery and returns success without a requestId. This branch then returns running immediately, even with time remaining before the deadline. Consequently, a transient delivery failure that recovers within the requested deadline prevents the caller from receiving the reply in its current turn; waiting again before redelivery also returns immediately. Keep the call parked or rechecking until an acting request exists or the deadline expires.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this one. It's a deliberate edge.

  • No binding to park on. With no acting request, a wait gate binds to a request or a task row, and a message row is neither. A deadline-only recheck would need a new kind of gate in core.
  • The resend is slower than most calls. It comes from the sending session's pass, at NOTICE_DUE_MS plus backoff. Most call deadlines would pass before it arrives.
  • The case is rare. Only a thrown dispatch or dispatch-rejected, no-dispatch-operation or flow-not-found leaves the row unconfirmed. A busy recipient is accepted and deferred, so it gets a requestId.
  • Nothing is lost. The call answers running with its callId, the reply is kept on the row, and sendMessage({ callId }) waits on the taker once the resend has one. DECISIONS already drops leaning on the resend timer for the same reason ("a call would have no request to wait on meanwhile").

If this turns out to matter, the right shape is a gate bound to the message row, as a follow-up.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
…can hold a wait; goal verdict for legs 10-10c (FIX-2239)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
@jhoffner

Copy link
Copy Markdown
Collaborator Author

Resolve conflicts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB

Copy link
Copy Markdown
Collaborator Author

I resolved the conflict in 851acb3. The only conflict was the verdict log in goal.md, where #4019's FIX-2160 row and this PR's row landed on the same line. Both rows are kept, with main's first. No code was in conflict.


Generated by Claude Code

@jhoffner
jhoffner added this pull request to stack #4046 October 28, 2026 12:08
@jhoffner
jhoffner merged commit 3c10d9d into main Oct 28, 2026
18 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-ymfvzj branch October 28, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants