Files
ea-chatbot-lg/backend/tests/test_review_fix_reflector.py
Yunxiao Xu 4d92c9aedb fix(orchestrator): Remove clarification interrupt to allow single-pass generation
Also fixes a test assertion in the reflector test to align with LangGraph state updates.
2026-02-23 19:32:45 -08:00

36 lines
1.3 KiB
Python

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 (therefore not in the updates dict)
assert "current_step" not in result
# Should increment iterations
assert result["iterations"] == 1
# Should probably route to planner or retry
assert result["next_action"] == "delegate" # Or 'planner' if we want re-planning