diff --git a/tests/integration/test_agent_manager_integration.py b/tests/integration/test_agent_manager_integration.py index 29a301ae..b434ed6b 100644 --- a/tests/integration/test_agent_manager_integration.py +++ b/tests/integration/test_agent_manager_integration.py @@ -757,7 +757,9 @@ Final Answer: { @pytest.mark.asyncio async def test_agent_manager_knowledge_query_collection_integration(self, mock_flow_context): """Test agent manager integration with KnowledgeQueryImpl collection parameter""" - # Arrange + import functools + + # Arrange - Use functools.partial like the real service does custom_tools = { "knowledge_query_custom": Tool( name="knowledge_query_custom", @@ -769,7 +771,7 @@ Final Answer: { description="The question to ask" ) ], - implementation=KnowledgeQueryImpl, + implementation=functools.partial(KnowledgeQueryImpl, collection="research_papers"), config={"collection": "research_papers"} ), "knowledge_query_default": Tool( @@ -813,11 +815,13 @@ Args: { @pytest.mark.asyncio async def test_knowledge_query_multiple_collections(self, mock_flow_context): """Test multiple KnowledgeQueryImpl instances with different collections""" - # Arrange + import functools + + # Arrange - Create partial functions like the service does tools = { - "general_kb": KnowledgeQueryImpl(mock_flow_context, collection="general"), - "technical_kb": KnowledgeQueryImpl(mock_flow_context, collection="technical"), - "research_kb": KnowledgeQueryImpl(mock_flow_context, collection="research") + "general_kb": functools.partial(KnowledgeQueryImpl, collection="general")(mock_flow_context), + "technical_kb": functools.partial(KnowledgeQueryImpl, collection="technical")(mock_flow_context), + "research_kb": functools.partial(KnowledgeQueryImpl, collection="research")(mock_flow_context) } # Act & Assert for each tool diff --git a/trustgraph-flow/trustgraph/agent/react/agent_manager.py b/trustgraph-flow/trustgraph/agent/react/agent_manager.py index ed22ea78..9b46bd34 100644 --- a/trustgraph-flow/trustgraph/agent/react/agent_manager.py +++ b/trustgraph-flow/trustgraph/agent/react/agent_manager.py @@ -269,13 +269,7 @@ class AgentManager: logger.debug(f"TOOL>>> {act}") - # Instantiate the tool implementation with context and config - if action.config: - tool_instance = action.implementation(context, **action.config) - else: - tool_instance = action.implementation(context) - - resp = await tool_instance.invoke( + resp = await action.implementation(context).invoke( **act.arguments )