fix: enrich MCP tool errors with recovery directive for schema drift (Closes #1393) - #1398
Merged
Merged
Conversation
…1393) When an MCP tool returns not_found or validation errors (tool-definition drift where the server-side schema changed but Hermes' cached definition didn't update), the error was returned with no recovery guidance. Agents retried with slightly different arguments in a loop (19 failed sessions/7d). The enriched error now appends a Recovery directive telling the agent to use tool_describe or tool_search to check the current schema and retry with corrected arguments, or find an alternative tool if it no longer exists. Triggers on error text containing: not_found, 'not found', validation, invalid. Closes #1393 Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
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
When an MCP tool returns
not_foundor validation errors (tool-definition drift — the server-side schema changed but Hermes' cached definition didn't update), the error was returned with no recovery guidance. Agents retried with slightly different arguments in a loop — 19 failed sessions in 7 days.Fix
Enriched the
isErrorresponse path in_make_tool_handler(tools/mcp_tool.py). When the error text containsnot_found,not found,validation, orinvalid, a recovery directive is appended:This tells the agent to re-check the schema (via
tool_describe) or find an alternative (viatool_search) instead of retrying the same failing call.Files
tools/mcp_tool.py— error enrichment inisErrorbranch (17 lines added)tests/tools/test_mcp_error_enrichment.py— 8 tests covering all trigger keywords + negative cases (105 lines)Validation
ruff check✓ruff format --check✓pytest tests/tools/test_mcp_error_enrichment.py— 8 passed ✓Closes #1393