diff --git a/haiku_rag_slim/haiku/rag/cli_chat.py b/haiku_rag_slim/haiku/rag/cli_chat.py index bf67f300..35070708 100644 --- a/haiku_rag_slim/haiku/rag/cli_chat.py +++ b/haiku_rag_slim/haiku/rag/cli_chat.py @@ -1,6 +1,7 @@ """Interactive CLI chat loop for research graph with human-in-the-loop.""" import asyncio +import json from pydantic_ai import Agent from rich.console import Console @@ -225,7 +226,8 @@ async def run_interactive_research( pass elif event_type == "TOOL_CALL_ARGS": - args = event.get("delta", {}) + delta = event.get("delta", "{}") + args = json.loads(delta) if isinstance(delta, str) else delta original_question = args.get("original_question", "") sub_questions = list(args.get("sub_questions", [])) qa_responses = args.get("qa_responses", []) diff --git a/haiku_rag_slim/haiku/rag/graph/agui/events.py b/haiku_rag_slim/haiku/rag/graph/agui/events.py index 49710126..5cb1728b 100644 --- a/haiku_rag_slim/haiku/rag/graph/agui/events.py +++ b/haiku_rag_slim/haiku/rag/graph/agui/events.py @@ -289,10 +289,12 @@ def emit_tool_call_args(tool_call_id: str, args: dict[str, Any]) -> dict[str, An Returns: ToolCallArgs event dict """ + import json + return { "type": "TOOL_CALL_ARGS", "toolCallId": tool_call_id, - "delta": args, + "delta": json.dumps(args), } diff --git a/tests/graph/agui/test_events.py b/tests/graph/agui/test_events.py index 297229e6..5c8795d2 100644 --- a/tests/graph/agui/test_events.py +++ b/tests/graph/agui/test_events.py @@ -160,12 +160,14 @@ def test_emit_tool_call_start_with_parent(): def test_emit_tool_call_args(): """Test TOOL_CALL_ARGS event creation.""" + import json + args = {"query": "test query", "limit": 10} event = emit_tool_call_args("call-1", args) assert event["type"] == "TOOL_CALL_ARGS" assert event["toolCallId"] == "call-1" - assert event["delta"] == args + assert event["delta"] == json.dumps(args) def test_emit_tool_call_end():