Skip to content

Conversation

@jaylonmcshan19-x
Copy link
Contributor

PCI review checklist

When tool input validation fails, errors were returned as Protocol Errors (JSON-RPC ). These errors were caught at the MCP Client level and never reach the LLM's context window. which causes:

  • The Model retries sort of blindly with the same invalid inputs
  • Repeated failures without any feedback loop
  • leads to a less desired user experience due to there needing manual intervention

This PR creates utils.ToolError() and utils.ToolErrorf() helpers that return Tool Execution Errors (isError: true) instead of Protocol Errors (Existing flow). Tool Execution Errors are included in the JSON-RPC response body, making them visible to the LLM.

Example flow:

return nil, utils.LogAndReturnError(logger, "missing input", err)
// → Protocol Error → The Model never sees this, which will result in retries, and repeated failures
return utils.ToolError(logger, "missing input", err)
// → Tool Execution Error → Model can now sees this and can self-correct
  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Changelog Warning

Please add a changelog entry to CHANGELOG.md for this change. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant