Skip to content

propose_crew and request_crew_member silently replay the first proposal when a client_request_id is reused #316

Done

Description

@Jacksondr5

propose_crew and request_crew_member return the first proposal when a client_request_id is reused with different arguments. This is the same silent-replay flaw #181 fixes for spawn_agent.

Where it breaks

  • propose_crew: AgentCrewProposalService.create does INSERT OR IGNORE and returns { status: "existing" } (apps/server/src/j5/a2a/AgentCrewProposalService.ts ~202, ~248). CrewProposalService.propose then returns the first proposal whatever the new brief, name, or seats are.
  • request_crew_member: looks up the proposal by key and returns it without comparing the requested seat (CrewProposalService.ts, "A replayed request finds its proposal before anything is checked").

The caller gets a success response naming a proposal that doesn't match what it asked for.

Checked and not affected

Checked against the code for #181:

  • stop_agent, stop_crew, archive_crew: reusing a key on a different thread raises OrchestratorCommandIdConflictError through canReplayCommandReceipt (Orchestrator.ts ~178, used ~7852). The handler reports it as a state error.
  • join_squadron: placement commands store a request_fingerprint and fail with PlacementCommandConflictError (PlacementService.ts ~490).

What should change

Sequencing

Land after #313, which reworks proposal resolution in CrewProposalService and removes the claim and reopen machinery.

Tests to ship

  • propose_crew with a reused key and a different brief, name, or seats is refused.
  • An identical propose_crew retry replays.
  • The same two cases for request_crew_member.

Found during the #181 audit.

🤖 Generated with Claude Code

Activity

  1. Jacksondr5 commented on Sep 25, 2026

    @Jacksondr5
    OwnerAuthor

    A deeper check found a second, related case in stop_agent and stop_crew. Line numbers are on j5/main at 2cf4ad7a83.

    • Same key, same target, newer run: silent. stop_agent derives the run.interrupt command id from the key (handlers.ts ~915). If the key is reused after the target starts a new run, the command id on the same thread replays the old receipt through canReplayCommandReceipt (Orchestrator.ts ~7852). The call reports interrupt_requested, and the new run keeps going. stop_crew does the same per seat (handlers.ts ~946).
    • Different target: loud. Reusing the key on a different target raises OrchestratorCommandIdConflictError.
    • archive_crew and join_squadron: safe. Details are in the issue body.

    This is a different mechanism from the proposal replay above: it's a stale receipt on the same thread, not an ignored payload. It could be fixed here or split into its own issue.

  2. self-assigned this
    on Oct 19, 2026
  3. bryantderosier commented on Dec 1, 2026

    @bryantderosier
    Collaborator

    The main bug here is fixed. #660 (50e5f28463) and #661 make propose_crew and request_crew_member refuse a reused client_request_id with different arguments, and an identical retry still replays. That's what this issue asked for, so closing.

    One leftover from the 2026-09-25 comment: j5_stop_crew still derives each seat's interrupt command id from the reused key (handlers.ts around line 1094). So reusing a key after a seat starts a new run replays the old receipt and reports "interrupted" while the new run keeps going. (j5_stop_agent was retired in #982.) It needs an agent to reuse a request key across runs, which is rare, so I'm not tracking it unless we actually see it happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions