Skip to content

fix(agents): stop retrying rejected empty replies - #170925

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-empty-error-retry-20260919
Oct 13, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-empty-error-retry-20260919

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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. A sessions_send replacement 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.failed error 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.
  • The existing transcript replay file's 45 sibling cases passed during the initial run; its new fixture was corrected to await the projection barrier and assert the owning current-turn guard. 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).
  • Changed-file oxfmt, core type-aware oxlint, extension syntax lint and git diff --check passed. Extension type-aware checks and full gates are delegated to PR CI.
  • independent subagent review (autoreview route unavailable): one diagnostic body-shape finding fixed; follow-up review clean. Autoreview refused because its requested provider route did not match the operator configuration; configuration was not changed.
  • No Testbox/Crabbox lease was allocated under the lane's light-local-validation rule. No remote benchmark was needed for request-attempt counts. The first CI run reported two behavior-test expectations and a missing required cfg field in the new fallback test. Fixed those expectations for terminal format failures and separate diagnostic warnings, preserved ChatGPT payload.error fields, and supplied cfg: 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T10:23:38.263656Z e8f27b5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: openai size: M labels Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +515 to +517
message:
record?.message ?? detail?.message ?? (typeof error === "string" ? error : undefined),
body: record?.errorBody ?? record?.body ?? response?.body ?? response?.data ?? detail,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +342 to +345
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +120 to +121
message: transcriptError,
body: failedAssistant.errorBody,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@steipete
steipete merged commit 997f42b into main Oct 13, 2026
144 of 145 checks passed
@steipete
steipete deleted the steipete/perf-micro-empty-error-retry-20260919 branch October 13, 2026 10:37
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
* 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
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: openai size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant