Skip to content

Add comprehensive tests for reasoning effort edge case handling#49

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

Add comprehensive tests for reasoning effort edge case handling#49
SantiagoDePolonia merged 3 commits intoclaude/fix-thinking-max-tokens-vdp8gfrom
copilot/sub-pr-48

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 26, 2026

Review feedback questioned whether req.Reasoning.Effort needs explicit nil checking. Since Effort is a string (not *string), it cannot be nil—unset values default to "". The existing check req.Reasoning.Effort != "" already handles all edge cases correctly.

Changes

  • Added test coverage for reasoning effort validation:
    • Nil Reasoning object
    • Empty/unset Effort string
    • Valid effort levels (low/medium/high)
    • Invalid effort values (defaults to low)
    • MaxTokens bump to meet budget requirements
    • Temperature removal when reasoning enabled
    • Coverage for both ChatRequest and ResponsesRequest paths

Example behavior validated

// Case 1: No reasoning - thinking disabled
req := &core.ChatRequest{Reasoning: nil}
result := convertToAnthropicRequest(req)
// result.Thinking == nil ✓

// Case 2: Reasoning with empty effort - thinking disabled
req := &core.ChatRequest{Reasoning: &core.Reasoning{Effort: ""}}
result := convertToAnthropicRequest(req)
// result.Thinking == nil ✓

// Case 3: Valid effort - thinking enabled, MaxTokens bumped if needed
req := &core.ChatRequest{
    Reasoning: &core.Reasoning{Effort: "high"},
    MaxTokens: intPtr(1000),
}
result := convertToAnthropicRequest(req)
// result.Thinking.BudgetTokens == 20000
// result.MaxTokens == 20000 (bumped from 1000) ✓

No implementation changes required—existing logic is correct and now has full test coverage.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 26, 2026 14:28
Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>
Co-authored-by: SantiagoDePolonia <16936376+SantiagoDePolonia@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MaxTokens and Effort checking based on review feedback Add comprehensive tests for reasoning effort edge case handling Jan 26, 2026
@SantiagoDePolonia SantiagoDePolonia marked this pull request as ready for review January 26, 2026 15:31
@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 14eca86 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 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