Repository navigation
fix(github): keep repository requests off the event loop - #306
Open
Linxiushen wants to merge 1 commit into
Open
Linxiushen wants to merge 1 commit into
Linxiushen wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHubToolkit.get_repo_info()is async, but its synchronous HTTP request and response handling run on the event-loop thread. A slow GitHub response therefore prevents unrelated agent coroutines from progressing, including when the tool is called throughAsyncBaseToolkit.call_tool().Move the existing implementation into a private synchronous helper and await it with
asyncio.to_thread(). The public tool registration, response fields, and error mapping stay the same, and caller context variables reach the request worker. Cancelling the coroutine releases its awaiter; it does not terminate an HTTP request already running in the worker. This change adds no timeout or retry policy.Closes #304.
Validation on Windows / Python 3.12.14 with native package imports, OpenAI Agents 0.10.4, Requests 2.34.2, and pytest-asyncio 1.3.0:
c2caa539f4c95ae1c39ed24dc8a99cb3651e1d5d, the new tests have 3 failures and 11 passing controls: direct/dispatcher calls starve a heartbeat during a real Requests call to a local HTTP server, and a pending dispatcher call cannot be cancelled.pytest tests/tools/test_github_toolkit.py tests/tools/test_base.pyhas 17 passing tests. Coverage includes response/default fields, HTTP/connection/parse errors, invalid URLs, context propagation, cancellation, registration, and existing toolkit schema tests.git diff --checkpass. Full-repository checks still report the same 3 lint findings and 9 files requiring formatting on both pristine base and this branch; those checks are not reported as passing.Validation used only loopback HTTP and explicit transport doubles; no live GitHub API, provider/model, GPU, or production load test was run. The test process imported the full original package and native dispatcher, without extracting methods or bypassing package initializers.
AI assistance was used to inspect the code, implement the fix, and prepare the tests and this description. The baseline failures, final tests, and exact diff were reviewed locally.