Skip to content

[codex] Tune adaptive stream readiness timeouts - #5767

Merged
diegosouzapw merged 6 commits into
cheaper-inference:release/v3.8.43from
nguyenxvotanminh3:codex/performance-streaming-readiness
Jul 2, 2026
Merged

diegosouzapw merged 6 commits into
cheaper-inference:release/v3.8.43from
nguyenxvotanminh3:codex/performance-streaming-readiness

Conversation

@nguyenxvotanminh3

Copy link
Copy Markdown
Contributor

Summary

  • Add STREAM_READINESS_MAX_TIMEOUT_MS so operators can raise the adaptive first-event cap for long-thinking agent workloads without changing code.
  • Raise the default adaptive cap from 120s to 180s for very large/tool-heavy/high-reasoning streaming requests.
  • Wire the cap into chat streaming readiness and document the env knob in .env.example.

Why

Large Codex/Kiro-style agent requests can legitimately take longer before producing the first useful SSE event. The existing adaptive policy could still cap at 120s, causing premature stream-readiness timeouts even though the stream may be alive.

Validation

  • node --import tsx/esm --test tests/unit/runtime-timeouts.test.ts tests/unit/stream-readiness-policy.test.ts tests/unit/stream-readiness.test.ts tests/unit/combo-stream-readiness-fallback.test.ts tests/unit/chat-retry-policy.test.ts
  • node --import tsx/esm --test tests/unit/runtime-timeouts.test.ts tests/unit/stream-readiness-policy.test.ts on the standalone branch
  • npm run typecheck:core
  • npx eslint src/shared/utils/runtimeTimeouts.ts open-sse/config/constants.ts open-sse/handlers/chatCore.ts open-sse/utils/streamReadinessPolicy.ts tests/unit/runtime-timeouts.test.ts tests/unit/stream-readiness-policy.test.ts
  • git diff --check
  • Runtime smoke: http://localhost:20129/api/auth/status returned 200 and resolver accepted STREAM_READINESS_MAX_TIMEOUT_MS=300000

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@nguyenxvotanminh3

Copy link
Copy Markdown
Contributor Author

Follow-up after review: verified the env override test is already asserting 300_000 for STREAM_READINESS_MAX_TIMEOUT_MS=300000 (no 30s typo in this branch). I also added the missing client-side protection for /v1/chat/completions: streaming requests now use the existing withEarlyStreamKeepalive wrapper while the handler is still waiting for upstream stream readiness, so strict clients receive SSE keepalives before the first real upstream event. Added a route-level regression test that delays the upstream stream past the 2s threshold and asserts the downstream body includes : omniroute-keepalive before the real SSE payload.\n\nValidation rerun on the PR branch:\n- node --import tsx/esm --test tests/unit/chat-combo-live-test.test.ts tests/unit/early-stream-keepalive.test.ts tests/unit/runtime-timeouts.test.ts tests/unit/stream-readiness-policy.test.ts (32/32)\n- git diff --check\n- npx eslint src/app/api/v1/chat/completions/route.ts tests/unit/chat-combo-live-test.test.ts (warnings only from pre-existing explicit-any lines in the test file)

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.43 July 1, 2026 23:42
@diegosouzapw
diegosouzapw marked this pull request as ready for review July 1, 2026 23:43
@diegosouzapw
diegosouzapw self-requested a review as a code owner July 1, 2026 23:43
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw
diegosouzapw merged commit 9358eea into cheaper-inference:release/v3.8.43 Jul 2, 2026
3 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @nguyenxvotanminh3! The adaptive readiness cap + env knob + SSE keepalive solves real false-timeouts on high-reasoning runs. Merged into release/v3.8.43. 🙌

diegosouzapw added a commit to nguyenxvotanminh3/OmniRoute that referenced this pull request Jul 2, 2026
…t-goal-resilience-pr

Resolve conflicts against release/v3.8.43 (which now contains cheaper-inference#5767):
preserve the agentGoalPolicy Math.max readiness-timeout guard and the
OMNIROUTE_AGENT_GOAL_* env docs/example blocks, keep release's version
of everything already delivered by cheaper-inference#5767.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@diegosouzapw diegosouzapw mentioned this pull request Jul 2, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants