Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preserve Claude final-result API error text #19136

MergedMarve10s(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/19136/headmerged by juliusmarminge View on GitHub

A Claude turn can finish with terminal_reason: api_error while placing the useful failure detail in result. T3 previously replaced that detail with a generic repeated-API-error message.

Use trimmed final-result text beginning with API Error: as a fallback, sanitizing the complete message before limiting it to 500 characters. Authentication and usage-window hints, listed errors, HTTP 429/529 messages, and other terminal reasons retain their precedence. The existing Claude adapter applies this for all clients without changing contracts or other providers.

Verification on headless Linux / Node 24:

  • Adapter suite: 293 tests passed. Reduced the contribution's 11 added cases to 7, retaining the existing auth/usage regression fixture changes (14 → 10 PR-related executions).
  • Before/after: removing the fallback makes both selected regression cases fail; truncating before sanitizing makes the secret-boundary case fail. Both pass with this implementation.
  • Server-only typecheck and targeted formatting/lint passed; lint retains one upstream unused-variable warning.
  • One independent full-diff review round by Claude Opus 5.5 and Codex GPT-6-Sol found no blocking code issues. The historical redaction-before-truncation finding was rechecked against the source and mutation proof.

Proof uses the running adapter's fake SDK harness and terminal receipts. No live Claude API failure, integrated browser flow, macOS, Windows, iOS, Android, or Electron desktop verification was performed. Screenshots do not demonstrate this result-mapping behavior. CI and maintainer approval remain separate gates.

Thanks to @Marve10s for the focused implementation and initial regression work in #19136. This addresses only final-result error selection from #13399; assistant-only errors and other 429 cases remain outside scope.

Tests: GPT-6-Astra (high); implementation: GPT-6.1-Sol (high); reviews: Claude Opus 5.5 and GPT-6-Sol. Harness: Codex and Claude in T3 Code.

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

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

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-10-13T19:31:00.173897Z2143f6ePR opened
      ℹ️ 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.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 11 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 73e04a62-344f-4292-b17c-5523925ffe7e
      📥 Commits

      Reviewing files that changed from the base of the PR and between ca63df8447d3dda4948e7e1dfd254a0b715e0b6f and cc5c96b8a8c68c620e1ffbc04af469ec8fb6ea88.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 9daef661-3992-4fad-af5d-768f0e6509b4
      📥 Commits

      Reviewing files that changed from the base of the PR and between 2143f6e3bfd9883571dcd886477d8a146eb087fb and ca63df8447d3dda4948e7e1dfd254a0b715e0b6f.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

      📝 Walkthrough

      The Claude adapter now uses qualifying API-error result text as a fallback failure message. Tests cover message normalization, fallback cases, failure codes, and classification.

      Changes: Claude API-error terminal reporting

      Layer / File(s)Summary
      Extract and validate API-error messages
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      For api_error terminal results, the adapter uses trimmed result text beginning with API Error: as a fallback hint, capped at 500 characters. Tests cover trimming, truncation, redaction, fallback messages, diagnostic filtering, HTTP 529/429 messages, prompt_too_long, and failure classification.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to ca63d

      Claude API-error results can retain useful diagnostic text without an identified secret-exposure or message-selection defect. The change is ready to merge after normal checks.

      ### Architecture Summary

      Architecture risk: 🔵 Low · up to ca63d

      The change affects 1 system.

      Changed systems: apps/server

      Architecture concerns No architecture-level concerns identified.

      Review details

      Systems and components

      • observed — apps/server (service) was modified; 2 changed files map to changed impact.

      Before / after behavior

      • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts: Added parameterized expectations for failed terminal API results: preserve and trim API error text, truncate long text to 500 characters, redact quoted secrets before the limit, select the last non-diagnostic listed error, and use fallback messages for empty or ordinary text. The cases also expect fixed messages for HTTP 529 and 429, and for prompt_too_long; each expects failure code api_error_<status> and class usage_limit only for status 429.
      • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts: Changed the expired-login test input from the generic "API Error" to a detailed HTTP 401 credentials-expired message.
      • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts: Changed the unrecovered usage-window test input from generic "API Error" to a detailed HTTP 400 provider-error message; the recovered case remains generic.
      • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: providerFailureFromResult derives a fallback message for api_error success results whose trimmed result starts with API Error:, normalizes it through makeProviderFailure, and truncates it to 500 characters. terminalResultError now receives failureHint ?? apiErrorMessage, so an explicit failure hint still takes precedence; other result cases retain the existing structured error handling.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly and concisely describes the main change: preserving Claude final-result API error text.
      Description checkPassedThe description clearly explains the problem, implementation, scope, linked issue, verification results, test environment, and limitations. It is mostly complete and relevant, although it does not inc…
      Full details: Description check

      Explanation

      The description clearly explains the problem, implementation, scope, linked issue, verification results, test environment, and limitations. It is mostly complete and relevant, although it does not include an explicit maintainer approval comment.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 2143f6e3bf

      ℹ️ 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".

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one as maintainer for batch claude-05. I will preserve the focused API-error behavior, reduce regression coverage to the necessary cases, and verify the rebuilt change before pushing here.

    7. juliusmarminge merged this55a8fe9

    8. juliusmarminge closed this

Sign in to join this conversation.