Skip to content

fix(driver): treat subtype:success + is_error:true as phase failure (#973) - #976

Merged
admarble merged 1 commit into
mainfrom
feature/973-fix-driver-result-subtype-success-with-is-error-tr
Aug 29, 2026
Merged

fix(driver): treat subtype:success + is_error:true as phase failure (#973)#976
admarble merged 1 commit into
mainfrom
feature/973-fix-driver-result-subtype-success-with-is-error-tr

Conversation

@admarble

@admarble admarble commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The SDK emits subtype: "success" with is_error: true when a turn ends on an API error (e.g. unrecognized model name). Previously the driver returned success: true in this case, silently producing a zero-work "successful" phase.
  • Added a guard inside the subtype === "success" branch that checks is_error and returns success: false with an ApiError carrying terminal_reason and api_error_status in its metadata.
  • Added two unit tests covering AC-1 (failure path) and AC-3 (structured error metadata).

AC Verification

AC Description Status Evidence
AC-1 subtype:success + is_error:truesuccess:false with result text as error claude-code.ts:232–258; new test "treats subtype:success + is_error:true as a phase failure"
AC-2 Genuine success path unaffected Existing "leaves structuredError undefined on success" test still green (26/26 pass)
AC-3 structuredError.metadata carries terminal_reason and api_error_status claude-code.ts:237–243; new test "carries terminal_reason and api_error_status in structuredError metadata"

Test plan

  • npx vitest run src/lib/workflow/drivers/claude-code.test.ts — 26/26 pass
  • npm run build — no TypeScript errors
  • npm run lint — 0 errors, 0 warnings

Closes #973

🤖 Generated with Claude Code

Orchestrator verification (2026-08-29)

Independently re-executed in the worktree: npx vitest run src/lib/workflow/drivers/claude-code.test.ts (26/26 pass), npm run build, npm run lint — all clean.

Mutation-verified: AC-1 — disabled the is_error guard in claude-code.ts (if (resultMessage.is_error)if (false)); test "treats subtype:success + is_error:true as a phase failure (AC-1)" failed; restored.
Mutation-verified: AC-3 — same mutation; test "carries terminal_reason and api_error_status in structuredError metadata (AC-3)" failed; restored.

…973)

The SDK emits subtype "success" with is_error:true when a turn ends on an
API error (e.g. unrecognized model). The driver was returning success:true
in this case, producing a zero-work "successful" phase. Guard the success
branch on is_error and return an ApiError with terminal_reason and
api_error_status in metadata when the flag is set.

Entire-Checkpoint: 6d0539f77208
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.

fix(driver): result subtype "success" with is_error:true is reported as phase success — unrecognized model yields a zero-work "successful" phase

1 participant