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
- 主要語言
- Python
- 星號
- 8.1k
- 分支
- 1.3k
- PR 合併指標
- PR 指標待擷取
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。