Skip to content

Conversation

Unshure
Copy link
Member

@Unshure Unshure commented Sep 18, 2025

Description

  • Add module-level flag _instrumentation_applied to track patch state
  • Return early from mcp_instrumentation() if already applied
  • Prevents wrapper accumulation that causes RecursionError with multiple MCPClient instances
  • Add integration tests for multiple client creation and thread safety

🤖 Assisted by Amazon Q Developer

Related Issues

Fixes #869

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Add module-level flag _instrumentation_applied to track patch state
- Return early from mcp_instrumentation() if already applied
- Prevents wrapper accumulation that causes RecursionError with multiple MCPClient instances
- Add integration tests for multiple client creation and thread safety

Fixes strands-agents#869

🤖 Assisted by Amazon Q Developer
@Unshure Unshure merged commit 337c43e into strands-agents:main Sep 18, 2025
12 checks passed
@Unshure Unshure mentioned this pull request Sep 19, 2025
7 tasks
@Unshure Unshure deleted the fix-mcp-inst branch September 25, 2025 00:59
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.

[BUG] MCP Instrumentation Wrapper Not Idempotent - Hits Python Recursion Limit

3 participants