fix(orchestrator): Apply refinements from code review

This commit is contained in:
Yunxiao Xu
2026-02-23 15:46:21 -08:00
parent c5cf4b38a1
commit 2cfbc5d1d0
19 changed files with 252 additions and 33 deletions

View File

@@ -0,0 +1,33 @@
import pytest
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_does_not_advance_on_failure():
"""Verify that reflector does not increment current_step if not satisfied."""
state = AgentState(
checklist=[{"task": "Task 1", "worker": "data_analyst"}],
current_step=0,
messages=[],
question="test",
analysis={},
next_action="",
iterations=0,
vfs={},
plots=[],
dfs={},
summary="Failed output"
)
with patch("ea_chatbot.graph.nodes.reflector.get_llm_model") as mock_get_llm:
mock_llm = MagicMock()
# Mark as NOT satisfied
mock_llm.with_structured_output.return_value.invoke.return_value = MagicMock(satisfied=False, reasoning="Incomplete.")
mock_get_llm.return_value = mock_llm
result = reflector_node(state)
# Should NOT increment
assert result["current_step"] == 0
# Should probably route to planner or retry
assert result["next_action"] == "delegate" # Or 'planner' if we want re-planning