Skip to content

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

Merged
rm-openai merged 2 commits into
openai:mainfrom
thoo:feature-conditional-tools
Aug 15, 2025
Merged

rm-openai merged 2 commits into
openai:mainfrom
thoo:feature-conditional-tools

Conversation

@thoo

@thoo thoo commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

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

seratch commented Jul 22, 2025

Copy link
Copy Markdown
Member

@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

thoo commented Jul 22, 2025

Copy link
Copy Markdown
Contributor Author

@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.

@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot added the stale label Aug 1, 2025
@seratch seratch added skip-stale and removed stale labels Aug 1, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot added the stale label Aug 12, 2025

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel having this should be fine for the above reason. @rm-openai do you have any thoughts?

@seratch seratch removed the stale label Aug 12, 2025

@rm-openai rm-openai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add is_enabled option to Agent as a tool pattern

3 participants