The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(agent): lock the reasoning-only stop row shape on the stall-guard and prefill paths
teknium1194695b58a5d
diff --git a/tests/agent/test_reasoning_only_stop_persistence.py b/tests/agent/test_reasoning_only_stop_persistence.pyindex 8e81b384701..34dcc1e6521 100644--- a/tests/agent/test_reasoning_only_stop_persistence.py+++ b/tests/agent/test_reasoning_only_stop_persistence.py@@ -78,6 +78,35 @@ def test_promoted_reasoning_is_returned_but_persisted_row_keeps_content_empty(loassert "api_content" not in assistant_rows[0]+def test_stall_guard_interim_row_carries_promoted_text_as_sidecar(loop_agent):+ """Promoted reasoning that tails on an announced next action trips the stall guard; the interim+ row it appends must follow the same shape as the final row — ``content`` empty, the promoted+ text in ``api_content`` — so the continuation request replays a real assistant turn, not an+ empty one (#111761)."""+ from tests.agent.test_run_agent import _mock_response++ stalled = "The user wants the file contents. Let me now read the file."+ loop_agent.valid_tool_names = {"read_file"}+ loop_agent._stall_guards = True++ result = _run(loop_agent, [+ _mock_response(content="", finish_reason="stop", reasoning_content=stalled),+ _mock_response(content="Here is the file.", finish_reason="stop"),+ ])++ assert result["final_response"] == "Here is the file."+ interim = [m for m in result["messages"] if m.get("role") == "assistant"][0]+ assert not interim.get("content")+ assert interim["reasoning"] == stalled+ assert interim["api_content"] == stalled++ # The continuation request carried the promoted text as the interim assistant turn.+ second_call = loop_agent.client.chat.completions.create.call_args_list[1].kwargs["messages"]+ interim_wire = [m for m in second_call if m.get("role") == "assistant"][0]+ assert interim_wire["content"] == stalled+ assert "api_content" not in interim_wire++def test_reasoning_only_clean_stop_logs_warning_with_route(loop_agent, caplog):from tests.agent.test_run_agent import _mock_responsediff --git a/tests/agent/test_thinking_prefill_trailing_turn.py b/tests/agent/test_thinking_prefill_trailing_turn.pyindex 4e41b055521..b6bd9de6a1c 100644--- a/tests/agent/test_thinking_prefill_trailing_turn.py+++ b/tests/agent/test_thinking_prefill_trailing_turn.py@@ -127,6 +127,40 @@ class TestThinkingPrefillTrailingTurn:f"Empty assistant stub(s) reached the wire: {empty_assistants}")+ def test_prefill_row_keeps_reasoning_out_of_content(self, loop_agent):+ """The prefill stub carries the model's reasoning in its reasoning fields only: its+ ``content`` stays empty when appended, and no transcript row ever stores the+ chain-of-thought as an ordinary reply (#111761)."""+ import agent.turn_empty_response as ter++ reasoning = "Let me work through the request step by step."+ loop_agent.client.chat.completions.create.side_effect = [+ _thinking_only_response(),+ _final_response(),+ ]+ appended = []+ real_append = ter.append_message++ def spy(messages, msg, *args, **kwargs):+ appended.append(dict(msg))+ return real_append(messages, msg, *args, **kwargs)++ with (+ patch.object(ter, "append_message", spy),+ patch.object(loop_agent, "_persist_session"),+ patch.object(loop_agent, "_save_trajectory"),+ patch.object(loop_agent, "_cleanup_task_resources"),+ ):+ result = loop_agent.run_conversation("do the thing")++ stubs = [m for m in appended if m.get("_thinking_prefill")]+ assert len(stubs) == 1+ assert not (stubs[0].get("content") or "").strip()+ assert stubs[0]["reasoning"] == reasoning+ assert not any(+ m.get("role") == "assistant" and m.get("content") == reasoning for m in result["messages"]+ )+def test_internal_marker_never_reaches_the_wire(self, loop_agent):"""``_thinking_prefill`` survives the API-copy build on purpose, but thetransport must still keep it off the wire."""