test(agent): pin verification fallback edge cases

Cover empty pending output falling back to summarization and a later verified response superseding the held premature report.
This commit is contained in:
kshitijk4poor 2026-07-10 11:36:02 +05:30 committed by kshitij
parent f46e7647eb
commit 8fc80bc2aa
2 changed files with 39 additions and 0 deletions

View file

@ -139,6 +139,22 @@ def test_pending_pre_verify_response_is_preserved_on_budget_exhaustion(monkeypat
assert agent._handle_max_iterations_called is False
def test_empty_pending_verification_response_uses_summary_fallback(monkeypatch):
monkeypatch.setattr("hermes_cli.plugins.invoke_hook", lambda *_a, **_kw: [])
agent = _LimitAgent()
result = _finalize(
agent,
final_response=None,
exit_reason="unknown",
pending_verification_response="",
)
assert result["final_response"] == "summary from extra call"
assert result["turn_exit_reason"] == "max_iterations_reached(60/60)"
assert agent._handle_max_iterations_called is True
def test_text_response_exit_not_rewritten_at_iteration_limit(monkeypatch):
monkeypatch.setattr("hermes_cli.plugins.invoke_hook", lambda *_a, **_kw: [])
agent = _LimitAgent(budget_remaining=5)

View file

@ -121,3 +121,26 @@ def test_intermediate_ack_uses_summary_instead_of_premature_text(agent, monkeypa
assert result["final_response"] == "verified summary"
assert result["turn_exit_reason"] == "max_iterations_reached(1/1)"
agent._handle_max_iterations.assert_called_once()
def test_later_verified_response_supersedes_pending_report(agent, monkeypatch):
agent.max_iterations = 2
agent.iteration_budget.max_total = 2
answers = iter([_response("premature report"), _response("verified final report")])
agent._interruptible_api_call = lambda _kwargs: next(answers)
agent._handle_max_iterations = MagicMock(return_value="replacement summary")
monkeypatch.setenv("HERMES_VERIFY_ON_STOP", "1")
with (
patch(
"agent.verification_stop.build_verify_on_stop_nudge",
side_effect=["verify it", None],
),
patch("hermes_cli.plugins.invoke_hook", return_value=[]),
):
result = agent.run_conversation("edit changed.py")
assert result["final_response"] == "verified final report"
assert result["turn_exit_reason"] == "text_response(finish_reason=stop)"
assert result["completed"] is True
agent._handle_max_iterations.assert_not_called()