Skip to content

The agent that grows with you

fix(auxiliary): treat any unfinished non-server-side item as a partial in leak rescue

kshitijk4poor9a98e845434d
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 78dfd299fb1..9d4d4512936 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -1134,8 +1134,8 @@ def _parse_codex_final_response(
) -> Tuple[List[str], List[Any], Any, str]:
"""Normalize Responses output without losing phase or completion state for aux callers."""
from agent.codex_responses_adapter import (
- _INCOMPLETE_STATUSES, _extract_responses_message_text, _leaked_tool_call_text, _lower_or_none,
- _normalize_codex_response,
+ _INCOMPLETE_STATUSES, _SERVER_SIDE_TOOL_CALL_TYPES, _extract_responses_message_text, _leaked_tool_call_text,
+ _lower_or_none, _normalize_codex_response,
)
# The shared normalizer reads SDK-style items. Keep support for compatible hosts
@@ -1158,10 +1158,11 @@ def _parse_codex_final_response(
reason = str(_field(normalized_final.incomplete_details, "reason", "") or "").strip().lower()
# The main loop's leaked-tool-call recovery clears the text so its continuation can re-elicit a
# real call; aux has no continuation, so a completed answer quoting such text keeps it.
- # Only a fully completed response qualifies: an unfinished message item is still a partial.
+ # Only a fully completed response qualifies: any unfinished (non-server-side) item is still a partial.
if finish_reason == "incomplete" and status == "completed" and not message.tool_calls \
and message.codex_message_items is None and not any(
- _field(item, "type") == "message" and _lower_or_none(_field(item, "status")) in _INCOMPLETE_STATUSES
+ _field(item, "type") not in _SERVER_SIDE_TOOL_CALL_TYPES
+ and _lower_or_none(_field(item, "status")) in _INCOMPLETE_STATUSES
for item in output):
answer = "\n".join(filter(None, (
_extract_responses_message_text(item) for item in output
diff --git a/tests/agent/test_auxiliary_codex_completion_status.py b/tests/agent/test_auxiliary_codex_completion_status.py
index b516b28bcb6..804bc2064f7 100644
--- a/tests/agent/test_auxiliary_codex_completion_status.py
+++ b/tests/agent/test_auxiliary_codex_completion_status.py
@@ -73,6 +73,9 @@ _TOOL_CALL = SimpleNamespace(
type="function_call", status="completed", call_id="call_1", name="inspect", arguments='{"path":"x"}',
)
_LEAK_LIKE_ANSWER = 'Summary of work.\nRunning the tests next.\n{"cmd": "pytest -q"}'
+_PARTIAL_TOOL_CALL = SimpleNamespace(
+ type="function_call", status="in_progress", call_id="call_2", name="inspect", arguments='{"pa',
+)
_CODEX_REASONING_ONLY = SimpleNamespace(
type="reasoning", id="rs_test", encrypted_content=None, summary=[SimpleNamespace(text="still thinking")],
)
@@ -87,7 +90,7 @@ _CODEX_REASONING_ONLY = SimpleNamespace(
pytest.param("", "completed", [_TOOL_CALL], None, None, "tool_calls", id="tool-call"),
pytest.param("", "completed", [_message(_LEAK_LIKE_ANSWER, phase=None)], None, _LEAK_LIKE_ANSWER, "stop",
id="tool-call-like-answer"),
- pytest.param("", "completed", [_message(_LEAK_LIKE_ANSWER, phase=None, status="incomplete")], None, None,
+ pytest.param("", "completed", [_message(_LEAK_LIKE_ANSWER, phase=None), _PARTIAL_TOOL_CALL], None, None,
"length", id="tool-call-like-partial-item"),
# A str ``output`` is delivered only via output_text (empty output list), as streamed Codex answers can be.
pytest.param("", "completed", _LEAK_LIKE_ANSWER, None, _LEAK_LIKE_ANSWER, "stop", id="tool-call-like-output-text"),