Skip to content

fix(claude): surface redacted thinking and reasoning tokens - #58

Merged
zawakin merged 1 commit into
mainfrom
fix/claude-redacted-thinking
Jun 1, 2026
Merged

fix(claude): surface redacted thinking and reasoning tokens#58
zawakin merged 1 commit into
mainfrom
fix/claude-redacted-thinking

Conversation

@zawakin

@zawakin zawakin commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

First code fix from the v2.1 log-format audit (#57). Addresses the original symptom — thinking became invisible — plus reasoning-token accounting.

Adaptive thinking (Opus 4.7+) no longer persists plaintext thinking: blocks arrive as {"type":"thinking","thinking":"","signature":"…"}. The text is unrecoverable, so:

  • Redacted-thinking marker: empty thinking with a signature now emits a Reasoning event with [thinking redacted] instead of a blank line. Blocks with neither text nor signature are dropped.
  • Reasoning tokens: parse usage.output_tokens_details.thinking_tokens into the reasoning bucket (previously hardcoded to 0). Since output_tokens already includes thinking, generated = output_tokens - reasoning, keeping total() unchanged. Pre-v2.1 logs lack the field, so they behave exactly as before.

Changes

  • claude/schema.rs: add OutputTokensDetail { thinking_tokens } to TokenUsage.
  • claude/parser.rs: redacted-thinking marker; reasoning-token split; 3 new unit tests.
  • Snapshots updated (additive output_tokens_details: null in raw output; no event-level change).

Notes

  • Plaintext thinking cannot be restored — it is not in the logs. This makes the reasoning step visible, not its content.
  • New record types and system subtypes are handled in a follow-up PR.

🤖 Generated with Claude Code

@zawakin zawakin self-assigned this May 31, 2026
@zawakin
zawakin merged commit 199d679 into main Jun 1, 2026
8 checks passed
@zawakin
zawakin deleted the fix/claude-redacted-thinking branch June 1, 2026 15:40
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.

1 participant