fix(agent): keep Codex reasoning replay on Codex path

This commit is contained in:
Teknium
2026-06-13 14:35:00 -07:00
parent 1d584a301e
commit 069bfd6545
3 changed files with 25 additions and 5 deletions
+12 -3
View File
@@ -3246,7 +3246,11 @@ class AIAgent:
return sanitize_api_messages(messages)
@staticmethod
def _is_thinking_only_assistant(msg: Dict[str, Any]) -> bool:
def _is_thinking_only_assistant(
msg: Dict[str, Any],
*,
drop_codex_reasoning_items: bool = True,
) -> bool:
"""Return True if ``msg`` is an assistant turn whose only payload is reasoning.
"Thinking-only" means the model emitted reasoning (``reasoning`` or
@@ -3302,7 +3306,7 @@ class AIAgent:
# thinking-only; empty/junk lists should fall through to the generic
# empty-turn handling instead of being dropped here.
codex_items = msg.get("codex_reasoning_items")
if isinstance(codex_items, list):
if drop_codex_reasoning_items and isinstance(codex_items, list):
return any(
isinstance(item, dict) and item.get("type") == "reasoning"
for item in codex_items
@@ -3312,10 +3316,15 @@ class AIAgent:
@staticmethod
def _drop_thinking_only_and_merge_users(
messages: List[Dict[str, Any]],
*,
drop_codex_reasoning_items: bool = True,
) -> List[Dict[str, Any]]:
"""Forwarder — see ``agent.agent_runtime_helpers.drop_thinking_only_and_merge_users``."""
from agent.agent_runtime_helpers import drop_thinking_only_and_merge_users
return drop_thinking_only_and_merge_users(messages)
return drop_thinking_only_and_merge_users(
messages,
drop_codex_reasoning_items=drop_codex_reasoning_items,
)
@staticmethod
def _cap_delegate_task_calls(tool_calls: list) -> list: