feat(orchestrator): Implement Synthesizer node for final worker results integration

This commit is contained in:
Yunxiao Xu
2026-02-23 05:42:55 -08:00
parent 37c353a249
commit 9fef4888b5
3 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
from unittest.mock import MagicMock, patch
from ea_chatbot.graph.nodes.synthesizer import synthesizer_node
from ea_chatbot.graph.state import AgentState
from langchain_core.messages import AIMessage
def test_synthesizer_node_success():
"""Verify that the synthesizer node produces a final response."""
state = AgentState(
messages=[AIMessage(content="Worker 1 found data."), AIMessage(content="Worker 2 searched web.")],
question="What are the results?",
checklist=[],
current_step=0,
iterations=0,
vfs={},
plots=[],
dfs={},
next_action="",
analysis={}
)
# Mocking the LLM
with patch("ea_chatbot.graph.nodes.synthesizer.get_llm_model") as mock_get_llm:
mock_llm = MagicMock()
mock_llm.invoke.return_value = AIMessage(content="Final synthesized answer.")
mock_get_llm.return_value = mock_llm
result = synthesizer_node(state)
assert len(result["messages"]) == 1
assert result["messages"][0].content == "Final synthesized answer."
assert result["next_action"] == "end"