Skip to content

feat(anthropic): map reasoning effort to thinking budgets - #3885

Closed
PaleRoses wants to merge 1 commit into
vectorize-io:mainfrom
PaleRoses:upstream/anthropic-thinking
Closed

feat(anthropic): map reasoning effort to thinking budgets#3885
PaleRoses wants to merge 1 commit into
vectorize-io:mainfrom
PaleRoses:upstream/anthropic-thinking

Conversation

@PaleRoses

Copy link
Copy Markdown

Problem

The native Anthropic provider accepts reasoning_effort but currently warns that it is ignored, even though Anthropic exposes extended thinking through an explicit token budget. Operators must route Anthropic through LiteLLM to control thinking.

Change

Map Hindsight's effort vocabulary onto native Anthropic thinking budgets for ordinary one-shot calls:

  • none: disabled
  • low: 4,096 tokens
  • medium: 8,192 tokens
  • high: 16,384 tokens
  • xhigh / max: 32,768 tokens

The thinking budget is added to max_tokens so the configured visible-output allowance is retained. Verification calls stay minimal. Forced structured-output calls omit thinking because Anthropic rejects extended thinking with forced tool choice. Unknown effort names remain visible through a warning.

This PR intentionally does not change timeout defaults, custom-base-URL behavior, or authentication headers.

Verification

The new request-shape tests fail on current main because no thinking field is sent (5 failures).

After the patch:

pytest -q \
  hindsight-api-slim/tests/test_anthropic_extended_thinking.py \
  hindsight-api-slim/tests/test_reasoning_effort_provider_coverage.py
17 passed

pytest -q hindsight-api-slim/tests/test_anthropic_structured_tool_use.py
3 passed

ruff check <changed Python paths>
All checks passed!

@strix-security

strix-security Bot commented Aug 29, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 52ba73d.


Reviewed by Strix
Re-run review · Configure security review settings

@PaleRoses PaleRoses closed this Aug 29, 2026
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