Skip to content

fix(protocol): validate MCP JSON reply IDs - #1010

Open
saiyam-jain-dev wants to merge 2 commits into
scaleapi:mainfrom
saiyam-jain-dev:fix/tool-session-json-reply-id
Open

saiyam-jain-dev wants to merge 2 commits into
scaleapi:mainfrom
saiyam-jain-dev:fix/tool-session-json-reply-id

Conversation

@saiyam-jain-dev

@saiyam-jain-dev saiyam-jain-dev commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What and why

ToolSession matched replies to request IDs on the SSE path, but accepted JSON replies with a missing or mismatched id. That could cause a reply for a different request to be returned as the current tool result.

The JSON path now raises ToolSessionError when the reply ID is missing or does not match the request. Added regression cases for both.

How it was tested

  • Both regression cases failed before the fix and passed afterward.
  • .venv/bin/pytest -o addopts='' -q packages/agentenv-protocol/tests/test_tool_client.py passed all 36 tests.
  • make lint and git diff --check passed.

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge.

Summary

ToolSession now rejects JSON replies whose id is missing or differs from the request.

  • ToolSession matches JSON replies to the request that sent them.

Reviews (1) · Last reviewed commit: "test(protocol): cover missing and mismat..." · Reviewed by Greptile

@saiyam-jain-dev
saiyam-jain-dev requested a review from a team as a code owner December 4, 2026 20:01

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant