anthropics / anthropics/claude-code-action

claude-code-action: SDK session returns is_error:true with zero turns/tool calls (subtype:success, 0 cost) — reproduces across v1.0.160 to v1.0.201, with and without --json-schema

Aperta
#1,720 5 commenti 1 reazione 0 assegnatari Vedi su GitHub
bug dev-experience p2 provider:1p
Lingua principale
TypeScript
Stelle
8.9k
Fork
2.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

## Summary

`claude-code-action` consistently fails since ~2026-08-23 20:47 UTC (still failing as of 2026-08-24): the Claude Agent SDK session returns a result event with `is_error: true`, `num_turns: 1`, `duration_ms` in the 200-280ms range, and `total_cost_usd: 0` — with **no assistant message, no tool call, and no actual work performed** — despite `subtype: "success"` on the same result object. Reproduced across 3 action versions and 2 models, so this doesn't look like a version-specific regression on our side.

## Environment

- Action versions tested: `v1.0.160` (2026-06-29), `v1.0.199` (2026-08-21), `v1.0.201` (2026-08-23) — all reproduce identically.
- Models tested: `claude-sonnet-4-6` (production workflow) and `claude-haiku-4-5` (isolated repro below) — both affected.
- Auth: `anthropic_api_key` input (direct API key, not OAuth/Bedrock/Vertex).
- Trigger: both `pull_request` and manual `workflow_dispatch` reproduce it.

## Minimal repro

```yaml
- uses: anthropics/claude-code-action@v1.0.160
id: probe
continue-on-error: true
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: |
--max-turns 3
--model claude-haiku-4-5
--allowedTools "Read"
prompt: |
Read README.md, then respond with "OK".
```

Result event captured from the run log:
```json
{"type": "system", "subtype": "init", "message": "Claude Code initialized", "model": "claude-haiku-4-5"}
{"type": "result", "subtype": "success", "is_error": true, "duration_ms": 220, "num_turns": 1, "total_cost_usd": 0, "permission_denials_count": 0}
```
No event in between — no assistant turn, no `Read` tool call, nothing. The SDK goes straight from `init` to an `is_error: true` result in ~220ms.

## With `--json-schema` (our production config on `gardien.yml`)

Adding `--json-schema '{"type":"object","properties":{"verdict":{"type":"string","enum":["A","B","C"]}},"required":["verdict"]}'` to the same config turns this into a hard action failure:
```
##[error]--json-schema was provided but Claude did not return structured_output. Result subtype: success
##[error]Action failed with error: --json-schema was provided but Claude did not return structured_output. Result subtype: success
```
Also worth noting: the action logs `Set session_id: ` internally right before this error, but `steps..outputs.session_id` is empty afterward — the session_id output isn't populated on this failure path, even though a session_id clearly exists internally.

## Impact on our side

We use `claude-code-action` for 4 automated review/monitoring workflows (PR review bot, an issue-triage bot, a staging/main drift auditor, and an hourly production monitor). All 4 depend on `--json-schema` + `steps.*.outputs.structured_output` to turn a review verdict into a pass/fail CI check (rather than parsing free-text comments, which we'd previously found fragile). Since this started, our PR-review bot fails on every single PR with zero real review performed, and we've had to bypass required-status-check protection to keep merging. We initially suspected a version regression (the floating `@v1` tag had just moved to a new release with an Agent SDK bump) and pinned to progressively older versions, but the failure reproduces identically all the way back to `v1.0.160` (2026-06-29) and with `--json-schema` removed entirely — so it doesn't look like something we can route around with a version pin.

## Question

Is this a known incident (API-side or Agent SDK-side) rather than an action bug? Happy to provide full run logs / workflow files if useful.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.