fix: add request timeout to prevent infinite hangs during scoring loop#56
Open
TristanSchneider-dev wants to merge 1 commit into
Open
fix: add request timeout to prevent infinite hangs during scoring loop#56TristanSchneider-dev wants to merge 1 commit into
TristanSchneider-dev wants to merge 1 commit into
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.
Add request timeout to prevent infinite hangs during scoring loop
Midway through the pipeline, I noticed that it got stuck indefinitely because the API stopped responding. :(
Problem
The pipeline can hang indefinitely when the OpenAI API server stops responding midrequest.
Error flow
During the detailed requirement scoring loop in
minimal_agent.py, every requirement triggers a separate API call. Earlier logs show a503 Service Unavailablethat eventually succeeded after retry. At some point the API connection stalled silently ? the traceback showshttpcoreblocked onself._protocol.read_event.wait()with no timeout configured onChatOpenAI. Theasyncio.exceptions.CancelledErroronly appeared after a manualKeyboardInterrupt; without that the process hangs forever.Fix
Added
timeoutandmax_retriesto theChatOpenAIconstructor intreesearch/llm/query.py:Parameters are reused from config.toml
request_timeoutmax_retriesWhy it works..
A x-second timeout ensures unresponsive calls raise a httpx.TimeoutException instead of hanging forever.
The exception is caught by the existing try/except blocks in minimal_agent.py, which mark the requirement as is_fulfilled=False and continue the pipeline gracefully.
3 automatic retries handle transient failures (like the observed 503) without manual intervention.