Skip to content

MCP tool sets: newer turn's set can be overwritten by a late drop or late check (#961 follow-up) #986

Closed

Description

@scuttletoby

Follow-ups from the round-2 state lens on #961 (#961 (comment)). None blocks: each fails closed (Refused until the thread's next turn) or needs a check that outlives a whole turn.

  • apps/server/src/fork/mcpT3ToolSets.ts:99, :145-147: a timed-out hold's drop can overwrite a set a newer turn already fixed (a joining turn keeps the first turn's 10 s deadline; a turn T3 starts itself does not touch the hold).
  • apps/server/src/fork/codexMcpProfile.ts:370: two checks finishing out of order: the last to finish wins, so a late check could give a wider set if the profile was narrowed in between (predates MCP profiles: follow-ups for Codex and the T3 tool rule (#812, #814, #918) #961).
  • Tiny window between a check fixing its set and releasing its hold: a request whose wait ends exactly then writes Refused over the new set.

One fix covers all three: tag each fixed set with a per-thread counter (or time); a drop or a late check writes only if no newer turn has fixed a set. Add a test for each order.

🤖 Generated with Claude Code

Activity

  1. scuttletoby commented on Nov 22, 2026

    @scuttletoby
    OwnerAuthor

    Two more from the round-2 code lens on #961 (#961 (comment)); point 3 there is the same race as the first item above.

    • claudeMcpProfile.ts:770: the "never wider" plan-key comparison has no test of its own (it only fails in a full run because an earlier test leaves a key in the module-global openedPlanKeys). Add a reset hook for tests and a test where a process opened with one key meets a different, wider plan.
    • claudeMcpProfile.ts:715: the 4096 cap evicts the oldest-opened process, not the least used; refresh the entry when a plan matches.

    🤖 Generated with Claude Code

  2. added 2 commits that reference this issue on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions