CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 21
claude-3.7-sonnet with thinking, refs #14 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Published some initial notes on this here, including the all-important pelicans riding bicycles: https://simonwillison.net/2025/Feb/24/claude-37-sonnet-and-claude-code/ |
Maybe I add It would be nice to have a |
From here's a challenging detail: https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
It's important NOT to store thinking tokens in the (I mean maybe we do in special cases, but I'll leave that for LLM users to decide.) |
... this means my current design isn't quite right. Having a I may need to ship a change to core to support this plugin after all. |
Here's an explanation of that
|
And I need to consider this edge-case (I wonder what it looks like in the streaming chunks API?):
It does at least provide this example: {
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "redacted_thinking",
"data": "EmwKAhgBEgy3va3pzix/LafPsn4aDFIT2Xlxh0L5L8rLVyIwxtE3rAFBa8cr3qpP..."
},
{
"type": "text",
"text": "Based on my analysis..."
}
]
} |
I ran this, after adding code to llm -m claude-3.7-sonnet -o show_thinking 1 'ANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB' And got this: https://gist.github.com/simonw/730a9217d981f0e5c85b4e42b1bf983e Truncated: {'message': {'content': [],
'id': 'msg_01SYnm2Viwe6oNwSENaH9b63',
'model': 'claude-3-7-sonnet-20250219',
'role': 'assistant',
'stop_reason': None,
'stop_sequence': None,
'type': 'message',
'usage': {'cache_creation_input_tokens': 0,
'cache_read_input_tokens': 0,
'input_tokens': 92,
'output_tokens': 2}},
'type': 'message_start'}
{'content_block': {'data': 'Eu0BCoYBGAIiQMuYgm7sHFe8J3ZAfOyGFpDsYykC7tAUCL89kxH0XKS49Q1D8KN7YE3VdgVE+pBGVQZvSb8P+MNVvKJo6xfp+a8qQLoL/lA1w6rZDUAe0HF1ahXUTb5tvbgBEt3n8lP9/b4Am1CxXzk+MJ7xyiKYYViNGMRyHtNuHpjQeb8jqruasBgSDGUZqtFFfSl9l+kp1hoM38iaGEBZSdTxha7ZIjDgv8QJwwBS/p3tMPTWrxZ/6dRVzyzJAVb9wRmgAi5DjKy/qBRQirEO09zkioKSlYkqFJQYmVkPRZdNrobr/BIb21CSruJ0',
'type': 'redacted_thinking'},
'index': 0,
'type': 'content_block_start'}
{'content_block': {'data': 'Eu0BCoYBGAIiQMuYgm7sHFe8J3ZAfOyGFpDsYykC7tAUCL89kxH0XKS49Q1D8KN7YE3VdgVE+pBGVQZvSb8P+MNVvKJo6xfp+a8qQLoL/lA1w6rZDUAe0HF1ahXUTb5tvbgBEt3n8lP9/b4Am1CxXzk+MJ7xyiKYYViNGMRyHtNuHpjQeb8jqruasBgSDGUZqtFFfSl9l+kp1hoM38iaGEBZSdTxha7ZIjDgv8QJwwBS/p3tMPTWrxZ/6dRVzyzJAVb9wRmgAi5DjKy/qBRQirEO09zkioKSlYkqFJQYmVkPRZdNrobr/BIb21CSruJ0',
'type': 'redacted_thinking'},
'index': 0,
'type': 'content_block_stop'}
{'content_block': {'data': 'EuUCCoYBGAIiQOkS6N2nZQOxRsm74E7XiLOWrCTXwyLEZKAo3i36YlMVfY0GNQPbUW8oMxQA6b3EEdJA68HBhsX7kcjbXiO8DHAqQFDeq8/O09hyaB2CX/5YyryfFVl0dYnMsmk3scqmqg9tH89i0wIki53eLoanDhAk7HN+tdbdp3V1Ts4eu42jus4SDOyd51dPT15lbnLIkBoMxsO7tto6x3oVXbzMIjBLA/RMRAV0HGD/YdLbktB6FmzJFTf2iJzOs4z8HBGX/l/VTGJlxA/y9Fve8SFtKnIqiwFTF+5HtHBvGOE77P3gR3Hu9JfPqmN/9S2BdbCWf8mu1sfSCd0oKtSR2mkMADBZp+3cYvcnjE77rtHfkhj8qd0KAG76OwXxv6Fmo9V8Od8Cwb+/ETc5P6kSFyaOaEvnlTqYr+jI0+5M16igvfkaLFxdGurbONMc5eh6Q40xCsAPltULFBwDsziwfrv0',
'type': 'redacted_thinking'},
'index': 1,
'type': 'content_block_start'}
{'content_block': {'data': 'EuUCCoYBGAIiQOkS6N2nZQOxRsm74E7XiLOWrCTXwyLEZKAo3i36YlMVfY0GNQPbUW8oMxQA6b3EEdJA68HBhsX7kcjbXiO8DHAqQFDeq8/O09hyaB2CX/5YyryfFVl0dYnMsmk3scqmqg9tH89i0wIki53eLoanDhAk7HN+tdbdp3V1Ts4eu42jus4SDOyd51dPT15lbnLIkBoMxsO7tto6x3oVXbzMIjBLA/RMRAV0HGD/YdLbktB6FmzJFTf2iJzOs4z8HBGX/l/VTGJlxA/y9Fve8SFtKnIqiwFTF+5HtHBvGOE77P3gR3Hu9JfPqmN/9S2BdbCWf8mu1sfSCd0oKtSR2mkMADBZp+3cYvcnjE77rtHfkhj8qd0KAG76OwXxv6Fmo9V8Od8Cwb+/ETc5P6kSFyaOaEvnlTqYr+jI0+5M16igvfkaLFxdGurbONMc5eh6Q40xCsAPltULFBwDsziwfrv0',
'type': 'redacted_thinking'},
'index': 1,
'type': 'content_block_stop'}
... |
More important tips - looks like preserving those thinking blocks really is critical:
|
These redacted blocks are not human readable, so it doesn't make sense to output them in the LLM CLI even if the user has requested seeing them. Anthropic suggest you could tell people "Some of Claude’s internal reasoning has been automatically encrypted for safety reasons" but I'd rather not do that in the default CLI output. Users can see that in |
More edge-cases:
I could enforce these in LLM options checking code but I think I'll let the Claude API complain about them with an error instead, that way if those limitations change in the future I won't have to update the plugin. |
Abandoning this in favor of the much simpler: I'll come back to visible thinking tokens later on, probably after I make some changes to LLM core. |
Refs:
Needed:
thinking
,thinking_budget
,show_thinking
andthinking_delimiter
show_thinking
andthinking_delimiter
for the moment - see Support Claude 3.7 Sonnet, including its new thinking mode #14 (comment)output-128k-2025-02-19
in your API request to increase the maximum output token length to 128k tokens for Claude 3.7 Sonnet" from https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-comparison-table