Fix app-server reader recovery for large messages - #36
Open
dimavrem22 wants to merge 3 commits into
Open
Conversation
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.
Executive Summary
Prevent bridged Codex turns from hanging when app-server emits large or early completion messages.
0.2.9.turn/startcapture registration.Description
This change adds
CODEX_APP_SERVER_STREAM_LIMIT_BYTES, threads it through the subprocess stream reader, and documents its 16 MiB default. Reader-loop exceptions now produce an error log, fail every pending request and turn, terminate the child, and make client health false immediately. Session acquisition disconnects an unhealthy client and resumes the saved thread in a replacement process.run_detailednow buffers agent-message, item-completed, and turn-completed notifications while theturn/startresponse is pending, then replays notifications for the returned turn after capture registration. Subprocess teardown is also bounded and awaits background task cleanup.Reason
Python's default asyncio subprocess stream limit is 64 KiB. A larger app-server JSON line could stop the only stdout reader while turn futures remained pending until the outer turn timeout. Independently, app-server can emit completion notifications immediately after its
turn/startresponse; the reader can process those lines before the awaiting coroutine registers its turn capture, dropping the completion and causing the same visible hang.Decisions
turn/startregistration window and replay only the returned turn's events.Testing
442 passed, 24 skipped.443 passed, 23 skipped.0.146.0host contract:5 passed.item/completedandturn/completedfixtures exceed 64 KiB; verify successful parsing at the default limit; and verify low-limit failure logging, settlement of multiple pending requests and an active turn, child termination, unhealthy-client replacement, and early notification replay.