fix(runtime): stream and fold non-streaming Codex OAuth calls #5723
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.76) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.76 · 531 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.376
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.076
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5723"
general
weight: 0.35
liugddx
Summary
On an
openai-codex(ChatGPT subscription) connection every tool-free auxiliary call failed: Session titles, goal evaluation, recap, Daily Review and prompt suggestions. Main turns kept working. As a result, Codex Sessions never get a generated title; they fall back to the truncated first message.The backend rejects the non-streaming request
generateTextsends, for three separate reasons:400 "Stream must be set to true"400 "Unsupported parameter: max_output_tokens"response.completedevent can carry an emptyoutputThe fix stays inside
buildOpenAiCodexFetch, the adapter that already reshapes Codex requests. For a caller that did not ask to stream, it:stream: trueand dropsmax_output_tokens;outputfromresponse.output_item.donewhen the terminal event omits it;A failed, incomplete or truncated stream surfaces as an error rather than an empty or partial success. Streaming callers (main turns) are forwarded exactly as built, including any configured
max_output_tokens; see #5736 for that separate failure.The stream is recognised by its body, not by
content-type. Against the live backend, the stream did not reach this layer with an event-stream content type, and a first version gated on the header never folded anything.Trade-off: Codex auxiliary calls no longer carry an output cap. They are bounded by their prompts and by each caller's own result validation.
Fixes #5711
Verification
subscription-model-fetch.test.ts: 22/22 pass. The five new cases fail without the change:- fold with an empty terminal
output, throughdoGenerate;- a streamed turn passed through unfolded, keeping its configured output cap;
- truncated stream;
-
response.failed;-
response.incompletewith partial output (content_filter).content-type, matching what the live backend delivered.session_titleusage row:| model |
main| this branch ||---|---|---|
| gpt-6-astra |
error,HTTP 400 {"detail":"Stream must be set to true"}; name = truncated first message |success(82 in / 14 out); "Planning a Small Refactor of a Large React Component" || gpt-5.6-sol | (same 400 in the workspace's usage history) |
success; "Planning a Large React Component Refactor" || gpt-5.5 | (same 400 in the workspace's usage history) |
success; "Refactoring a Large React Component" |That workspace's
usage_llm_callshad 18 Codex auxiliary rows (titles and goal evaluation), all failed, none succeeded.biome checkon the changed files passes, and so doestsc --noEmitfor@maka/runtime.@maka/runtimesuite ran on Windows. Its failures are all in unrelated files and are environmental:EBUSYon temp SQLite cleanup,EPERMon symlink creation, macOS seatbelt tests, and shell tests. I did not run the other workspaces' suites.scripts/biome-staged-check.mjsspawnsnode_modules/.bin/biome.cmdwithspawnSyncand no shell, which Node 22 rejects withEINVAL. I ran its steps manually and all passed:biome check,asf-license-headers check-staged,protocol-epoch-check --stagedandgit diff --cached --check. The hook problem itself is not part of this PR.AI use
Tool(s) and scope: Claude Code (Claude Opus) diagnosed the backend responses, implemented the fix and tests, and ran the verification above; liugddx reviewed. The commit carries a
Generated-bytrailer.Checklist
Does this PR entail a change in behavior?
🤖 Generated with Claude Code