fix: return connector tool errors as tool results instead of throwing - #451
Open
Ashu (ashudhanda) wants to merge 1 commit into
Open
fix: return connector tool errors as tool results instead of throwing#451Ashu (ashudhanda) wants to merge 1 commit into
Ashu (ashudhanda) wants to merge 1 commit into
Conversation
Thrown tool errors abort the agent run and the model never sees the guidance written for it (e.g. "run openwiki_list_mcp_tools first and use an exact discovered name"). Wrap every connector tool func so errors come back as a `Tool error: <message>` result the model can self-correct from. Closes langchain-ai#427
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.
Summary
Closes #427
Every
funcincreateOpenWikiConnectorTools()currently lets errors propagate. A thrown tool error aborts the whole agent run, so the model never sees the error messages that were written for it — e.g. theopenwiki_call_mcp_toolguidance to runopenwiki_list_mcp_toolsfirst and retry with an exact discovered tool name. A single hallucinated tool name or one expired connector token kills the entire wiki-build instead of letting the agent self-correct or continue with other connectors.Change
Added a small
wrapToolErrorshelper insrc/connectors/tools.tsand applied it to all seven connector tools via.map(wrapToolErrors)on the returned array, following the approach suggested (and verified with a local patch) in the issue:Behavior
Tool error: <message>as the tool result, matching how LangChain's ownToolNodereports errors, so the agent can retry with corrected input or move onthrows (input validation, MCP-backed checks) are preserved and simply surface through the wrapperKept the scope minimal per the issue; making
ingestAllConnectorscollect per-connector failures individually could be a follow-up.