Repository navigation
fix(acp): bound ACP server startup with a timeout - #4126
Merged
Merged
Conversation
ACPAgent._start_acp_server ran its spawn + authenticate + session-create coroutine with no timeout, so a hung ACP call during startup (e.g. codex-acp blocking on an expired id_token inside authenticate()) froze init_state() forever with no error ever surfaced to the client. Add acp_startup_timeout (default 90s) and pass it to the existing run_async(timeout=...) support, converting the resulting bare TimeoutError into a descriptive one and classifying it as a new ACPStartupTimeout code in _classify_acp_init_error. Wired the new field through ACPAgentSettings, ACPAgentProfile, and the settings<->profile conversion helpers (seed.py, resolver.py) alongside the existing acp_prompt_timeout field they already mirror.
Collaborator
|
[Automatic Post]: I have assigned @neubig as a reviewer based on the repository MAINTAINERS file. Thanks in advance for the help! This comment was created by an AI agent (OpenHands) on behalf of the user. |
1 of 5 tasks
5 tasks
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.
HUMAN:
Picked this up from the open issue tracker, fix verified locally.
AGENT:
Why
ACPAgent._start_acp_serverruns its spawn +initialize()/authenticate()/new_session()/load_session()coroutine (_init()) viaself._executor.run_async(_init)with no timeout. If any of those ACP calls hang — e.g. codex-acp blocking indefinitely onauthenticate()when the localid_tokenis expired — the coroutine never returns and never raises, soinit_state()freezes forever. Because a silent hang never raises, the existingtry/exceptininit_state()that emits a typedConversationErrorEventis never reached, and the client sees no error at all — just a spinner forever.Summary
acp_startup_timeout: float(default 90s) toACPAgent, mirroring the existingacp_prompt_timeoutidle-timeout field.timeout=self.acp_startup_timeoutto the existingrun_async(...)call (it already supports atimeoutkwarg viaanyio.fail_after, already used elsewhere in this file for the prompt-turn idle timeout).TimeoutError(anyio.fail_afterraises one with no message) is caught and re-raised with a descriptive message, mirroring_idle_timeout_message()'s pattern for the turn-loop path.ACPStartupTimeoutbranch to_classify_acp_init_error()soinit_state()'s existing cold-start error handler emits a typedConversationErrorEventinstead of the genericACPInitError.acp_prompt_timeout:ACPAgentSettings(+ itscreate_agent()pass-through),ACPAgentProfile, and the two settings↔profile conversion helpers (profiles/seed.py,profiles/resolver.py).Issue Number
#3629
How to Test
Ran the full local test suite after the change:
Added two new regression tests that reproduce the reported hang directly:
test_start_acp_server_bounds_a_hung_handshake_callmakesconn.initialize()hang for 10s withacp_startup_timeout=0.05, and asserts_start_acp_serverraises a descriptiveTimeoutErrorwell before the 10s would elapse (test runs in well under a second).test_init_state_surfaces_startup_timeoutdrives the same hang through the fullinit_state()path and asserts the client-facingConversationErrorEventcarries codeACPStartupTimeoutand the descriptive detail message. Also addedtest_timeout_error_is_startup_timeoutfor the classifier unit.Pre-commit hooks (ruff format, ruff lint, pycodestyle, pyright, import-dependency rules, tool-subclass registration) all passed on commit.
Video/Screenshots
Not applicable — backend Python logic fix with no UI surface; verified via the tests above.
Type
Notes
New field defaults to 90s, within the 60-90s range suggested in the issue. No breaking changes — existing callers get the new timeout automatically with a sane default; no config migration needed.