Skip to content

feat: forward thinking.display to --thinking-display CLI flag#830

Open
maxim092001 wants to merge 1 commit intoanthropics:mainfrom
maxim092001:feat/thinking-display
Open

feat: forward thinking.display to --thinking-display CLI flag#830
maxim092001 wants to merge 1 commit intoanthropics:mainfrom
maxim092001:feat/thinking-display

Conversation

@maxim092001
Copy link
Copy Markdown

@maxim092001 maxim092001 commented Apr 16, 2026

Summary

Expose thinking.display through ClaudeAgentOptions.thinking so callers can override Opus 4.7's default \"omitted\" behavior and receive summarized thinking text.

Motivation

Opus 4.7 silently changed the default of thinking.display from \"summarized\" (Opus 4.6) to \"omitted\". The bundled Claude Code CLI (2.1.111) accepts --thinking-display <summarized|omitted> to override this, but the Python SDK had no way to pass it:

  • ThinkingConfigAdaptive / ThinkingConfigEnabled TypedDicts omit display
  • SubprocessCLITransport._build_command only reads t[\"type\"], so any extra keys in the thinking dict are silently dropped

As a result, any Opus 4.7 chat through claude-agent-sdk returns ThinkingBlock(thinking=\"\", signature=\"...\") with zero thinking_delta stream events. {\"type\": \"adaptive\", \"display\": \"summarized\"} looks like it should work but doesn't.

Reproduction (Opus 4.7, before this change):

content_block_start { type: \"thinking\", thinking: \"\", signature: \"\" }
signature_delta ...
# no thinking_delta events
# terminal ThinkingBlock.thinking == \"\"

After this change, passing thinking={\"type\": \"adaptive\", \"display\": \"summarized\"} yields thinking_delta events and non-empty ThinkingBlock.thinking.

Changes

  • Add ThinkingDisplay = Literal[\"summarized\", \"omitted\"] and optional display: NotRequired[ThinkingDisplay] on ThinkingConfigAdaptive and ThinkingConfigEnabled (src/claude_agent_sdk/types.py)
  • Forward display to the CLI via --thinking-display in _build_command (src/claude_agent_sdk/_internal/transport/subprocess_cli.py)
  • Three new tests covering adaptive+display, enabled+budget+display, and omission behavior (tests/test_transport.py)

Notes for reviewers

  • --thinking-display is a real flag on the bundled CLI 2.1.111 (claude --thinking-display bogus returns Allowed choices are summarized, omitted) but it's not listed in claude --help. If the flag is intended to stay internal, happy to gate this behind a doc note or withdraw. If it's intended to be public, an accompanying mention in the docs / CHANGELOG would be worth adding when this lands.
  • TypeScript SDK (@anthropic-ai/claude-agent-sdk) appears to have the same gap; happy to file a sibling PR if useful.
  • Left CHANGELOG.md untouched since test_changelog.py enforces ## X.Y.Z version headings; suggest folding an entry into the next release section.

Test plan

  • pytest tests/test_transport.py tests/test_types.py tests/test_changelog.py — 121 passed
  • New parametrized tests verify the flag is emitted for adaptive+display and enabled+budget+display
  • New test verifies --thinking-display is absent when display is unset (preserves server default)
  • Manual verification on Opus 4.7: thinking={\"type\": \"adaptive\", \"display\": \"summarized\"} produces thinking_delta events and non-empty ThinkingBlock.thinking (reviewer to confirm against their environment)

Opus 4.7+ defaults thinking.display to "omitted", which returns empty
thinking text and signature-only deltas. The bundled CLI accepts
--thinking-display <summarized|omitted> to override, but the Python SDK
neither exposed display on ThinkingConfig nor forwarded it in
_build_command, so {"type":"adaptive","display":"summarized"} was
silently dropped.

- Add optional display: ThinkingDisplay to ThinkingConfigAdaptive and
  ThinkingConfigEnabled
- Forward display to the CLI via --thinking-display in _build_command
- Tests for adaptive+display, enabled+budget+display, and
  omission of --thinking-display when display is unset
@maxim092001
Copy link
Copy Markdown
Author

Opened #831 with a standalone writeup of the problem and repro.

@maxim092001
Copy link
Copy Markdown
Author

@qing-ant could you please take a look on this one? Thanks!

Copy link
Copy Markdown
Contributor

@qing-ant qing-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved, and seems like parity with existing TS as of last week

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a0fbd14). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #830   +/-   ##
=======================================
  Coverage        ?   84.31%           
=======================================
  Files           ?       14           
  Lines           ?     2633           
  Branches        ?        0           
=======================================
  Hits            ?     2220           
  Misses          ?      413           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants