Skip to content

fix(providers): prevent idle timeouts during hidden reasoning - #114997

Merged
steipete merged 1 commit into
mainfrom
codex/fix-openai-compatible-hidden-reasoning-idle
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-openai-compatible-hidden-reasoning-idle

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #113323.

What Problem This Solves

Fixes an issue where users running a local OpenAI-compatible reasoning model would lose active agent turns to LLM idle timeout while the provider was continuously streaming hidden reasoning. The failure affects providers such as vLLM when the model is configured with reasoning disabled but its server still sends reasoning-only chat-completion chunks before the visible answer.

Why This Change Was Made

Notify the existing model-request activity channel for every valid streamed OpenAI-compatible completion chunk, in both the built-in provider and the managed transport. This lets the existing idle watchdog observe genuine provider progress without emitting hidden thinking, weakening timeouts, changing model configuration, expanding the plugin SDK, or adding provider-specific policy. Regression coverage handles the current vLLM reasoning field and legacy reasoning_content / reasoning_text variants. The stream shape is checked against the pinned [email protected] implementation and vLLM's documented streaming reasoning output.

User Impact

Local and OpenAI-compatible reasoning models can finish a long thinking phase and return their normal visible reply without a false idle timeout. Private reasoning remains private, genuine silent-provider timeouts still fire, and configured timeout and fallback behavior remain unchanged.

Evidence

  • Reproduced both failures against the unpatched current main on Blacksmith Testbox tbx_01kykmwgs3356cawv0yc4vkhyw: four hidden reasoning chunks produced zero model-activity notifications, and a real 127.0.0.1 HTTP/SSE provider hit the production idle watchdog while reasoning chunks were still arriving.
  • After the fix, the same real loopback SSE provider completes successfully beyond the watchdog budget for both reasoning and reasoning_content, returns OK, emits no thinking, and never fires the idle callback.
  • pnpm test packages/ai/src/providers/openai-completions.test.ts — 59 passing tests, including three hidden reasoning field variants.
  • pnpm test src/agents/openai-transport-stream.streaming.test.ts — 46 passing tests, including both real HTTP/SSE provider reproductions.
  • pnpm test src/agents/embedded-agent-runner/run/llm-idle-timeout.test.ts — 123 passing watchdog regressions.
  • pnpm test packages/ai/src/provider-transport-parity.test.ts — 4 passing provider/transport parity tests.
  • pnpm check:changed — passed formatting, core and test TypeScript, typed lint, plugin/SDK boundaries, dependency and environment guards, SQLite/storage guards, and runtime import-cycle checks on the same Testbox.
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean; no actionable findings.

AI-assisted implementation and review.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete-oai
steipete-oai marked this pull request as ready for review July 28, 2026 06:38
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 2:43 AM ET / 06:43 UTC.

ClawSweeper review

What this changes

The PR reports each valid OpenAI-compatible completion chunk as model-request activity in both streaming implementations so hidden reasoning chunks can prevent false idle timeouts without emitting private reasoning.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 5 items remain

Keep this PR open for maintainer review. The patch is a plausible, narrowly scoped repair for the broader OpenAI-compatible stream-progress contract, but its cited loopback proof does not establish the original inference.local production path on current main because current idle-timeout code classifies .local and loopback endpoints as local/self-hosted. The PR is also protected by the maintainer label.

Priority: P1
Reviewed head: 741b74866b98cfcf8760a5d0c5fbafd38c6fa85f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused regression coverage are promising, but the available real-behavior proof does not establish the production watchdog path that the broader patch changes.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The PR supplies detailed loopback SSE evidence, but current main classifies loopback and .local provider URLs under local/self-hosted watchdog handling, so the evidence does not yet isolate the broader standard watchdog behavior changed by this patch. Please add redacted live output, logs, or a terminal recording from a non-local or explicitly standard-watchdog configuration; updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR supplies detailed loopback SSE evidence, but current main classifies loopback and .local provider URLs under local/self-hosted watchdog handling, so the evidence does not yet isolate the broader standard watchdog behavior changed by this patch. Please add redacted live output, logs, or a terminal recording from a non-local or explicitly standard-watchdog configuration; updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Current built-in parser behavior: Current main accepts hidden reasoning fields (reasoning_content, reasoning, and reasoning_text) while deciding whether to emit thinking, but it has no request-activity notification in the stream loop; the PR adds that notification after a valid chunk is received.
Current local endpoint handling: Current idle-timeout code explicitly recognizes loopback and *.local provider endpoints as local/self-hosted and assigns them a separate watchdog policy, so a 127.0.0.1 or inference.local proof cannot by itself demonstrate the default remote-provider idle path changed by this PR.
Proposed stream-progress repair: The branch adds the existing activity notification to the built-in OpenAI-compatible completion loop and mirrors it in the managed transport, while adding hidden-reasoning and SSE watchdog regression coverage.
Findings None None.
Security None None.

How this fits together

OpenAI-compatible provider streams are decoded by either the built-in AI provider or the managed transport, then passed to agent execution. The agent idle watchdog listens for model-request activity to distinguish active provider output from a genuinely stalled model call.

flowchart LR
  Provider[OpenAI-compatible provider] --> Chunks[Streaming completion chunks]
  Chunks --> BuiltIn[Built-in provider parser]
  Chunks --> Transport[Managed transport parser]
  BuiltIn --> Activity[Model request activity]
  Transport --> Activity
  Activity --> Watchdog[Agent idle watchdog]
  BuiltIn --> Reply[Visible assistant reply]
  Transport --> Reply
Loading

Decision needed

Question Recommendation
Should all valid OpenAI-compatible stream chunks, including hidden-reasoning-only chunks, reset the standard model idle watchdog for non-local providers? Confirm generic chunk progress: Accept valid OpenAI-compatible chunks as watchdog activity, then require rebased proof through the standard non-local watchdog path.

Why: The patch intentionally changes the generic definition of provider progress beyond the originally reported local endpoint, while current main already treats the reported local route differently; that contract choice requires maintainer intent.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR supplies detailed loopback SSE evidence, but current main classifies loopback and .local provider URLs under local/self-hosted watchdog handling, so the evidence does not yet isolate the broader standard watchdog behavior changed by this patch. Please add redacted live output, logs, or a terminal recording from a non-local or explicitly standard-watchdog configuration; updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The change broadens the idle-watchdog contract: any valid OpenAI-compatible chunk, including hidden-reasoning-only chunks, now counts as progress. That is likely desirable, but maintainers should explicitly confirm it does not mask a provider that emits structurally valid but non-progressing keepalive chunks.
  • Resolve merge risk (P1) - The cited after-fix loopback SSE evidence does not prove the original inference.local production path on current main, because both loopback and .local endpoints already follow local/self-hosted watchdog handling.
  • Resolve merge risk (P1) - The branch is behind current main; rebase and rerun the focused watchdog proof against the merged result before landing.
Agent review details

Security

None.

PR surface

Source +7, Tests +143. Total +150 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 7 0 +7
Tests 2 143 0 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 150 0 +150

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: src/agents/openai-transport-stream.streaming.test.ts, serialized state: src/agents/openai-transport-stream.streaming.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove the standard watchdog path (recommended)
    Rebase, then show a redacted after-fix run through a non-local OpenAI-compatible endpoint or an explicitly non-local test configuration so the new progress rule—not the local exemption—is what prevents timeout.
  2. Accept the broader progress contract
    If maintainers intentionally treat every valid streamed completion chunk as progress, document that decision in review and land after the rebased focused tests pass.

Technical review

Best possible solution:

Retain the two-path activity notification if maintainers confirm that valid provider chunks are the intended cross-provider progress signal, then rebase and provide redacted after-fix evidence through a non-local OpenAI-compatible endpoint or an explicit test configuration that exercises the default watchdog path.

Do we have a high-confidence way to reproduce the issue?

No high-confidence current-main reproduction of the original local route was established: current source gives loopback and *.local endpoints separate local/self-hosted idle-timeout handling. The broader hidden-reasoning chunk gap is source-supported, but its standard remote-watchdog impact still needs a targeted run.

Is this the best way to solve the issue?

Unclear. Reporting valid hidden-reasoning chunks as activity is the narrowest shared repair across the two OpenAI-compatible stream paths, but the best final contract depends on maintainer confirmation that valid chunks—not only visible/tool output—should reset the generic watchdog.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f0ef1c6d33e4.

Labels

Label changes:

  • add P1: The linked bug can abort active agent turns for users of affected OpenAI-compatible reasoning providers.
  • add merge-risk: 🚨 availability: The PR changes the condition that keeps the model idle watchdog alive across both OpenAI-compatible streaming paths.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR supplies detailed loopback SSE evidence, but current main classifies loopback and .local provider URLs under local/self-hosted watchdog handling, so the evidence does not yet isolate the broader standard watchdog behavior changed by this patch. Please add redacted live output, logs, or a terminal recording from a non-local or explicitly standard-watchdog configuration; updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The linked bug can abort active agent turns for users of affected OpenAI-compatible reasoning providers.
  • merge-risk: 🚨 availability: The PR changes the condition that keeps the model idle watchdog alive across both OpenAI-compatible streaming paths.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR supplies detailed loopback SSE evidence, but current main classifies loopback and .local provider URLs under local/self-hosted watchdog handling, so the evidence does not yet isolate the broader standard watchdog behavior changed by this patch. Please add redacted live output, logs, or a terminal recording from a non-local or explicitly standard-watchdog configuration; updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current built-in parser behavior: Current main accepts hidden reasoning fields (reasoning_content, reasoning, and reasoning_text) while deciding whether to emit thinking, but it has no request-activity notification in the stream loop; the PR adds that notification after a valid chunk is received. (packages/ai/src/providers/openai-completions.ts:411, f0ef1c6d33e4)
  • Current local endpoint handling: Current idle-timeout code explicitly recognizes loopback and *.local provider endpoints as local/self-hosted and assigns them a separate watchdog policy, so a 127.0.0.1 or inference.local proof cannot by itself demonstrate the default remote-provider idle path changed by this PR. (src/agents/embedded-agent-runner/run/llm-idle-timeout.ts:2, f0ef1c6d33e4)
  • Proposed stream-progress repair: The branch adds the existing activity notification to the built-in OpenAI-compatible completion loop and mirrors it in the managed transport, while adding hidden-reasoning and SSE watchdog regression coverage. (packages/ai/src/providers/openai-completions.ts:394, 741b74866b98)
  • Linked bug and prior review context: The linked report describes an inference.local route that aborts during hidden reasoning; the prior ClawSweeper cycle correctly identified that current main’s local-provider treatment changes the relevance of the loopback proof, while the branch changes a broader chunk-progress invariant.

Likely related people:

  • steipete: Authored the proposed provider-stream repair and supplied the accompanying validation rationale; current-main ownership provenance was not available through the read-only inspection backend. (role: likely follow-up owner; confidence: low; commits: 741b74866b98; files: packages/ai/src/providers/openai-completions.ts, packages/ai/src/transports/openai-completions-transport.ts, src/agents/openai-transport-stream.streaming.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the focused provider and idle-timeout regressions.
  • Add redacted after-fix live proof that exercises the non-local or explicitly standard watchdog path.
  • Obtain maintainer confirmation of the all-valid-chunks progress contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-28T06:36:24.223Z sha 741b748 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer-requested landing follow-up for the latest ClawSweeper rank-up moves at reviewed head 741b74866b98cfcf8760a5d0c5fbafd38c6fa85f:

  • Rebase: intentionally skipped. The exact reviewed head is mergeable and its complete GitHub CI, CodeQL, and CodeQL Critical Quality are green. The repository landing contract treats behind-main drift as advisory; rebasing would invalidate the reviewed, proven head without correcting a conflict.
  • Explicit standard-watchdog behavior: already exercised in src/agents/openai-transport-stream.streaming.test.ts. The real HTTP/SSE loopback server streams five hidden reasoning chunks at 35 ms intervals; the production streamWithIdleTimeout(createOpenAICompletionsTransportStreamFn(), 100, onIdleTimeout) is explicitly enabled and receives the actual stream. On unpatched main this exact test fails with LLM idle timeout; after the fix it completes beyond 100 ms, returns OK, emits no private thinking, and never calls the timeout callback for both reasoning and reasoning_content. This test invokes the standard watchdog directly; local-hostname classification does not bypass it.
  • Generic progress contract: explicitly approved by the maintainer’s request to land this exact PR. Only valid parsed OpenAI-compatible chunks notify the already-existing request activity channel; no timeout defaults, configuration, or provider-specific policy change.

All 232 focused tests, pnpm check:changed, independent autoreview, and exact-head hosted CI are green.

@steipete
steipete merged commit 0216fbd into main Jul 28, 2026
186 of 196 checks passed
@steipete
steipete deleted the codex/fix-openai-compatible-hidden-reasoning-idle branch July 28, 2026 07:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LLM idle timeout aborts agent runs during reasoning-token streaming on a local reasoning model

1 participant