@@ -53,67 +53,12 @@ export class MimoHandler extends OpenAiHandler {
5353 return { id, info, ...params }
5454 }
5555
56- /**
57- * Strip OpenAI-specific extensions that MiMo's Token Plan proxy rejects.
58- * The official API docs list `strict` as supported (default false), but the
59- * proxy endpoints have historically returned 400 for it. Kept as a safety
60- * net until the proxy is confirmed to handle these fields correctly.
61- */
62- protected override convertToolsForOpenAI ( tools : any [ ] | undefined ) : any [ ] | undefined {
63- if ( ! tools ) {
64- return undefined
65- }
66-
67- return tools . map ( ( tool ) => {
68- if ( tool . type !== "function" ) {
69- return tool
70- }
71-
72- return {
73- type : "function" ,
74- function : {
75- name : tool . function . name ,
76- description : tool . function . description ,
77- parameters : this . stripOpenAiExtensions ( tool . function . parameters ) ,
78- } ,
79- }
80- } )
81- }
82-
83- /**
84- * Recursively walks a JSON Schema object and removes OpenAI-specific
85- * fields (additionalProperties, strict) that MiMo's proxy doesn't
86- * recognize. Without this, every tool call would 400.
87- */
88- private stripOpenAiExtensions ( schema : any ) : any {
89- if ( ! schema || typeof schema !== "object" ) {
90- return schema
91- }
92-
93- const { additionalProperties, ...rest } = schema
94-
95- if ( rest . properties ) {
96- const newProps : Record < string , any > = { }
97- for ( const [ key , prop ] of Object . entries ( rest . properties ) ) {
98- newProps [ key ] = this . stripOpenAiExtensions ( prop )
99- }
100- rest . properties = newProps
101- }
102-
103- if ( rest . items && typeof rest . items === "object" ) {
104- rest . items = this . stripOpenAiExtensions ( rest . items )
105- }
106-
107- return rest
108- }
109-
11056 /**
11157 * Streams a chat completion from MiMo's OpenAI-compatible API.
11258 *
11359 * Uses convertToR1Format (shared with DeepSeek/Z.ai) for message conversion
11460 * with mergeToolResultText and normalizeToolCallId options enabled.
115- * MiMo-specific: enables thinking mode via extra_body.thinking, strips
116- * OpenAI-specific fields from tool definitions via convertToolsForOpenAI.
61+ * MiMo-specific: enables thinking mode via extra_body.thinking.
11762 *
11863 * supportsPromptCache is false because MiMo doesn't support client-side
11964 * cache_control injection. However, MiMo's server-side cache CAN return
@@ -133,7 +78,7 @@ export class MimoHandler extends OpenAiHandler {
13378 normalizeToolCallId : sanitizeOpenAiCallId ,
13479 } )
13580
136- const tools = this . convertToolsForOpenAI ( metadata ?. tools )
81+ const tools = metadata ?. tools
13782
13883 // Build request per MiMo's OpenAI-compatible API
13984 // https://developer.puter.com/ai/xiaomi/mimo-v2.5-pro/
0 commit comments