Repository navigation
fix(core): keep tool parameters on the MiniMax chat-completions wire #11842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0b41973
fix(core): keep tool parameters on the MiniMax chat-completions wire
yiliang114 d22e4cb
fix(core): match MiniMax routings by model id when the host gives no …
yiliang114 f4d8dd6
fix(core): gate the MiniMax tool-shape opt-out on the wire model
yiliang114 415c5c2
Merge origin/main into fix/issue-11834-minimax-tool-parameters
yiliang114 c889318
style(core): format minimax provider test
yiliang114 58d6e33
test(core): pin the logged tool shape to the wire model
yiliang114 4d8c883
Merge remote-tracking branch 'origin/main' into fix/issue-11834-minim…
yiliang114 fdf880a
Merge origin/main into fix/issue-11834-minimax-tool-parameters
yiliang114 3d6aa01
fix(core): scope MiniMax tool parameters to its provider
yiliang114 264da57
test(core): pin MiniMax tool-parameters scoping and document the over…
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
148 changes: 148 additions & 0 deletions
148
packages/core/src/core/openaiContentGenerator/converter-parameterless-parameters.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import type { Tool } from '@google/genai'; | ||
| import type { Config } from '../../config/config.js'; | ||
| import { ListAgentsTool } from '../../tools/list-agents.js'; | ||
| import { convertLlmToolsToOpenAI } from './converter.js'; | ||
|
|
||
| /** | ||
| * A zero-argument tool's `parameters` key is contested on the wire: | ||
| * | ||
| * - llama.cpp cannot compile a grammar over an empty `properties` map (#10080) | ||
| * and strict OpenAI-contract validators such as LM Studio reject | ||
| * `parameters: {"type":"object"}` without `properties` (#11410), which is why | ||
| * #11431 made omitting the key the default; | ||
| * - MiniMax rejects the omission itself — a request carrying the | ||
| * always-registered `list_agents` answers `400 invalid params, function | ||
| * parameters is empty (2013)` before the model is even reached (#11834). | ||
| * | ||
| * There is no single shape both accept, so the omission stays the default and | ||
| * the MiniMax routing opts out. Every assertion here is made on the | ||
| * *serialized* body: the defect is `JSON.stringify` dropping the key, so an | ||
| * assertion on the returned object could pass while the wire still omits it. | ||
| */ | ||
| describe('convertLlmToolsToOpenAI parameterless `parameters` (#11834)', () => { | ||
| /** | ||
| * The declaration from the report, taken from the real tool rather than a | ||
| * hand-written copy of its schema. `list_agents` is registered | ||
| * unconditionally, so every default interactive request carries it — which | ||
| * is why a bare greeting fails with no tool call in the conversation yet. | ||
| */ | ||
| function listAgentsTools(): Tool[] { | ||
| const declaration = new ListAgentsTool({} as Config).schema; | ||
| return [{ functionDeclarations: [declaration] }] as Tool[]; | ||
| } | ||
|
|
||
| function wire(tools: unknown): string { | ||
| return JSON.stringify(tools); | ||
| } | ||
|
|
||
| it('keeps an explicit empty `parameters` object when the routing opts out', async () => { | ||
| const result = await convertLlmToolsToOpenAI(listAgentsTools(), 'auto', { | ||
| keepParameterlessParameters: true, | ||
| }); | ||
|
|
||
| expect(result).toHaveLength(1); | ||
| expect(result[0].function.name).toBe('list_agents'); | ||
| expect(wire(result)).toContain( | ||
| '"parameters":{"type":"object","properties":{}}', | ||
| ); | ||
| expect(result[0].function.parameters).toEqual({ | ||
| type: 'object', | ||
| properties: {}, | ||
| }); | ||
| }); | ||
|
|
||
| it('still omits `parameters` by default', async () => { | ||
| const result = await convertLlmToolsToOpenAI(listAgentsTools()); | ||
|
|
||
| expect(wire(result)).not.toContain('parameters'); | ||
| expect(result[0].function.parameters).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('still omits `parameters` when the opt-out is explicitly disabled', async () => { | ||
| const result = await convertLlmToolsToOpenAI(listAgentsTools(), 'auto', { | ||
| keepParameterlessParameters: false, | ||
| }); | ||
|
|
||
| expect(wire(result)).not.toContain('parameters'); | ||
| expect(result[0].function.parameters).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('gates an MCP-style zero-argument tool the same way', async () => { | ||
| // An MCP server that declares no input schema reaches the converter as | ||
| // this default shape. | ||
| const tools = [ | ||
| { | ||
| functionDeclarations: [ | ||
| { | ||
| name: 'mcp_ping', | ||
| description: 'No arguments', | ||
| parametersJsonSchema: { type: 'object', properties: {} }, | ||
| }, | ||
| ], | ||
| }, | ||
| ] as Tool[]; | ||
|
|
||
| const kept = await convertLlmToolsToOpenAI(tools, 'auto', { | ||
| keepParameterlessParameters: true, | ||
| }); | ||
| expect(wire(kept)).toContain( | ||
| '"parameters":{"type":"object","properties":{}}', | ||
| ); | ||
|
|
||
| const omitted = await convertLlmToolsToOpenAI(tools); | ||
| expect(wire(omitted)).not.toContain('parameters'); | ||
| }); | ||
|
|
||
| it('leaves a tool that declares arguments identical on both paths', async () => { | ||
| const tools = [ | ||
| { | ||
| functionDeclarations: [ | ||
| { | ||
| name: 'read_file', | ||
| description: 'Reads a file', | ||
| parametersJsonSchema: { | ||
| type: 'object', | ||
| properties: { path: { type: 'string' } }, | ||
| required: ['path'], | ||
| additionalProperties: false, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| ] as Tool[]; | ||
|
|
||
| const kept = await convertLlmToolsToOpenAI(tools, 'auto', { | ||
| keepParameterlessParameters: true, | ||
| }); | ||
| const omitted = await convertLlmToolsToOpenAI(tools); | ||
|
|
||
| expect(kept).toEqual(omitted); | ||
| expect(wire(kept)).toContain('"path"'); | ||
| }); | ||
|
|
||
| it('does not synthesise `parameters` for a declaration that never carried a schema', async () => { | ||
| // No registration path produces this — tools always expose | ||
| // `parametersJsonSchema`, and an MCP tool without an input schema gets an | ||
| // empty object one — so the opt-out deliberately stops at undoing the | ||
| // omission #11431 introduced. | ||
| const tools = [ | ||
| { | ||
| functionDeclarations: [{ name: 'bare', description: 'No schema' }], | ||
| }, | ||
| ] as Tool[]; | ||
|
|
||
| const result = await convertLlmToolsToOpenAI(tools, 'auto', { | ||
| keepParameterlessParameters: true, | ||
| }); | ||
|
|
||
| expect(result[0].function.parameters).toBeUndefined(); | ||
| expect(wire(result)).not.toContain('parameters'); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.