fix(agent): strip gateway replay metadata from messages before API calls (#48523)#48604
Open
kyssta-exe wants to merge 1 commit into
Open
fix(agent): strip gateway replay metadata from messages before API calls (#48523)#48604kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
…lls (NousResearch#48523) When the gateway reloads a session from SQLite, get_messages_as_conversation() attaches internal metadata fields (timestamp, message_id, observed, finish_reason) to message dicts. These fields are not part of the OpenAI Chat Completions schema. Permissive providers (OpenAI, OpenRouter) silently ignore them, but strict validators (e.g. GLM-5.2 via opencode-go) reject with HTTP 400: 'Extra inputs are not permitted'. The existing convert_messages() in ChatCompletionsTransport stripped some internal fields (codex_reasoning_items, tool_name, _-prefixed keys) but missed the gateway replay metadata. This fix adds timestamp, message_id, observed, and finish_reason to the strip list and refactors the detection and removal logic into a shared _STRIP_KEYS tuple for maintainability.
Collaborator
|
Duplicate of #47875 — both strip gateway/session replay metadata at the same |
23 tasks
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.
Fixes #48523. When the gateway reloads a session from SQLite, get_messages_as_conversation() attaches internal metadata fields (timestamp, message_id, observed, finish_reason) to message dicts. These fields are not part of the OpenAI Chat Completions schema. Permissive providers silently ignore them, but strict validators (e.g. GLM-5.2 via opencode-go) reject with HTTP 400: 'Extra inputs are not permitted'. This fix adds these fields to the strip list in convert_messages().