Skip to content

Add conditional tool enabling feature to agent as tool. #1193

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 2 commits into
base: main
Choose a base branch
from

Conversation

thoo
Copy link
Contributor

@thoo thoo commented Jul 20, 2025

Summary

Adds is_enabled parameter to Agent.as_tool() method for conditionally enabling/disabling agent tools at runtime. Supports boolean values and callable functions for dynamic tool filtering
in multi-agent orchestration.

Test plan

  • Added unit tests in tests/test_agent_as_tool.py
  • Added example in examples/agent_patterns/agents_as_tools_conditional.py
  • Updated documentation in docs/tools.md
  • All tests pass

Issue number

Closes #1097

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@seratch seratch added enhancement New feature or request feature:core labels Jul 22, 2025
@seratch
Copy link
Member

seratch commented Jul 22, 2025

@rm-openai As we have the is_enabled flag for other types of tools now, this looks reasonable change to me. What do you think?

@seratch seratch requested a review from rm-openai July 22, 2025 00:10
@thoo
Copy link
Contributor Author

thoo commented Jul 22, 2025

@seratch Thanks for the review! I'm happy to address any suggestions you or @rm-openai might have. This feature is particularly useful for us since we work extensively with MCP agents and need the flexibility to dynamically enable/disable tools based on runtime conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add is_enabled option to Agent as a tool pattern
2 participants