Skip to content

fix: Anthropic extended thinking with tool use and minor fixes #2487

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kaushal-26
Copy link

Fixes: #2425 (issue)

- In anthropic extended thinking we cannot send `tool_choice: {"type": "any"}` or `tool_choice: {"type": "tool", "name": "..."}` will give an error.
	- Source: https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking#extended-thinking-with-tool-use
- Fixes anthropic models file to explicitly handle thinking enabled flag.
- Add testcases for output variations in pydantic as: `pydantic.BaseModel, ToolOutput and StructuredDict`. Failed earlier without changes
- Add a warning for `temperature < 1`, as anthropic only allows `temperature == 1` if enabled thinking and `0.95 <= top_p <= 1`.
	- Source: https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking#feature-compatibility
- Minor fix in .gitignore as .venv 3.9, 3.10, ... handled and pycache, ruff cache handled as previously dependent on .gitignore file inside this folders.
- Fix CLAUDE.md to use `pydantic_ai_slim/pydantic_ai/agent/` instead of `pydantic_ai_slim/pydantic_ai/agent.py` as file doesn't exists.
Copy link
Contributor

hyperlint-ai bot commented Aug 8, 2025

PR Change Summary

Enhanced Anthropic extended thinking functionality and addressed several issues.

  • Fixed tool choice handling in extended thinking to prevent errors.
  • Updated anthropic models to manage the thinking enabled flag explicitly.
  • Added test cases for output variations in Pydantic.
  • Implemented a warning for temperature settings in accordance with Anthropic guidelines.

Modified Files

  • CLAUDE.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

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.

Anthropic thinking returns error: "Thinking may not be enabled when tool_choice forces tool use."
1 participant