fix: stamp timestamps in model_metadata, turn_finalizer

This commit is contained in:
Tuck
2026-08-09 20:52:39 -04:00
committed by Teknium
parent d61558793e
commit 261ed6e855
2 changed files with 11 additions and 2 deletions
+9 -1
View File
@@ -26,6 +26,7 @@ import os
from agent.codex_responses_adapter import _summarize_user_message_for_log
from agent.message_content import flatten_message_text
from agent.message_metadata import append_message, stamp_message_timestamp
from agent.message_sanitization import _sanitize_surrogates
@@ -315,7 +316,10 @@ def finalize_turn(
if _tail_role != "assistant":
# Tail is not an assistant row — append the final response
# so the durable turn closes with the answer (#43849/#44100).
messages.append({"role": "assistant", "content": final_response})
append_message(
messages,
{"role": "assistant", "content": final_response},
)
elif isinstance(_tail, dict) and _tail.get("content") != final_response and _is_pure_tool_call_tail(_tail):
# The tail IS an assistant row, but a *pure tool-call turn*:
# tool_calls with no text of its own. The role check alone
@@ -332,6 +336,10 @@ def finalize_turn(
# candidate collapse — the provisional answer was persisted and
# reused as the terminal response, #65919 §7).
_tail["content"] = final_response
# The normal assistant builder already stamps this row. Cover
# legacy/exceptional pure-tool tails before they become a
# delivered final response.
stamp_message_timestamp(_tail)
# The row may have already been flushed to SQLite by the
# incremental tool-call persist (conversation_loop.py:4990),
# which stamps ``_DB_PERSISTED_MARKER`` so subsequent flushes