Skip to content
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

Fix: claude thinking when not streaming #2226

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cookbook/models/anthropic/thinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
agent = Agent(
model=Claude(
id="claude-3-7-sonnet-20250219",
max_tokens=8192,
thinking={"type": "enabled", "budget_tokens": 4096},
max_tokens=2048,
thinking={"type": "enabled", "budget_tokens": 1024},
),
markdown=True,
)

# Print the response in the terminal
agent.print_response("Share a very scary 2 sentence horror story", stream=True)
agent.print_response("Share a very scary 2 sentence horror story")
14 changes: 14 additions & 0 deletions cookbook/models/anthropic/thinking_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.anthropic import Claude

agent = Agent(
model=Claude(
id="claude-3-7-sonnet-20250219",
max_tokens=2048,
thinking={"type": "enabled", "budget_tokens": 1024},
),
markdown=True,
)

# Print the response in the terminal
agent.print_response("Share a very scary 2 sentence horror story", stream=True)
2 changes: 2 additions & 0 deletions libs/agno/agno/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ def _process_model_response(
model_response.content = assistant_message.get_content_string()
else:
model_response.content += assistant_message.get_content_string()
if assistant_message.thinking is not None:
model_response.thinking = assistant_message.thinking
if assistant_message.audio_output is not None:
model_response.audio = assistant_message.audio_output
if provider_response.extra is not None:
Expand Down