Strip non-schema message fields for Mistral chat requests#48
Open
jvmenen wants to merge 1 commit intoagent0ai:mainfrom
Open
Strip non-schema message fields for Mistral chat requests#48jvmenen wants to merge 1 commit intoagent0ai:mainfrom
jvmenen wants to merge 1 commit intoagent0ai:mainfrom
Conversation
Mistral's chat completions API uses strict Pydantic validation (extra="forbid") and rejects internal bookkeeping fields (tokenCount, kind, source) that the prompt pipeline attaches to message objects. Add a headless _core/mistral module with shared endpoint detection and a body-rewrite helper, wired through extension hooks on prepareOnscreenAgentApiRequest and prepareAdminAgentApiRequest. Non-Mistral requests are untouched.
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.
Summary
extra="forbid") and rejects any field on a message object that is not part of its defined schema.tokenCount,kind, andsourceto message objects for prompt budgeting and UI display, which causes Mistral to reject the request._core/mistralmodule with shared endpoint detection and a body-rewrite helper, wired through extension hooks onprepareOnscreenAgentApiRequestandprepareAdminAgentApiRequest. Non-Mistral requests are left untouched.Design notes
/api/proxy.role,content,name,tool_calls,tool_call_id. If Mistral expands the accepted schema later, extendALLOWED_MESSAGE_FIELDSinrequest.jsrather than removing the strip._core/onscreen_agent/llm.jsor_core/admin/views/agent/api.js, so the admin and onscreen surfaces stay in sync via one shared helper.AGENTS.mddocuments ownership and contracts for the new module.Test plan
app/**/*assets include the new_core/mistralmodule after repackaging.