Repository navigation
Description
What happens
spawn_agent derives the child thread id, every command id, and the brief's message id from providerSessionId plus client_request_id alone (apps/server/src/j5/a2a/mcp/handlers.ts, stableInput, now in spawnIds.ts on the crews branches). The orchestrator's dispatch path looks up an existing receipt by command id and, when it was accepted, replays it without comparing the payload (apps/server/src/orchestration-v2/Orchestrator.ts around L7054-7080: "A receipt only proves this exact command was handled", then canReplayCommandReceipt checks only the thread id).
So a second call that reuses a client_request_id with a different brief, provider, model, reasoning, or (since #147) agent:
thread.createreplays the first thread and returns its receipt.recordFactsis idempotent and returns the first home and placement.message.dispatchreplays the first brief by message id.- The handler returns success, naming the first spawn's participant, with none of the new arguments applied.
The caller gets a success response for a spawn that did not happen. Nothing logs the mismatch.
Repro
Two spawn_agent calls from one session with the same client_request_id:
spawn_agent { brief: "Review the auth flow", agent: "scout", provider: "codex", model: "gpt-5.6-terra", reasoning: "high", client_request_id: "k1" }
spawn_agent { brief: "Fix the CI failures", agent: "builder", provider: "codex", model: "gpt-5.6-sol", reasoning: "high", client_request_id: "k1" }
The second call returns the Scout's participant id and the Scout keeps running on the first brief. No Builder exists.
Expected
A reused id with a different payload is refused with a state error naming the original request ("client_request_id k1 already spawned with a different brief/agent; use a fresh id"), the same way a previously rejected id is refused today. Same id, same payload keeps replaying safely.
Notes
- The tool description says "Reuse client_request_id to retry the same spawn safely", so a model that reuses an id for a different spawn is misusing it, which is why this is low priority. The cost when it happens is a silent wrong result, which is the worst kind.
- Every J5 lifecycle verb that takes
client_request_id(stop_agent,archive_agent,join_squadron,propose_crew,request_crew_member,stop_crew,archive_crew) derives ids the same way; check whether the same fix applies before implementing it only for spawn. - Smallest fix: fold a digest of the stable payload into the id derivation is wrong (it would defeat retries after a partial failure). Instead, store the request digest with the first accepted command and compare on replay, or compare the request against the created thread's stored title, model selection, and persona assignment before returning.
Found during the Crews stack review (#147); pre-existing on j5/main.
Activity