Skip to content

Add logging for MaxTokens adjustment in Anthropic extended thinking#50

Merged
SantiagoDePolonia merged 3 commits intoclaude/fix-thinking-max-tokens-vdp8gfrom
copilot/sub-pr-48-again
Jan 26, 2026
Merged

Add logging for MaxTokens adjustment in Anthropic extended thinking#50
SantiagoDePolonia merged 3 commits intoclaude/fix-thinking-max-tokens-vdp8gfrom
copilot/sub-pr-48-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 26, 2026

Addresses review feedback to add visibility into MaxTokens modifications when Anthropic extended thinking is enabled.

Changes

  • Added logMaxTokensAdjustment() helper function to log when MaxTokens is increased to meet Anthropic's extended thinking constraint (budget_tokens ≤ max_tokens)
  • Applied logging in both convertToAnthropicRequest() and convertResponsesRequestToAnthropic() flows
  • Logs include original value, adjusted value, and constraint reason

Example output:

INFO MaxTokens adjusted to meet Anthropic extended thinking requirements original=4096 adjusted=10000 reason="extended thinking budget_tokens must be <= max_tokens"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 26, 2026 14:27
Add informative log statements when MaxTokens is adjusted to meet
Anthropic extended thinking requirements. Logs include original value,
adjusted value, and the reason for adjustment.

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>
Extract duplicate logging statements into a dedicated helper function
to improve code maintainability and ensure consistency across both
ChatCompletion and StreamChatCompletion flows.

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>
Copilot AI changed the title [WIP] Add logs for MaxTokens adjustment reasons Add logging for MaxTokens adjustment in Anthropic extended thinking Jan 26, 2026
@SantiagoDePolonia SantiagoDePolonia marked this pull request as ready for review January 26, 2026 15:32
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@SantiagoDePolonia SantiagoDePolonia merged commit e8558d0 into claude/fix-thinking-max-tokens-vdp8g Jan 26, 2026
1 check passed
SantiagoDePolonia added a commit that referenced this pull request Jan 26, 2026
* fix: ensure MaxTokens >= budget when extended thinking is enabled

When extended thinking is enabled via the reasoning parameter, Anthropic
requires max_tokens to be at least the thinking budget_tokens. This fix
ensures MaxTokens is bumped to the budget value when it's lower, in both
ChatRequest and ResponsesRequest conversion paths.

* Add logging for MaxTokens adjustment in Anthropic extended thinking (#50)

* Initial plan

* feat: add logging for MaxTokens adjustment in Anthropic provider

Add informative log statements when MaxTokens is adjusted to meet
Anthropic extended thinking requirements. Logs include original value,
adjusted value, and the reason for adjustment.

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

* refactor: extract MaxTokens logging into helper function

Extract duplicate logging statements into a dedicated helper function
to improve code maintainability and ensure consistency across both
ChatCompletion and StreamChatCompletion flows.

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

* Add comprehensive tests for reasoning effort edge case handling (#49)

* Initial plan

* test: add comprehensive tests for reasoning effort edge cases

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

* fix: improve test code quality based on review feedback

Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>
@SantiagoDePolonia SantiagoDePolonia deleted the copilot/sub-pr-48-again branch March 22, 2026 14:24
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.

2 participants