Skip to content

fix(github): keep repository requests off the event loop - #306

Open
Linxiushen wants to merge 1 commit into
TencentCloudADP:mainfrom
Linxiushen:codex/fix-github-toolkit-async-20261102
Open

Linxiushen wants to merge 1 commit into
TencentCloudADP:mainfrom
Linxiushen:codex/fix-github-toolkit-async-20261102

Conversation

@Linxiushen

Copy link
Copy Markdown

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 through AsyncBaseToolkit.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:

  • On unchanged 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.
  • After the fix, pytest tests/tools/test_github_toolkit.py tests/tools/test_base.py has 17 passing tests. Coverage includes response/default fields, HTTP/connection/parse errors, invalid URLs, context propagation, cancellation, registration, and existing toolkit schema tests.
  • Ruff 0.12.11 lint/format checks for both changed files and git diff --check pass. 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.

This branch has not been deployed

No deployments
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: GitHubToolkit.get_repo_info blocks the asyncio event loop

1 participant