Fix agent knowledge query initialisation failure (#469)

* Back out agent change

* Fixed broken tests
This commit is contained in:
cybermaggedon 2025-08-26 19:41:04 +01:00 committed by GitHub
parent 6e9e2a11b1
commit e5b9b4976a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 13 deletions

View file

@ -757,7 +757,9 @@ Final Answer: {
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_agent_manager_knowledge_query_collection_integration(self, mock_flow_context): async def test_agent_manager_knowledge_query_collection_integration(self, mock_flow_context):
"""Test agent manager integration with KnowledgeQueryImpl collection parameter""" """Test agent manager integration with KnowledgeQueryImpl collection parameter"""
# Arrange import functools
# Arrange - Use functools.partial like the real service does
custom_tools = { custom_tools = {
"knowledge_query_custom": Tool( "knowledge_query_custom": Tool(
name="knowledge_query_custom", name="knowledge_query_custom",
@ -769,7 +771,7 @@ Final Answer: {
description="The question to ask" description="The question to ask"
) )
], ],
implementation=KnowledgeQueryImpl, implementation=functools.partial(KnowledgeQueryImpl, collection="research_papers"),
config={"collection": "research_papers"} config={"collection": "research_papers"}
), ),
"knowledge_query_default": Tool( "knowledge_query_default": Tool(
@ -813,11 +815,13 @@ Args: {
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_knowledge_query_multiple_collections(self, mock_flow_context): async def test_knowledge_query_multiple_collections(self, mock_flow_context):
"""Test multiple KnowledgeQueryImpl instances with different collections""" """Test multiple KnowledgeQueryImpl instances with different collections"""
# Arrange import functools
# Arrange - Create partial functions like the service does
tools = { tools = {
"general_kb": KnowledgeQueryImpl(mock_flow_context, collection="general"), "general_kb": functools.partial(KnowledgeQueryImpl, collection="general")(mock_flow_context),
"technical_kb": KnowledgeQueryImpl(mock_flow_context, collection="technical"), "technical_kb": functools.partial(KnowledgeQueryImpl, collection="technical")(mock_flow_context),
"research_kb": KnowledgeQueryImpl(mock_flow_context, collection="research") "research_kb": functools.partial(KnowledgeQueryImpl, collection="research")(mock_flow_context)
} }
# Act & Assert for each tool # Act & Assert for each tool

View file

@ -269,13 +269,7 @@ class AgentManager:
logger.debug(f"TOOL>>> {act}") logger.debug(f"TOOL>>> {act}")
# Instantiate the tool implementation with context and config resp = await action.implementation(context).invoke(
if action.config:
tool_instance = action.implementation(context, **action.config)
else:
tool_instance = action.implementation(context)
resp = await tool_instance.invoke(
**act.arguments **act.arguments
) )