Tell the Python LangGraph Bot's model why a tool call was refused - #524
Merged
davidmckayv merged 2 commits intoSep 14, 2026
Merged
Conversation
When the deployment refuses a callback from the Python LangGraph Bot it answers with a status and the reason under `error`: a token it no longer accepts, one issued to another Bot, or a malformed call. The Bot dropped the reason and told its model only "Refused. Tool callback returned HTTP 403.", so the model could say a call was refused but not why, and could not correct a call the deployment had named as malformed. The reason now follows the status, the way the TypeScript LangGraph Bot passes it on since CopilotKit#518. It is read on its own, so a body that is not JSON still reads as the refusal it was rather than as a failed callback. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 13, 2026 21:52
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
# Conflicts: # CHANGELOG.md
davidmckayv
approved these changes
Sep 14, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Deep-reviewed clean (validation, no secret leak, fail-closed, agrees with existing layers). CI green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
When the deployment will not run a tool call from the Python LangGraph Bot (
agent-langgraph-agui),/api/agent-tools/callanswers with a status and the reason undererror: a token it no longer accepts, a token issued to another Bot, or a malformed call (400). The Bot dropped the reason, so its model was told only:The model could say a call was refused but not why, and could not correct a call the deployment had named as malformed. The TypeScript LangGraph Bot passes the reason on since #518 (
agent-langgraph/src/tool-answer.ts); this is the same reading for the Python one:The reason is read on its own, so a body that is not JSON (a proxy's HTML error page) still reads as
Refused. Tool callback returned HTTP 502.rather than falling into the "could not be completed" branch, and a blankerroradds nothing. A successful call is untouched.Where it runs
Boundary and audit
mcp.callback_refusedrow are unchanged; only what the Bot tells its model changes.Changelog
CHANGELOG.mdunderUnreleased.Proof
New parametrised test in
agent-langgraph-agui/tests/test_tool_protocol.py, driven through the real AG-UI endpoint against the file's existing loopback callback server (the fixture can now reply with a chosen body).Before the fix:
(The blank-reason and non-JSON 502 cases already passed and stay as guards.)
After, the whole Bot suite as CI runs it:
The two failures are
test_chatgpt_token_provider_atomic_writer_*, which rundocker runand write under/tmp. They fail identically onmainon this machine (no Docker), so they are environmental, not this change.🤖 Generated with Claude Code