diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.py index 4b000372b39..d2dc4745c03 100644 --- a/agent/chat_completion_helpers.py +++ b/agent/chat_completion_helpers.py @@ -1525,8 +1525,10 @@ def handle_max_iterations(agent, messages: list, api_call_count: int) -> str: # hand-builds messages and calls chat.completions.create() directly, # bypassing the transport — so mirror that sanitization here: # tool_name (SQLite FTS bookkeeping), the codex_* reasoning carriers, + # timestamp (preserved on gateway user replay entries for the + # stale-confirmation expiry check — #47868 rejection class), # and every Hermes-internal underscore-prefixed scaffolding key. - for schema_foreign in ("tool_name", "codex_reasoning_items", "codex_message_items"): + for schema_foreign in ("tool_name", "codex_reasoning_items", "codex_message_items", "timestamp"): api_msg.pop(schema_foreign, None) for internal_key in [k for k in api_msg if isinstance(k, str) and k.startswith("_")]: api_msg.pop(internal_key, None)