Skip to content

Conversation

@SrikarMannepalli
Copy link
Contributor

⏺ Summary of Changes

Problem Solved

AutoGen’s Anthropic client did not support thinking mode—Claude’s ability to show its reasoning process before providing a final answer.
Without this, users could not access the internal thought process that makes Claude’s responses more accurate and transparent.

Changes Made

Core Implementation (_anthropic_client.py)

  • Added _get_thinking_config() method to handle thinking parameter validation.
  • Added thinking content extraction for both regular and streaming responses.
  • Added support for thinking parameter in API calls.
  • Fixed pre-existing bug: _last_used_tools initialization.

Configuration Support (config/init.py)

  • Added ThinkingConfig TypedDict and ThinkingConfigModel for type safety.
  • Integrated thinking config into existing configuration structures.

Test Coverage (test_anthropic_model_client.py)

  • Added 4 comprehensive tests covering validation, basic usage, streaming, and tool integration.

Key Design Decisions

  • API-First Validation: Let Anthropic API handle all validation (budget_tokens, model support, temperature requirements).
  • User Responsibility: Users must set temperature=1.0 themselves — no automatic overrides.
  • Model-Agnostic: Works with any model name format (API validates support).
  • Clean Integration: Follows AutoGen’s existing extra_create_args pattern.

⏺ Usage Example

thinking_config = {
    "thinking": {
        "type": "enabled",
        "budget_tokens": 2000
    }
}

result = await client.create(messages, extra_create_args=thinking_config)

print(result.thought)   # reasoning process
print(result.content)   # final answer

⏺ Result

AutoGen users can now access Claude’s reasoning process, leading to more transparent and explainable AI interactions, while maintaining clean, maintainable code that follows AutoGen’s architectural principles.


⏺ Related Issue

Closes #6095


⏺ Checks

  • I’ve included any doc changes needed for https://microsoft.github.io/autogen/.
  • I’ve added tests corresponding to the changes introduced in this PR.
  • I’ve made sure all auto checks have passed.
@SrikarMannepalli
Copy link
Contributor Author

@microsoft-github-policy-service agree

@SrikarMannepalli SrikarMannepalli marked this pull request as ready for review September 9, 2025 06:33
@SrikarMannepalli
Copy link
Contributor Author

Hi @ekzhu,
This change introduces support for Claude’s reasoning (“thinking”) mode in the Anthropic client, along with validation, configuration updates, and tests.
I kindly request you to review the PR whenever you get a chance. Please let me know if there are any additional adjustments or clarifications you’d like.
Thanks so much for your time 🙏

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.93%. Comparing base (0df6be1) to head (9cfb218).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../autogen_ext/models/anthropic/_anthropic_client.py 40.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7002      +/-   ##
==========================================
- Coverage   80.99%   80.93%   -0.07%     
==========================================
  Files         237      237              
  Lines       18198    18240      +42     
==========================================
+ Hits        14739    14762      +23     
- Misses       3459     3478      +19     
Flag Coverage Δ
unittests 80.93% <50.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@ekzhu ekzhu merged commit 5216bf3 into microsoft:main Sep 16, 2025
72 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants