Skip to content

Fix: Preserve context, session_state, and extra_data when creating default reasoning agents #4081

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

Conversation

hussain-mohammed
Copy link
Contributor

Summary

Current Behavior:
When reasoning=True is used without specifying a reasoning model or agent, agno creates a default reasoning agent but loses the context, session_state, and extra_data from the original agent. As a result, these arguments are None when running the hooks.

Fix Implemented:
Added session_state, context, and extra_data arguments when creating default reasoning agents to preserve the original agent’s data.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Additional Notes

Add any important context (deployment instructions, screenshots, security considerations, etc.)

@hussain-mohammed hussain-mohammed requested a review from a team as a code owner August 3, 2025 12:30
@dirkbrnd
Copy link
Contributor

dirkbrnd commented Aug 4, 2025

@hussain-mohammed this makes sense thanks! Do you have an example to show why this is needed? Asking because the reasoning agent wouldn't use the context or session_state right? Unless it is configured to do so.

@hussain-mohammed
Copy link
Contributor Author

I’m using the agent via Slack and need to pass some Slack context to tools, especially in a hook for a confirmation step. (I pass this context with add_context=False). When I set reasoning=True, those parameters (context, session_state, extra_data) became None in the hook. After some digging, I found it’s because the flag creates a default reasoning agent without carrying over the original parameters.

@dirkbrnd dirkbrnd merged commit b67af71 into agno-agi:main Aug 18, 2025
3 checks passed
@dirkbrnd
Copy link
Contributor

This is added with 1.7.12!

@hussain-mohammed
Copy link
Contributor Author

That's great 🎉, thanks @dirkbrnd

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