Repository navigation
fix(agents): stop retrying rejected empty replies - #170925
Conversation
Surface retired transcript custody and deterministic request rejection without unchanged retries or model fallback. Preserve transient recovery and context compaction, and log raw provider error fields before transcript projection so empty failures retain their cause.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da78c21f95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| message: | ||
| record?.message ?? detail?.message ?? (typeof error === "string" ? error : undefined), | ||
| body: record?.errorBody ?? record?.body ?? response?.body ?? response?.data ?? detail, |
There was a problem hiding this comment.
Keep provider-controlled prompt echoes out of logs
When an OpenAI HTTP/SSE or WebSocket rejection includes provider-controlled text, these fields write it verbatim to the local log; the existing fixtures in packages/ai/src/providers/openai-chatgpt-responses-streaming.test.ts intentionally return a prompt echo and a hostile response.failed type and assert that neither is logged. This also adds a second warning where that transport expects one metadata-only warning. Preserve safe codes/IDs without logging the raw provider message/body, or let that transport opt out of the shared diagnostic.
AGENTS.md reference: AGENTS.md:L59-L61
Useful? React with 👍 / 👎.
Retain nested error fields from ChatGPT HTTP and stream errors. Update the real transport and prompt-cache fixtures to expect raw diagnostics and terminal request rejection, and provide the required fallback configuration field.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7236916233
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (decision.action === "surface_error" && error.reason === "format") { | ||
| // A different model cannot repair a rejected request. Context overflow | ||
| // remains owned by the earlier compaction recovery path. | ||
| recordModelFallbackStop(error); |
There was a problem hiding this comment.
Preserve fallback for model-specific format failures
Do not mark every surfaced format failure as a terminal chain stop. This category includes model-specific rejections such as OpenRouter's “No endpoints found that support image input” and unsupported-parameter errors; a configured image-capable or otherwise compatible fallback can handle the same turn. Recording the stop here makes runFallbackAttempt throw before trying that fallback, regressing the existing format-fallback behavior. Reserve the terminal marker for proven transcript-admission failures or another classification that establishes the rejection is invariant across candidates.
Useful? React with 👍 / 👎.
| message: transcriptError, | ||
| body: failedAssistant.errorBody, |
There was a problem hiding this comment.
Omit provider-controlled content from assistant failure logs
When a provider rejection echoes prompt or tool content, errorMessage and errorBody carry that text into this new warning; this is an independent sink from the shared transport warning and affects every provider. Log only safe metadata such as provider/model/status/code/IDs so sensitive conversation content is not copied into local logs.
AGENTS.md reference: AGENTS.md:L61-L61
Useful? React with 👍 / 👎.
* fix(agents): stop retrying rejected empty responses Surface retired transcript custody and deterministic request rejection without unchanged retries or model fallback. Preserve transient recovery and context compaction, and log raw provider error fields before transcript projection so empty failures retain their cause. * fix(ai): preserve ChatGPT error payload diagnostics Retain nested error fields from ChatGPT HTTP and stream errors. Update the real transport and prompt-cache fixtures to expect raw diagnostics and terminal request rejection, and provide the required fallback configuration field. * fix(openai): stop retrying code-less content filters
* fix(agents): classify local runtime faults before fallback * fix(agents): stop fallback after prompt projection loss Release adaptation: stable lacks #170925, so transcript-turn-error only gains the prompt-projection message alongside its existing keyed-user regex (no pending-input messages). The assistant-failure regression is a new single case using the stable makeInput helper instead of the main it.each table, and the terminal-boundary case uses the stable two-element tuple shape. SessionTranscriptReadFenceError covers the stable prepared-replay timing of the admission race already handled by #179347. (cherry picked from commit bef193c)
What Problem This Solves
Fixes repeated empty replies when a queued turn loses transcript admission or a provider rejects the request permanently. Retry warnings also omitted the actual cause.
User Impact
Permanent rejections surface immediately with their real reason, while transient failures retain recovery. Local file logs now preserve complete provider error fields; these fields can be sensitive. Transcript and export redaction remain unchanged.
Evidence
An empty assistant error could exhaust unchanged-request retries and then repeat the same rejection across model fallbacks, while the retry warning omitted the cause. Read-only incident forensics found 12 local attempts, each rejected with
Pending input is no longer active in its admitted transcript, zero provider usage and no provider response ID. Asessions_sendreplacement had retired the original user branch and carried its unanswered input into the replacement turn. The queued original correctly lost custody; changing models could never restore it. Of the reported 234,186 ms, 212,755 ms was queue wait, so this was not nine slow provider requests.Why This Change Was Made
Treat the existing pending-input admission assertions as terminal at the shared transcript-error boundary, preserving the storage guard. Mark surfaced request-format failures terminal for outer model fallback as well. Keep transient retries and the existing context-overflow compaction owner. Extend OpenAI-native classification for context limits, invalid requests and content policy, including the exact content-filter finish/incomplete messages emitted without a code.
Log raw transport error status/code/type/message/body/request ID/response ID before transcript redaction and clipping, excluding request payloads and generated response content. Also log saved assistant error fields before recovery, so local admission failures have a visible cause. Preserve structured
response.failederror fields in transcript projection. Document the behavior.Before/after measurement
The incident's rejected queued turn changes from 12 local attempts to one terminal rejection, with no provider call. Focused old-code regressions reached all three configured models for each permanent rejection; the fixed tests stop after the first model. The synthetic transcript replay reproduces the retired-branch shape and proves the current-turn admission guard refuses it before transport. No live provider replay or production mutation was performed; no wall-clock speedup is claimed.
Production delta: +70/-6 lines (net +64). Growth is required by the explicitly requested diagnostic contract and permanent-error classification; no cache, alternate storage owner, configuration option or compatibility shim is added.
Validation
pnpm test packages/ai/src/utils/provider-error.test.ts packages/ai/src/transports/transport-stream-shared.test.ts src/agents/embedded-agent-runner/run/assistant-failure.failover.test.ts extensions/openai/openai-provider.test.ts --maxWorkers=1: 114 tests passed, 170.93 s wall time. Covers raw/unclipped response.error and response.data diagnostics, generated-content exclusion, permanent stops, native codes and existing transient recovery.pnpm test src/agents/embedded-agent-runner/run/attempt-session-replay.test.ts --maxWorkers=1 -t "refuses queued custody": passed, 58.83 s wall time (32.18 s Vitest duration; regression execution about 9 s).oxfmt, core type-aware oxlint, extension syntax lint andgit diff --checkpassed. Extension type-aware checks and full gates are delegated to PR CI.cfgfield in the new fallback test. Fixed those expectations for terminal format failures and separate diagnostic warnings, preserved ChatGPTpayload.errorfields, and suppliedcfg: undefined.pnpm test packages/ai/src/providers/openai-chatgpt-responses-streaming.test.ts --maxWorkers=1: 9 passed, 4.23 s wall time.pnpm test src/agents/embedded-agent-runner.prompt-cache.test.ts --maxWorkers=1 -t "preserves responses prefixes": passed, 134.72 s wall time (87.03 s Vitest duration), proving subsequent prefix stability after the permanent rejection. Projection/transport regressions passed again: 57 tests, 4.97 s wall time. Repair diff independently reviewed clean; changed-file formatting and lint passed. A final content-policy audit found code-less content-filter finish/incomplete terminals. The plugin now classifies the two exact producer messages as format errors. Focused native-classification regression passed (1 test, 38 skipped; 70.95 s wall time, 55.66 s Vitest duration); independent review clean. Final exact-head CI run: all 55 CI jobs successful, 599 seconds from the first job start to the last completion; full lint/typechecks, changed test lanes, guards, build and UI E2E passed. Head:e8f27b55b1cb1454c98f496afd63fd0d9c9f0b96. Security review and independent review clean.