Skip to content

Conversation

@cagataycali
Copy link
Member

Description

Fixes a TypeError: not all arguments converted during string formatting error that occurs when MCP error messages contain % characters (common in URL-encoded strings from MCP servers like Bedrock AgentCore).

Related Issues

Fixes #1244

Root Cause

In _handle_error_message(), the log call was:

self._log_debug_with_thread("ignoring non-fatal MCP session error", message)

The format string had no %s placeholder, but message was passed as an argument. When message contained % characters (e.g., unknown request id: abc%20123), Python's % formatting in _log_debug_with_thread would fail.

Solution

Add %s format specifier to the log message:

self._log_debug_with_thread("ignoring non-fatal MCP session error: %s", message)

Documentation PR

No documentation changes required.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Added regression test test_handle_error_message_with_percent_in_message
  • All 109 existing MCP tests pass
  • hatch fmt --formatter
  • hatch fmt --linter

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective
  • My changes generate no new warnings

🦆

@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dbschmigelski dbschmigelski merged commit 56676c1 into strands-agents:main Jan 12, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ERROR - Unhandled exception in receive loop: not all arguments converted during string formatting

3 participants