Skip to content

feat: Thinking-/Reasoning-Blöcke unterstützen und anzeigen - #48

Merged
webmatze merged 1 commit into
mainfrom
feat/thinking
Aug 7, 2026
Merged

feat: Thinking-/Reasoning-Blöcke unterstützen und anzeigen#48
webmatze merged 1 commit into
mainfrom
feat/thinking

Conversation

@webmatze

@webmatze webmatze commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Closes #26.

Was drin ist

Korrektheit. ContentBlock kennt jetzt Thinking und RedactedThinking. Die Signatur wird byte-genau geparst, gespeichert und zurückgeschickt — ohne das lehnt Anthropic den Folge-Request ab. Alte Sessions, die vor dem Feature gespeichert wurden, deserialisieren weiterhin (signature hat einen Declaration-Default).

Sichtbarkeit. Thinking streamt live ins Transcript (thinking_delta / thinking_block, inkl. --json).

Compaction. Beim Zusammenfassen alter Turns werden Thinking-Blöcke verworfen; in noch ungekürzten Turns bleiben sie unangetastet.

OpenAI. reasoning_effort war auf "none" hartcodiert und ist jetzt konfigurierbar.

Abweichung von der Issue-Spec

Das Issue nennt thinking: { type: "enabled", budget_tokens: N }. Diese Form ist auf Anthropic-Modellen ab 4.7 entfernt und liefert einen 400 — live gegen claude-sonnet-5 reproduziert:

"thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort"

Gesendet wird deshalb:

"thinking": {"type": "adaptive", "display": "summarized"},
"output_config": {"effort": "medium"}

display ist nicht kosmetisch: der Default ist "omitted", dann kommen Thinking-Blöcke mit leerem Text — gedacht und abgerechnet wird trotzdem, nur anzuzeigen gäbe es nichts.

Die Budget-Form bleibt für Modelle älter als 4.6 erhalten, per Default ungesetzt und nur über ein explizites thinking_budget erreichbar. Der max_tokens-Guard aus der Spec hängt an ihr.

Konfiguration

[defaults]
thinking = true

[providers.anthropic]
thinking_effort = "medium"   # low | medium | high | xhigh | max

[providers.openai]
reasoning_effort = "none"

Dazu --think / --no-think.

Verifikation

  • 500 Specs grün, Format sauber, Build ok — macOS und Linux (Docker)
  • Live gegen claude-sonnet-5: ohne --think unverändert; mit --think streamen thinking_delta-Events mit Inhalt und der akkumulierte thinking_block stimmt

🤖 Generated with Claude Code

Two separate problems, per #26.

Correctness first: with thinking on, an Anthropic response contains
thinking blocks, and the next request is rejected unless they come back
untouched — the signature is cryptographic. ContentBlock now knows
Thinking and RedactedThinking, both round-trip through the session file,
and both are parsed and re-serialised losslessly.

Visibility second: thinking now streams into the transcript as it
arrives, so a long research phase is no longer silent.

The request shape is the current one, not the one the issue describes.
budget_tokens was removed on Anthropic models from 4.7 on and returns a
400 — verified live against claude-sonnet-5. Depth is an effort level
instead:

    thinking: {type: "adaptive", display: "summarized"}
    output_config: {effort: "medium"}

display matters: it defaults to "omitted", which streams thinking blocks
whose text is empty — thinking still happens and is still billed, but
there would be nothing to show.

The token-budget form stays for models older than 4.6, unset by default
and only reachable by configuring thinking_budget explicitly. Its
max_tokens guard stays with it.

Compaction drops thinking blocks when summarising old turns; blocks in
turns that have not been compacted stay untouched, so the signature
requirement holds.

OpenAI's reasoning_effort was hardcoded to "none" and is now
configurable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@webmatze
webmatze merged commit 73ca0af into main Aug 7, 2026
2 checks passed
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.

Thinking-/Reasoning-Blöcke unterstützen und anzeigen

1 participant