Skip to content

fix(agent): guard float infinity to int conversions in stale timeout watchdogs - #65594

Closed
AntonIXO wants to merge 2 commits into
NousResearch:mainfrom
AntonIXO:fix-moa-float-infinity-overflow
Closed

fix(agent): guard float infinity to int conversions in stale timeout watchdogs#65594
AntonIXO wants to merge 2 commits into
NousResearch:mainfrom
AntonIXO:fix-moa-float-infinity-overflow

Conversation

@AntonIXO

@AntonIXO AntonIXO commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Prevent OverflowError: cannot convert float infinity to integer when the non-streaming API watchdog formats an unbounded timeout.

Root cause / reproduction

_compute_non_stream_stale_timeout() intentionally returns float("inf") for local endpoints such as moa://local. After 100 polling intervals (100 × 0.3s ≈ 30s), the wait-notice heartbeat formatted that value with int(_deadline), aborting an otherwise-live MoA request. The outer conversation loop then retried, producing failures at approximately 30s, 62s, and 97s.

This PR now includes a deterministic regression test that drives the exact 100-poll MoA heartbeat without waiting 30 seconds. Before the fix it fails at chat_completion_helpers.py with the reported OverflowError; after the fix it emits auto-reconnect at never and leaves the request alive.

Fix

Guard infinite timeout formatting in the wait-notice path and the related TTFB, stream-idle, and stale-timeout diagnostic paths.

Relation to #64924

This overlaps with #64924 on the primary wait-notice cast. It is broader rather than independent: it also guards the related watchdog diagnostic/error formatting and adds direct MoA regression coverage for the observed 30-second failure.

Verification

  • tests/agent/test_infinite_stale_timeout_wait_notice.py: 1 passed
  • tests/agent/test_reasoning_stale_timeout_floor.py: 57 passed
  • tests/agent/test_codex_ttfb_watchdog.py: 13 passed

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jul 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #64924: both guard infinite timeout formatting in chat_completion_helpers.py, but this PR additionally covers TTFB, idle, and stale-timeout error paths, so it is a broader overlapping fix rather than a duplicate.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment

Scope

  • 1 file (agent/chat_completion_helpers.py), +10/-3 lines
  • Guards float-to-int conversions when deadline/timeout values are infinity.

Quality

  • F-strings with conditional formatting: display "inf" instead of crashing on int(float('inf')).
  • Consistent with the infinite-wait-deadline fix in PR 65606 (same file context).

Looks Good

  • Small, correct fix for a real edge case.

Reviewed by Hermes Agent

@teknium1

Copy link
Copy Markdown
Contributor

Superseded by #66139, which has now merged the same MoA/local heartbeat fix with the full 100-poll regression shape from this PR, plus accurate finite-watchdog selection and fail-open notice construction.

#66139 explicitly credits this PR for the full-heartbeat regression approach. Thank you for the production evidence and coverage.

@teknium1 teknium1 closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants