anthropics / anthropics/claude-agent-sdk-python

Bug: Missing `content[type="thinking"]` in Python Agent SDK agent-conversation JSONL (0.1.35+)

Đang mở
#777 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
8.1k
Fork
1.3k
Merge trung bình
2 ngày 31 phút
Pull request đã merge (30 ngày)
1

Mô tả

# Summary
In `agent-conversations/**/*.jsonl` produced by the **Claude Agent SDK for Python** (`claude-agent-sdk` **v0.1.35+**), I often do **not** see assistant `content` blocks with `type: "thinking"` even when thinking is configured as enabled/adaptive with high effort or high `budget_tokens`.

Instead, intermediate reasoning appears in `content[type="text"]`, and in some runs the missing thinking correlates with incorrect multi-step derived values.

# Environment
- SDK: `claude-agent-sdk` **v0.1.35+** (Python), including **v0.1.52** (latest at time of reporting)
- Models tested:
- `claude-sonnet-4-5-20250929`
- `claude-sonnet-4-6`
- Thinking configs attempted:
- `thinking: { "type": "enabled", "budget_tokens": }`
- `thinking: { "type": "adaptive", "effort": "high" }`

# Expected
When thinking is enabled (or adaptive decides to think), `agent-conversations/**/*.jsonl` should consistently include assistant blocks like:
- `content: [{ "type": "thinking", "thinking": "...", "signature": "..." }, ...]`

# Actual
`type: "thinking"` is missing in some agent conversation logs (especially subagent logs), while `type: "text"` increases or contains reasoning-like narration.

## Version comparison
In my tests, behavior changes across `claude-agent-sdk` versions:

- With a **newer** `claude-agent-sdk` (>= `0.1.35`), the produced **agent conversation JSONL** often omits assistant `content` blocks where `type == "thinking"`.
- With an **older** `claude-agent-sdk`, assistant `content` blocks with `type == "thinking"` are present.
- Reproduced on **v0.1.52** as well.

## “Text replacing thinking” observation
When `type: "thinking"` blocks are missing, the number of assistant `content` blocks with `type: "text"` increases. These `text` blocks frequently contain visible, reasoning-like narration that appears to take the role that `thinking` blocks would normally serve, but this does not reliably translate into better agent performance (and in some runs correlates with less consistent/incorrect intermediate results).

## Possible behavioral impact
In multiple cases, runs where `thinking` blocks were missing produced less consistent intermediate results compared to runs where `thinking` blocks were present.

## Speed vs quality tradeoff observed
I also observed that runs without `thinking` blocks often complete faster, but that speedup appears to come with weaker agent performance/quality in intermediate reasoning outcomes.

# Questions
1. Is it intentional that the **Python SDK “agent conversation JSONL”** omits `type: "thinking"` blocks from some runs/subagents even when thinking is enabled?
2. If intentional, can we get documentation and/or an option to include thinking blocks in transcripts for debugging (e.g. `include_thinking_in_transcripts=true`)?
3. If unintentional, can you point me to the code path that strips/omits `thinking` during transcript serialization/compaction?

# Minimal reproduction (high level)
1. Use `claude-agent-sdk` v0.1.35+ with `ClaudeAgentOptions(thinking=...)` and tools/subagents.
2. Run an agent that produces `agent-conversations/**/*.jsonl`.
3. Inspect assistant message content blocks in the JSONL and check for `content[].type == "thinking"`.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.