fix(agent): treat Codex reasoning items as thinking-only

This commit is contained in:
briandevans 2026-06-13 13:53:58 -07:00 committed by Teknium
parent 57c2a55be4
commit 1d584a301e
2 changed files with 42 additions and 0 deletions

View file

@ -3297,6 +3297,16 @@ class AIAgent:
rd = msg.get("reasoning_details")
if isinstance(rd, list) and rd:
return True
# Codex Responses stores encrypted reasoning state under a separate
# assistant-message key. Treat only real reasoning items as
# 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):
return any(
isinstance(item, dict) and item.get("type") == "reasoning"
for item in codex_items
)
return False
@staticmethod

View file

@ -104,6 +104,38 @@ class TestIsThinkingOnlyAssistant:
}
assert AIAgent._is_thinking_only_assistant(msg)
def test_codex_reasoning_items_list_form_detected(self):
msg = {
"role": "assistant",
"content": "",
"codex_reasoning_items": [
{"type": "reasoning", "id": "rs_123", "encrypted_content": "enc_blob"}
],
}
assert AIAgent._is_thinking_only_assistant(msg)
def test_codex_reasoning_items_with_visible_text_is_not_thinking_only(self):
msg = {
"role": "assistant",
"content": "Visible answer",
"codex_reasoning_items": [
{"type": "reasoning", "id": "rs_123", "encrypted_content": "enc_blob"}
],
}
assert not AIAgent._is_thinking_only_assistant(msg)
def test_empty_codex_reasoning_items_list_is_not_thinking_only(self):
msg = {"role": "assistant", "content": "", "codex_reasoning_items": []}
assert not AIAgent._is_thinking_only_assistant(msg)
def test_non_reasoning_codex_items_are_not_thinking_only(self):
msg = {
"role": "assistant",
"content": "",
"codex_reasoning_items": [None, "x", {"type": "other"}],
}
assert not AIAgent._is_thinking_only_assistant(msg)
def test_user_message_never_thinking_only(self):
assert not AIAgent._is_thinking_only_assistant({"role": "user", "content": ""})