fix: strip timestamp field from messages before sending to strict providers#48666
Open
malavbhavsar wants to merge 1 commit into
Open
fix: strip timestamp field from messages before sending to strict providers#48666malavbhavsar wants to merge 1 commit into
malavbhavsar wants to merge 1 commit into
Conversation
…viders get_messages_as_conversation() attaches a float timestamp (Unix epoch from time.time()) to every message dict when the gateway restores conversation history from the SQLite session store. The field is not part of the OpenAI Chat Completions schema. Strict providers (Fireworks, Moonshot/Kimi, strict OpenAI-compatible gateways) reject it with HTTP 400 "Extra inputs are not permitted, field: messages[N].timestamp". Permissive providers (real OpenAI, OpenRouter) silently ignore unknown message keys, which masked the bug — the same pattern as tool_name (documented in the same function). The fix adds timestamp to the existing detection check and sanitization pass in convert_messages(), alongside the existing codex_*, tool_name, and _-prefixed scaffolding stripping. Also adds three regression tests covering: basic timestamp stripping, combined timestamp+tool_name stripping, and Gemini models (timestamp stripped but extra_content preserved).
Collaborator
|
Duplicate of #47875 — both add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Strips the
timestampfield from message dicts before they're sent to OpenAI-compatible providers viaconvert_messages()inagent/transports/chat_completions.py.The field — a float Unix epoch from
time.time()— is attached to every message byget_messages_as_conversation()inhermes_state.py:2903-2904when the gateway restores conversation history from the SQLite session store. It is not part of the OpenAI Chat Completions schema. Strict providers (Fireworks, Moonshot/Kimi, strict OpenAI-compatible gateways) reject it with:Permissive providers (real OpenAI, OpenRouter) silently ignore unknown message keys, which masked the bug — the same pattern as
tool_name(documented in the same function, lines 148-152). The fix addstimestampto the existing detection check and sanitization pass, alongside the existing stripping ofcodex_reasoning_items,tool_name,_-prefixed scaffolding markers, andextra_content.Related Issue
N/A
Type of Change
Changes Made
agent/transports/chat_completions.py: Addedtimestampto the detection check (line 183) and sanitization pass (line 213) inconvert_messages(). Updated the docstring to document the new field.tests/agent/transports/test_chat_completions.py: Added three regression tests:test_convert_messages_strips_timestamp,test_convert_messages_strips_timestamp_and_tool_name_together,test_convert_messages_strips_timestamp_for_gemini_too.How to Test
python -m pytest tests/agent/transports/test_chat_completions.py -k timestamp -vHTTP 400: Extra inputs are not permitted, field: 'messages[1].timestamp', value: 1781818044.0on the second turn when history is replayed from the session storetimestampis stripped before the payload reaches the providerChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (pytest not available in stripped install venv; tests verified manually — see How to Test)Documentation & Housekeeping
convert_messages()updated) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs
Original error from a strict Fireworks proxy:
After fix —
timestampis stripped from all messages before they reach the wire: