Commit c604b90
authored
fix: use semantic JSON comparison for MCP approval argument matching (#5080)
## Summary
MCP tool approval matching fails intermittently because LLMs may
serialize
tool call arguments differently between the first turn (where the
approval
request is created) and the second turn (where the approval is looked
up).
For example, the first call may include
`{"liquid_name":"x","celsius":true}`
while the re-invocation omits the defaulted field:
`{"liquid_name":"x"}`.
The current code compares argument strings with `==`, so these are
treated as
different tool calls and a new approval request is emitted instead of
honoring
the one the user already approved.
This change parses the JSON before comparing so that semantically
identical
arguments match regardless of serialization differences.
## Test plan
Existing `test_response_mcp_tool_approval` integration test covers this
path.
Made with [Cursor](https://cursor.com)1 parent 424ff0c commit c604b90
1 file changed
Lines changed: 10 additions & 1 deletion
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
| |||
210 | 219 | | |
211 | 220 | | |
212 | 221 | | |
213 | | - | |
| 222 | + | |
214 | 223 | | |
215 | 224 | | |
216 | 225 | | |
| |||
0 commit comments