Python: remove hardcoded 30s default timeout from JsonRpcClient.request()#592
Conversation
The Python SDK's JsonRpcClient.request() had a hardcoded 30s default timeout via asyncio.wait_for(), unlike the other three SDK languages (Go, Node/TS, .NET) which all wait indefinitely for the server to respond. Change the default from timeout=30.0 to timeout=None so that requests wait indefinitely by default, matching the behavior of the other SDKs. Callers can still pass an explicit timeout when needed. Fixes #539 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a timeout inconsistency in the Python SDK by removing the hardcoded 30-second default timeout from JsonRpcClient.request(), making it wait indefinitely like the Go, Node/TypeScript, and .NET SDKs. This resolves issue #539 where long-running RPC calls such as fleet.start would fail with asyncio.TimeoutError after 30 seconds, even though the operation was still in progress.
Changes:
- Changed
JsonRpcClient.request()default timeout from 30 seconds to None (wait indefinitely) - Updated implementation to conditionally use
asyncio.wait_for()only when an explicit timeout is provided - Updated docstrings to reflect the new timeout behavior
✅ Cross-SDK Consistency Review: PASSEDThis PR successfully resolves a timeout inconsistency in the Python SDK by aligning its behavior with the other three SDK implementations. Summary of ChangesThe PR removes the hardcoded 30-second timeout from Cross-SDK VerificationI verified the timeout behavior across all four SDK implementations:
Implementation DetailsPython (
Node.js (
Go (
.NET (
ConclusionThis change brings the Python SDK into alignment with the established pattern across all other SDKs. The fix is correct and maintains API consistency. 🎉 No additional cross-SDK changes are needed.
|
Add cast() calls for handler results that go through inspect.isawaitable(), which loses type narrowing: - session.py: _handle_permission_request, _handle_user_input_request - client.py: _execute_tool_call Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Cross-SDK Consistency ReviewThis PR successfully brings the Python SDK into alignment with the timeout behavior of the other three SDKs. The change removes the hardcoded 30-second timeout and makes Python wait indefinitely by default, matching:
Additional ChangesThe other changes in this PR are type casting additions ( No consistency issues identified. This PR improves consistency across the SDK implementations. ✅
|
Summary
Changes
JsonRpcClient.request()default timeout from30.0toNone, so requests wait indefinitely for the server to respond — matching the behavior of the Go, Node/TypeScript, and .NET SDKs.Related
Fixes #539