feat(agent): apply per-reasoning-model stale-timeout floor in stream + non-stream detectors (#52217) - #52845
Merged
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-argument-type |
11 |
unresolved-import |
1 |
First entries
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `bool`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `list[str] | None`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `str`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `list[str]`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `int | float`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `list[dict[str, Any]]`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `dict[str, Any]`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `((str, dict[Unknown, Unknown], /) -> None) | None`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:38: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `int | float | None`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `int`, found `str | bool`
tests/agent/test_reasoning_stale_timeout_floor.py:154: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `IterationBudget`, found `str | bool`
✅ Fixed issues: none
Unchanged: 6003 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
…+ non-stream detectors Wire get_reasoning_stale_timeout_floor() into both stale detectors so known reasoning models (Nemotron 3 Ultra, OpenAI o1/o3, Opus 4.x thinking, DeepSeek R1, Qwen QwQ, Grok reasoning) tolerate multi-minute thinking phases instead of the upstream gateway idle-killing the socket (BrokenPipeError) before first token. Applied as max(default, floor) — never overrides explicit user config, never lowers an existing threshold. The reasoning_timeouts.py allowlist module already landed on main via #52795, so this salvage carries only the wiring + tests (the duplicate module and the stale-base MoA reverts from the original PR branch are dropped). Salvaged from #52238. Fixes #52217.
teknium1
force-pushed
the
salvage/52238-reasoning-floor-wiring
branch
from
June 26, 2026 05:04
600dbdf to
add3830
Compare
5 tasks
1 task
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
Known reasoning models now tolerate their multi-minute thinking phase instead of having the upstream cloud gateway idle-kill the socket (
BrokenPipeError/RemoteProtocolError) before the first token arrives.The reasoning-model allowlist (
agent/reasoning_timeouts.py) already landed onmainvia #52795. This PR wires its floor into the two stale detectors that previously used the chat-model defaults (180s stream / 90s non-stream), which are too short for reasoning models.Salvage of #52238 (fixes #52217), cherry-picked onto current
mainwith @DavidMetcalfe's authorship preserved.Changes
agent/chat_completion_helpers.py— stream stale detector consultsget_reasoning_stale_timeout_floor()and applies it asmax(stream_timeout, floor).run_agent.py— non-stream detector (_resolved_api_call_stale_timeout_base) returns the reasoning floor withuses_implicit_default=False, so the local-endpoint short-circuit doesn't disable stale detection for reasoning models on a local NIM endpoint.tests/agent/test_reasoning_stale_timeout_floor.py— 51 tests covering the floor table, anchoring, and wiring.Dropped from the original PR branch (now redundant / stale): the duplicate
agent/reasoning_timeouts.py(already onmain), and the stale-base reverts of the MoA client path /_extract_landed_file_mutation_paths/moa_configthat the original branch carried because it predated those landing onmain.Contract (verified)
providers.<id>.models.<model>.stale_timeout_seconds,HERMES_API_CALL_STALE_TIMEOUT, etc. resolve first.max(default, floor).Nonefrom the allowlist.Validation
Live E2E through the real
AIAgent._resolved_api_call_stale_timeout_base()resolution chain (real imports, tempHERMES_HOME):nvidia/nemotron-3-ultra-550b-a55bopenai/o3-miniopenai/gpt-4oHERMES_API_CALL_STALE_TIMEOUT=45Stream-detector path verified:
max(180 base, 600 floor) == 600; chat model floorNone→ base unchanged; floor never lowers (max(300, 300) == 300).Tests:
tests/agent/test_reasoning_stale_timeout_floor.py— 51/51 passing.Test plan
Infographic