Skip to content

fix: enrich MCP tool errors with recovery directive for schema drift (Closes #1393) - #1398

Merged
Lexus2016 merged 1 commit into
mainfrom
evolution/issue-1393-mcp-validation-recovery
Jul 28, 2026
Merged

fix: enrich MCP tool errors with recovery directive for schema drift (Closes #1393)#1398
Lexus2016 merged 1 commit into
mainfrom
evolution/issue-1393-mcp-validation-recovery

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Summary

When an MCP tool returns not_found or 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 isError response path in _make_tool_handler (tools/mcp_tool.py). When the error text contains not_found, not found, validation, or invalid, a recovery directive is appended:

Recovery: the tool definition for '<tool_name>' may have changed on the MCP server. Use tool_describe or tool_search to check the current schema, then retry with corrected arguments. If the tool no longer exists, use tool_search to find an alternative.

This tells the agent to re-check the schema (via tool_describe) or find an alternative (via tool_search) instead of retrying the same failing call.

Files

  • tools/mcp_tool.py — error enrichment in isError branch (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 ✓
  • Total diff: 125 lines (under 200-line autonomous merge cap)

Closes #1393

…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>
@github-actions github-actions Bot added the fix Bug or fix label Jul 28, 2026
@Lexus2016
Lexus2016 merged commit 2d5166f into main Jul 28, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug or fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] mcp__composio__composio_remote_workbench — 19 failed sessions/7d, not_found + validation errors, NEW pattern

1 participant