Skip to content

feat(batch): name api_key_cap_reached and expose failure_detail on runs stopped by an API key credit cap - #32

Merged
AnderRV merged 2 commits into
mainfrom
feat/batch-api-key-cap-reached
Oct 2, 2026
Merged

AnderRV merged 2 commits into
mainfrom
feat/batch-api-key-cap-reached

Conversation

@AnderRV

@AnderRV AnderRV commented Oct 1, 2026

Copy link
Copy Markdown
Member

Why

A Batch run that stops because its API key reached a credit cap reports failure_reason: "api_key_cap_reached" and a failure_detail saying which cap and when it resets. Since #31 unknown values type-check, but callers can't name this reason or read the detail.

What

  • Exported RunFailureReason including api_key_cap_reached.
  • Run.failure_detail?: string | null (at most 500 characters).
  • TaskStatus gains processing, matching the API.
  • README: handling failed runs and the 402 api_key_cap_reached problem code.

Verification

  • pnpm check: clean. pnpm test -- --run: 252 passed, no type errors. pnpm build: OK.
  • New tests: a capped run parses; a 402 on rerun exposes its code and detail.

No version bump (the release sets it).

🤖 Generated with Claude Code

AnderRV and others added 2 commits October 1, 2026 12:16
…old apart from an empty account, so the SDK now types api_key_cap_reached and failure_detail

Run.failure_reason gains api_key_cap_reached (exported as RunFailureReason),
Run gains failure_detail, TaskStatus gains processing to match conveyor's
spec, and the README documents the 402 api_key_cap_reached problem code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…terminal, so waitForRun polled until its timeout

Add `failed` to TERMINAL_RUN_STATUSES so waitForRun / run.wait() /
job.run.wait() resolve with the failed run and its failure_reason /
failure_detail. A status in failureStatuses now takes precedence over the
targets, so failureStatuses: new Set(["failed"]) still throws
WaiterFailureError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lr2QdqhUNrX6q4DRLGeTMY
@AnderRV AnderRV self-assigned this Oct 2, 2026
@AnderRV
AnderRV marked this pull request as ready for review October 2, 2026 06:59
@AnderRV
AnderRV merged commit 27ad371 into main Oct 2, 2026
1 check passed
@AnderRV
AnderRV deleted the feat/batch-api-key-cap-reached branch October 2, 2026 07:00
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.

1 participant