Skip to content

fix(server): validate sampling tool-use history - #3049

Open
Adebayo120 wants to merge 2 commits into
modelcontextprotocol:mainfrom
Adebayo120:fix/sampling-tool-use-balance
Open

Adebayo120 wants to merge 2 commits into
modelcontextprotocol:mainfrom
Adebayo120:fix/sampling-tool-use-balance

Conversation

@Adebayo120

Copy link
Copy Markdown

While integrating sampling, I noticed the server would forward a history containing an assistant tool_use without its matching user tool_result.

Reject these incomplete histories before sending the sampling request, and add regression coverage for missing or interrupted results.

Reject sampling histories with assistant tool_use blocks that lack matching tool_result blocks in the next user message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Adebayo120
Adebayo120 requested a review from a team as a code owner October 18, 2026 18:46
@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59b818d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3049

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3049

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3049

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3049

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3049

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3049

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3049

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3049

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3049

commit: 59b818d

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Oct 19, 2026

This branch has not been deployed

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

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant