The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: double-paren bug in dropped-tools prefix + add empty-response nudge sibling
kshitij4f675cf2fc1d
diff --git a/agent/context_compressor.py b/agent/context_compressor.pyindex 134d27abd6a..3eb05b6b971 100644--- a/agent/context_compressor.py+++ b/agent/context_compressor.py@@ -4601,6 +4601,7 @@ This compaction should PRIORITISE preserving all information related to the focu_CODEX_ACK_CONTINUATION_NUDGE,_CODEX_INCOMPLETE_NUDGE,_DROPPED_TOOLCALL_NUDGE_CONTENT,+ _EMPTY_TOOL_RESPONSE_NUDGE,_LENGTH_CONTINUATION_DROPPED_TOOLS_PREFIX,_LENGTH_CONTINUATION_NETWORK_STUB,_LENGTH_CONTINUATION_OUTPUT_LIMIT,@@ -4613,6 +4614,7 @@ This compaction should PRIORITISE preserving all information related to the focu_CODEX_INCOMPLETE_NUDGE,_CODEX_ACK_CONTINUATION_NUDGE,_DROPPED_TOOLCALL_NUDGE_CONTENT,+ _EMPTY_TOOL_RESPONSE_NUDGE,_LENGTH_CONTINUATION_NETWORK_STUB,_LENGTH_CONTINUATION_OUTPUT_LIMIT,} or text.startswith(diff --git a/agent/conversation_loop.py b/agent/conversation_loop.pyindex 4e00a17ff7c..01a256d5dce 100644--- a/agent/conversation_loop.py+++ b/agent/conversation_loop.py@@ -779,7 +779,7 @@ _LENGTH_CONTINUATION_OUTPUT_LIMIT = (# The dropped-tools variant interpolates the tool name list right after this# prefix, so it can't be exact-matched — this stable prefix is what# _is_synthetic_compression_user_turn checks with str.startswith instead.-_LENGTH_CONTINUATION_DROPPED_TOOLS_PREFIX = "[System: Your previous tool call ("+_LENGTH_CONTINUATION_DROPPED_TOOLS_PREFIX = "[System: Your previous tool call "def _get_continuation_prompt(is_partial_stub: bool, dropped_tools: Optional[List[str]] = None) -> str:@@ -839,6 +839,15 @@ _DROPPED_TOOLCALL_NUDGE_CONTENT = ("the actual tool call now to continue the task.")+# Re-prompt sent when the model returns an empty response after executing tool+# calls (#9400). Named for the same reason as the nudges above — its+# _empty_recovery_synthetic metadata flag doesn't survive SessionDB projection.+_EMPTY_TOOL_RESPONSE_NUDGE = (+ "You just executed tool calls but returned an "+ "empty response. Please process the tool "+ "results above and continue with the task."+)+# Shared recovery hint appended to every content-policy refusal message. Both# the HTTP-200 refusal path (``finish_reason=content_filter``) and the@@ -7070,11 +7079,7 @@ def run_conversation(messages.append(_nudge_msg)messages.append({"role": "user",- "content": (- "You just executed tool calls but returned an "- "empty response. Please process the tool "- "results above and continue with the task."- ),+ "content": _EMPTY_TOOL_RESPONSE_NUDGE,"_empty_recovery_synthetic": True,})continuediff --git a/tests/agent/test_context_compressor_zero_user_provenance.py b/tests/agent/test_context_compressor_zero_user_provenance.pyindex 1954353fd27..6890eba8681 100644--- a/tests/agent/test_context_compressor_zero_user_provenance.py+++ b/tests/agent/test_context_compressor_zero_user_provenance.py@@ -280,6 +280,12 @@ def test_real_task_wins_over_trailing_max_iterations_nudge(compressor):"the actual tool call now to continue the task.",id="dropped_toolcall_nudge",),+ pytest.param(+ "You just executed tool calls but returned an "+ "empty response. Please process the tool "+ "results above and continue with the task.",+ id="empty_tool_response_nudge",+ ),],)def test_conversation_loop_retry_nudges_are_synthetic(content):