Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/agents/mcp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,11 @@ async def invoke_mcp_tool(
error_message = f"Invalid JSON input for tool {tool_name_for_display}"
if _debug.DONT_LOG_TOOL_DATA:
logger.debug(error_message)
Comment on lines 593 to 594
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid chaining raw tool input in the redaction path

When _debug.DONT_LOG_TOOL_DATA is true, this branch now falls through to raise ... from json_decode_error, but json.JSONDecodeError retains the original payload in its .doc attribute. For malformed MCP tool arguments containing secrets, any caller or error reporter that inspects chained exceptions can recover the redacted input; this also contradicts the existing redaction regression in tests/mcp/test_mcp_util.py that expects __cause__ and __context__ to be absent in this mode.

Useful? React with 👍 / 👎.

raise ModelBehaviorError(error_message)
raise ModelBehaviorError(error_message) from None
else:
error_message = f"{error_message}: {input_json}"
logger.debug(error_message)
raise ModelBehaviorError(error_message) from json_decode_error
raise ModelBehaviorError(error_message) from json_decode_error

if not isinstance(json_data, dict):
raise ModelBehaviorError(
Expand Down