feat(orchestrator): Implement Reflector node for task evaluation and plan advancement

This commit is contained in:
Yunxiao Xu
2026-02-23 05:38:50 -08:00
parent ff9b443bfe
commit 37c353a249
3 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
from unittest.mock import MagicMock, patch
from ea_chatbot.graph.nodes.reflector import reflector_node
from ea_chatbot.graph.state import AgentState
def test_reflector_node_satisfied():
"""Verify that the reflector node increments current_step when satisfied."""
state = AgentState(
checklist=[{"task": "Analyze votes", "worker": "data_analyst"}],
current_step=0,
messages=[],
question="test",
analysis={},
next_action="",
iterations=0,
vfs={},
plots=[],
dfs={},
summary="Worker successfully analyzed votes and found 5 million."
)
# Mocking the LLM to return 'satisfied=True'
with patch("ea_chatbot.graph.nodes.reflector.get_llm_model") as mock_get_llm:
mock_llm = MagicMock()
mock_llm.with_structured_output.return_value.invoke.return_value = MagicMock(satisfied=True, reasoning="Good.")
mock_get_llm.return_value = mock_llm
result = reflector_node(state)
assert result["current_step"] == 1
assert result["next_action"] == "delegate" # Route back to delegate for next task