anthropics / anthropics/claude-agent-sdk-python

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

未关闭
#777 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
8.1k
派生
1.3k
平均合并
2 天 31 分钟
30 天内合并 PR
1

描述

# 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"`.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。