Skip to content

Conversation

@seratch
Copy link
Member

@seratch seratch commented Jan 31, 2026

This pull request resolves #2386 by preventing sync tool functions from blocking the event loop: sync tools are now invoked via asyncio.to_thread in src/agents/tool.py, so parallel tool calls can run concurrently even when some tools are synchronous, and the loop remains responsive. It adds focused tests in tests/test_function_tool.py.

to_thread is chosen over manual run_in_executor because it uses the default thread pool, propagates contextvars automatically (important for tracing/telemetry), and keeps the implementation concise while preserving compatibility with Python 3.9+.

@seratch seratch added this to the 0.7.x milestone Jan 31, 2026
@github-actions github-actions bot added bug Something isn't working enhancement New feature or request feature:core labels Jan 31, 2026
@seratch seratch modified the milestones: 0.7.x, 0.8.x Jan 31, 2026
@seratch seratch merged commit 9a1543a into main Feb 3, 2026
10 checks passed
@seratch seratch deleted the fix/sync-tools-to-thread branch February 3, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync function blocks parallel tool calls

2 participants