anthropics / anthropics/claude-agent-sdk-python

query() returns is_error with subtype="success" and api_error_status=400; --print succeeds with identical binary and credentials

Abierto
#1,156 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
8.1k
Forks
1.3k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Since 2026-08-01 ~09:42 UTC, every `query()` call fails within 1–2 seconds with a self-contradictory result. The same CLI binary, in the same container, with the same OAuth credential, succeeds via `--print --output-format json`.

**Result object returned:**

```
is_error: true
errors: []
subtype: "success"
api_error_status: 400
```

`is_error=true` with an empty `errors` array and `subtype="success"` appears to be a bug in its own right — the SDK cannot describe its own failure. In `query.py`, `"; ".join(errors) or str(subtype)` falls through to the subtype when `errors` is empty, surfacing the string `Claude Code returned an error result: success`.

**What is eliminated (each tested individually):**

- `tools`, `setting_sources`, `cwd`, `system_prompt` — varied one at a time, byte-identical failure each time
- Model — fails on both `claude-fable-5` and `claude-opus-5`
- CLI version — fails on the SDK-bundled CLI 2.1.187, and reproduces identically with `ClaudeAgentOptions.cli_path='/usr/bin/claude'` forcing CLI 2.1.211. Invoking either binary directly with `--print --output-format json` succeeds. The failure is specific to the SDK's streaming/control transport, not to a CLI version.
- Environment — reproduces in a throwaway container and in a long-lived one
- Credential — `ANTHROPIC_API_KEY` absent; OAuth token only (Max subscription), confirmed valid; `--print` succeeds on the same credential
- Client-side change — our code is byte-identical by hash across the onset

**Timeline:** 44 consecutive successful `query()` calls through 2026-07-31. Last success 2026-08-01 09:41:08 UTC, elapsed 37.16s. First failure 09:42:41 UTC, elapsed ~2s. Every attempt since has failed in 1–2s, across ~14 hours. Onset window is 93 seconds; nothing changed on our side.

The consistent ~2s failure against a ~37s success suggests the request isn't reaching the model.

**Environment:**

- claude-agent-sdk 0.2.108
- Python 3.12.13 (python:3.12-slim, linux/arm64)
- CLI 2.1.187 (SDK-bundled, invoked by default) and 2.1.211 (npm, via `cli_path`) — both fail
- Docker container, OAuth via Max subscription, no API key

**Repro:** any `query()` call reproduces it; the same options via `--print --output-format json` succeed on the same binary.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.