Skip to content

Python: remove hardcoded 30s default timeout from JsonRpcClient.request()#592

Merged
SteveSandersonMS merged 2 commits intomainfrom
fix/python-rpc-remove-default-timeout
Feb 26, 2026
Merged

Python: remove hardcoded 30s default timeout from JsonRpcClient.request()#592
SteveSandersonMS merged 2 commits intomainfrom
fix/python-rpc-remove-default-timeout

Conversation

@SteveSandersonMS
Copy link
Contributor

@SteveSandersonMS SteveSandersonMS commented Feb 26, 2026

Summary

Changes JsonRpcClient.request() default timeout from 30.0 to None, so requests wait indefinitely for the server to respond — matching the behavior of the Go, Node/TypeScript, and .NET SDKs.

Related

Fixes #539

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>
Copilot AI review requested due to automatic review settings February 26, 2026 13:44
@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner February 26, 2026 13:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@github-actions
Copy link
Contributor

✅ Cross-SDK Consistency Review: PASSED

This PR successfully resolves a timeout inconsistency in the Python SDK by aligning its behavior with the other three SDK implementations.

Summary of Changes

The PR removes the hardcoded 30-second timeout from JsonRpcClient.request() in the Python SDK, making it wait indefinitely by default (when timeout=None).

Cross-SDK Verification

I verified the timeout behavior across all four SDK implementations:

SDK Default RPC Request Timeout Status
Node.js/TypeScript ✅ Indefinite (no timeout) Consistent
Python (before PR) ❌ 30 seconds hardcoded Inconsistent
Python (after PR) ✅ Indefinite (no timeout) FIXED
Go ✅ Indefinite (no timeout) Consistent
.NET ✅ Indefinite (no timeout) Consistent

Implementation Details

Python (python/copilot/jsonrpc.py):

  • Before: timeout: float = 30.0 → hardcoded 30s timeout
  • After: timeout: Optional[float] = None → waits indefinitely by default
  • Uses asyncio.wait_for() only when timeout is explicitly provided

Node.js (nodejs/src/client.ts):

  • Uses vscode-jsonrpc with no timeout configuration
  • Relies on connection-level error handling

Go (go/internal/jsonrpc2/jsonrpc2.go):

  • Line 230-247: Waits on responseChan indefinitely unless process exits
  • No timeout mechanism in the core Request() method

.NET (dotnet/src/Client.cs):

  • Line 870-897: Uses StreamJsonRpc with CancellationToken only
  • No built-in timeout; relies on caller-provided cancellation tokens

Conclusion

This 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.

AI generated by SDK Consistency Review Agent

@SteveSandersonMS SteveSandersonMS changed the title fix(python): remove hardcoded 30s default timeout from JsonRpcClient.request() Python: remove hardcoded 30s default timeout from JsonRpcClient.request() Feb 26, 2026
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>
@github-actions
Copy link
Contributor

✅ Cross-SDK Consistency Review

This 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:

  • Node.js/TypeScript: Uses vscode-jsonrpc's MessageConnection.sendRequest() which waits indefinitely with no default timeout
  • Go: jsonrpc2.Request() uses a simple channel select with no timeout (only exits on response, process done, or stop signal)
  • .NET: InvokeWithCancellationAsync() waits indefinitely unless the caller provides a cancellation token with a timeout

Additional Changes

The other changes in this PR are type casting additions (cast(ToolResult, result) and cast(UserInputResponse, result)) which are Python-specific type checking improvements and don't affect cross-language consistency.

No consistency issues identified. This PR improves consistency across the SDK implementations. ✅

AI generated by SDK Consistency Review Agent

@SteveSandersonMS SteveSandersonMS merged commit 20e5ce0 into main Feb 26, 2026
26 checks passed
@SteveSandersonMS SteveSandersonMS deleted the fix/python-rpc-remove-default-timeout branch February 26, 2026 13:58
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.

"FleetApi.start()" uses default 30s timeout but "fleet.start" RPC blocks until fleet completes

2 participants