diff --git a/tests/unit/test_agent/test_agent_service_non_streaming.py b/tests/unit/test_agent/test_agent_service_non_streaming.py index 0f1ece85..0fd2060d 100644 --- a/tests/unit/test_agent/test_agent_service_non_streaming.py +++ b/tests/unit/test_agent/test_agent_service_non_streaming.py @@ -39,7 +39,7 @@ class TestAgentServiceNonStreaming: async def mock_react(question, history, think, observe, answer, context, streaming): await think("I need to solve this.", is_final=True) await observe("The answer is 4.", is_final=True) - return Final("4") + return Final(thought="Final answer", final="4") mock_agent_instance.react = mock_react @@ -115,7 +115,7 @@ class TestAgentServiceNonStreaming: # Mock react to return Final directly async def mock_react(question, history, think, observe, answer, context, streaming): - return Final("4") + return Final(thought="Final answer", final="4") mock_agent_instance.react = mock_react diff --git a/trustgraph-base/trustgraph/base/agent_service.py b/trustgraph-base/trustgraph/base/agent_service.py index d675983a..0e5524fe 100644 --- a/trustgraph-base/trustgraph/base/agent_service.py +++ b/trustgraph-base/trustgraph/base/agent_service.py @@ -48,13 +48,13 @@ class AgentService(FlowProcessor): async def on_request(self, msg, consumer, flow): + # Get ID early so error handler can use it + id = msg.properties().get("id", "unknown") + try: request = msg.value() - # Sender-produced ID - id = msg.properties()["id"] - async def respond(resp): await flow("response").send(