Test that plugins are NOT propagated when include_plugins=False.
()
| 695 | |
| 696 | |
| 697 | def test_include_plugins_false(): |
| 698 | """Test that plugins are NOT propagated when include_plugins=False.""" |
| 699 | |
| 700 | class TrackingPlugin(BasePlugin): |
| 701 | |
| 702 | def __init__(self, name: str): |
| 703 | super().__init__(name) |
| 704 | self.before_agent_calls = 0 |
| 705 | |
| 706 | async def before_agent_callback(self, **kwargs): |
| 707 | self.before_agent_calls += 1 |
| 708 | |
| 709 | tracking_plugin = TrackingPlugin(name='tracking') |
| 710 | |
| 711 | mock_model = testing_utils.MockModel.create( |
| 712 | responses=[function_call_no_schema, 'response1', 'response2'] |
| 713 | ) |
| 714 | |
| 715 | tool_agent = Agent( |
| 716 | name='tool_agent', |
| 717 | model=mock_model, |
| 718 | ) |
| 719 | |
| 720 | root_agent = Agent( |
| 721 | name='root_agent', |
| 722 | model=mock_model, |
| 723 | tools=[AgentTool(agent=tool_agent, include_plugins=False)], |
| 724 | ) |
| 725 | |
| 726 | runner = testing_utils.InMemoryRunner(root_agent, plugins=[tracking_plugin]) |
| 727 | runner.run('test1') |
| 728 | |
| 729 | # Plugin should only be called for root_agent, not tool_agent. |
| 730 | assert tracking_plugin.before_agent_calls == 1 |
| 731 | |
| 732 | |
| 733 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected