Skip to content

fix: write execution file when SDK throws#1255

Open
Jerry2003826 wants to merge 1 commit intoanthropics:mainfrom
Jerry2003826:codex/fix-execution-file-on-sdk-error
Open

fix: write execution file when SDK throws#1255
Jerry2003826 wants to merge 1 commit intoanthropics:mainfrom
Jerry2003826:codex/fix-execution-file-on-sdk-error

Conversation

@Jerry2003826
Copy link
Copy Markdown

Fixes #1226

Summary

  • Persist the SDK message log before rethrowing SDK execution errors.
  • Reuse the same execution-file writer on success and error paths.
  • Add regression coverage for SDK errors after partial output.

Root Cause

runClaudeWithSdk only wrote EXECUTION_FILE after the SDK async iterator completed. When query() threw, for example with error_max_turns, the catch path rethrew before writing the partial message log.

Validation

  • bun test test/run-claude-sdk.test.ts
  • bun test
  • bun run typecheck
  • bunx prettier --check src/run-claude-sdk.ts test/run-claude-sdk.test.ts

Note: full bun run format:check on this Windows checkout reports pre-existing formatting/line-ending issues across unrelated files, so I verified the changed files with Prettier directly.

@Jerry2003826 Jerry2003826 marked this pull request as ready for review April 25, 2026 04:35
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.

execution_file output not written when SDK throws on error_max_turns

1 participant