fix: guard float infinity in stale timeout display and truncate codex cache key (#65746, #66045) - #66050
Closed
AlexFucuson9 wants to merge 1 commit into
Closed
Conversation
… cache key
Two production crashes fixed:
1. MoA/local calls with non-stream stale timeout of float("inf") crash
with OverflowError when the 30s heartbeat formats int(_deadline).
Guard with math.isinf() and display "∞" instead. (NousResearch#65746)
2. Codex transport emits prompt_cache_key longer than 64 chars when the
fallback to session_id produces a long key (e.g. cron_<id>_<ts>).
The Codex backend rejects >64 chars with HTTP 400 on every turn,
causing silent fallback. Truncate to 64 chars. (NousResearch#66045)
Fixes NousResearch#65746
Fixes NousResearch#66045
Collaborator
tonydwb
reviewed
Jul 17, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM / Comment
Small, targeted fix that guards against float infinity (math.inf) causing display issues in stale timeout UI. Adds isinf check before formatting. No security concerns. Clean and well-scoped.
Contributor
|
Closing as superseded in both parts:
Thank you for responding quickly to both reports. |
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.
Summary
Two production crash fixes in
agent/:1.
chat_completion_helpers.py— OverflowError on infinite stale timeout (#65746)MoA/local calls set non-stream stale timeout to
float("inf"). When the 30-second heartbeat fires,int(_deadline)raisesOverflowError: cannot convert float infinity to integer. The retry loop then mislabels the healthy local request as an API failure and retries 5 times.Fix: Guard with
math.isinf()and display "∞" in the wait notice and timeout error messages. Three call sites protected: the heartbeat display (line ~620), and both timeout error paths (lines ~780, ~786).2.
transports/codex.py— prompt_cache_key > 64 chars causes HTTP 400 on every turn (#66045)When
_content_cache_key()returnsNone(no static content to hash), the fallback issession_id. Cron jobs and long session IDs produce keys > 64 chars. The Codex backend (chatgpt.com/backend-api/codex) rejects anyprompt_cache_keyover 64 characters with HTTP 400. The failure is masked by the fallback chain, making the primary provider appear unused.Fix: Truncate
cache_keyto 64 characters before setting the kwarg. Content-addressed keys (pck_<sha256[:24]>) are 28 chars and unaffected; only the session_id fallback is truncated.Testing
python3 -m py_compilepasses for both filesmath.isinf(float("inf"))returns True (tested locally)Fixes #65746
Fixes #66045