From 6af8515f698bc929bc52bcf3e81cb9e7a0e6d3b7 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Mon, 7 Sep 2026 14:14:14 -0500 Subject: [PATCH] feat(ai): add MiniMax provider (#47827) --- packages/ai/README.md | 40 +++ packages/ai/src/providers/index.ts | 1 + packages/ai/src/providers/minimax.ts | 144 ++++++++++ packages/ai/src/providers/minimax/chat.ts | 13 + packages/ai/src/providers/minimax/messages.ts | 1 + .../ai/src/providers/minimax/responses.ts | 16 ++ ...ues-a-tool-loop-with-default-thinking.json | 56 ++++ ...3-streams-text-with-thinking-disabled.json | 36 +++ .../m2-7-streams-default-thinking.json | 36 +++ ...es-a-tool-loop-with-adaptive-thinking.json | 56 ++++ ...d-tool-call-with-default-thinking-off.json | 36 +++ .../m3-streams-adaptive-thinking.json | 36 +++ ...3-streams-text-with-thinking-disabled.json | 36 +++ ...inues-a-tool-loop-with-effort-minimal.json | 56 ++++ .../m3-streams-text-with-effort-none.json | 36 +++ .../ai/test/provider-options/minimax.types.ts | 26 ++ packages/ai/test/provider-package.test.ts | 29 ++ .../ai/test/provider/minimax.recorded.test.ts | 265 ++++++++++++++++++ packages/ai/test/provider/minimax.test.ts | 101 +++++++ 19 files changed, 1020 insertions(+) create mode 100644 packages/ai/src/providers/minimax.ts create mode 100644 packages/ai/src/providers/minimax/chat.ts create mode 100644 packages/ai/src/providers/minimax/messages.ts create mode 100644 packages/ai/src/providers/minimax/responses.ts create mode 100644 packages/ai/test/fixtures/recordings/minimax-chat/m3-continues-a-tool-loop-with-default-thinking.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-chat/m3-streams-text-with-thinking-disabled.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-messages/m2-7-streams-default-thinking.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-messages/m3-continues-a-tool-loop-with-adaptive-thinking.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-messages/m3-generates-a-named-tool-call-with-default-thinking-off.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-adaptive-thinking.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-text-with-thinking-disabled.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-responses/m3-continues-a-tool-loop-with-effort-minimal.json create mode 100644 packages/ai/test/fixtures/recordings/minimax-responses/m3-streams-text-with-effort-none.json create mode 100644 packages/ai/test/provider-options/minimax.types.ts create mode 100644 packages/ai/test/provider/minimax.recorded.test.ts create mode 100644 packages/ai/test/provider/minimax.test.ts diff --git a/packages/ai/README.md b/packages/ai/README.md index 5343cfa4ea0..f885ee38214 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -29,6 +29,46 @@ await Effect.runPromise(program.pipe(Effect.provide(llmLayer))) Run `LLMClient.stream(request)` instead of `generate` when you want incremental `LLMEvent`s. The event stream is provider-neutral — same shape across OpenAI Chat, OpenAI Responses, Anthropic Messages, Gemini, Bedrock Converse, and any OpenAI-compatible deployment. +## MiniMax + +MiniMax defaults to its Messages API and reads `MINIMAX_API_KEY` when `apiKey` is omitted: + +```ts +import { Effect, Layer } from "effect" +import { LLM, LLMClient } from "@opencode-ai/ai" +import { MiniMax } from "@opencode-ai/ai/providers" +import { RequestExecutor } from "@opencode-ai/ai/route" + +const minimax = MiniMax.configure({ apiKey: process.env.MINIMAX_API_KEY }) +const request = LLM.request({ + model: minimax.model("MiniMax-M3"), // also minimax.messages("MiniMax-M3") + prompt: "What is 173 multiplied by 219?", + providerOptions: { thinking: { type: "adaptive" } }, + generation: { maxTokens: 1536 }, +}) + +const layer = LLMClient.layer.pipe(Layer.provide(RequestExecutor.fetchLayer)) +const response = await Effect.runPromise(LLMClient.generate(request).pipe(Effect.provide(layer))) +console.log(response.text) +``` + +Select `minimax.chat("MiniMax-M3")` or `minimax.responses("MiniMax-M3")` for MiniMax's native Chat Completions +and Responses APIs. The matching package entrypoints are `@opencode-ai/ai/providers/minimax/messages`, +`@opencode-ai/ai/providers/minimax/chat`, and `@opencode-ai/ai/providers/minimax/responses`. + +- **Messages:** M3 thinking defaults off. Set `thinking: { type: "adaptive" }` to enable it or + `thinking: { type: "disabled" }` to disable it. +- **Chat:** M3 thinking defaults on and uses the same `thinking` control. The provider enables `reasoning_split` + by default so reasoning is separate from answer text; `reasoningSplit: false` selects native ``-tagged text. +- **Responses:** M3 reasoning defaults off. `reasoningEffort: "none"` disables it; `"minimal"`, `"low"`, + `"medium"`, and `"high"` enable reasoning without changing its depth. + +M2.x models always think, even when a disabling option is supplied. For tool continuations, retain the complete +`response.message` in history before adding `Message.tool(...)` results; this preserves reasoning and any signatures. + +The default API bases are `https://api.minimax.io/anthropic/v1` for Messages and `https://api.minimax.io/v1` for +Chat and Responses. `configure({ baseURL })` replaces the selected API's base, including its version prefix. + ## Image generation Use `Image.generate` with an image model for direct asset generation: diff --git a/packages/ai/src/providers/index.ts b/packages/ai/src/providers/index.ts index 9f15fea3f12..b962c5233e3 100644 --- a/packages/ai/src/providers/index.ts +++ b/packages/ai/src/providers/index.ts @@ -16,6 +16,7 @@ export * as GoogleVertexChat from "./google-vertex-chat.js" export * as GoogleVertexMessages from "./google-vertex-messages.js" export * as GoogleVertexResponses from "./google-vertex-responses.js" export * as Groq from "./groq.js" +export * as MiniMax from "./minimax.js" export * as Mistral from "./mistral.js" export * as OpenAI from "./openai.js" export * as OpenAICompatible from "./openai-compatible.js" diff --git a/packages/ai/src/providers/minimax.ts b/packages/ai/src/providers/minimax.ts new file mode 100644 index 00000000000..449c1e537f9 --- /dev/null +++ b/packages/ai/src/providers/minimax.ts @@ -0,0 +1,144 @@ +import { Effect, Schema } from "effect" +import type { ProviderPackage } from "../provider-package.js" +import { AnthropicMessages } from "../protocols/anthropic-messages.js" +import { OpenAIChat } from "../protocols/openai-chat.js" +import { OpenResponses } from "../protocols/open-responses.js" +import { ProviderShared } from "../protocols/shared.js" +import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js" +import { Route, type RouteDefaultsInput } from "../route/client.js" +import { Endpoint } from "../route/endpoint.js" +import { Framing } from "../route/framing.js" +import { Protocol } from "../route/protocol.js" +import { ProviderID, type LLMRequest, type ModelID } from "../schema/index.js" + +export const id = ProviderID.make("minimax") + +export type MessagesOptionsInput = { + /** M3 defaults to disabled; M2.x always thinks. */ + readonly thinking?: { readonly type: "adaptive" | "disabled" } + readonly metadata?: AnthropicMessages.OptionsInput["metadata"] +} + +export type ChatOptionsInput = { + /** M3 defaults to adaptive; M2.x always thinks. */ + readonly thinking?: { readonly type: "adaptive" | "disabled" | (string & {}) } + /** Separates reasoning from text. Defaults to true. */ + readonly reasoningSplit?: boolean +} + +export type ResponsesOptionsInput = { + /** M3 defaults to none. Other supported values enable thinking without changing its depth. */ + readonly reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | (string & {}) +} + +export type ProviderOptionsInput = MessagesOptionsInput | ChatOptionsInput | ResponsesOptionsInput + +export type Config = Omit & + ProviderAuthOption<"optional"> & { + /** Overrides the selected API's base URL, including its version prefix. */ + readonly baseURL?: string + readonly providerOptions?: ProviderOptionsInput + } + +export interface Settings extends ProviderPackage.Settings { + readonly apiKey?: string + readonly baseURL?: string + readonly providerOptions?: Options +} + +const ChatOptions = Schema.Struct({ + thinking: Schema.optional(Schema.Struct({ type: Schema.String })), + reasoningSplit: Schema.optional(Schema.Boolean), +}) + +const chatProtocol = Protocol.make({ + id: "minimax-chat", + body: { + schema: Schema.Struct({ + ...OpenAIChat.bodyFields, + thinking: ChatOptions.fields.thinking, + reasoning_split: Schema.Boolean, + }), + from: Effect.fn("MiniMax.chatFromRequest")(function* (request: LLMRequest) { + const options = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(ChatOptions))( + request.providerOptions ?? {}, + ) + return { + ...(yield* OpenAIChat.protocol.body.from(request)), + thinking: options.thinking, + // MiniMax otherwise embeds tags in ordinary assistant text. + reasoning_split: options.reasoningSplit ?? true, + } + }), + }, + stream: OpenAIChat.protocol.stream, +}) + +const messagesRoute = Route.make({ + id: "minimax-messages", + provider: id, + providerMetadataKey: "minimax", + protocol: AnthropicMessages.protocol, + endpoint: Endpoint.path("/messages", { baseURL: "https://api.minimax.io/anthropic/v1" }), + framing: AnthropicMessages.framing, + headers: () => ({ "anthropic-version": "2023-06-01" }), +}) + +const chatRoute = Route.make({ + id: "minimax-chat", + provider: id, + providerMetadataKey: "minimax", + protocol: chatProtocol, + endpoint: Endpoint.path("/chat/completions", { baseURL: "https://api.minimax.io/v1" }), + framing: OpenAIChat.framing, +}) + +const responsesRoute = Route.make({ + id: "minimax-responses", + provider: id, + providerMetadataKey: "minimax", + protocol: OpenResponses.protocol, + endpoint: Endpoint.path("/responses", { baseURL: "https://api.minimax.io/v1" }), + framing: Framing.sse, +}) + +export const routes = [messagesRoute, chatRoute, responsesRoute] + +export const configure = (input: Config = {}) => { + const { apiKey: _apiKey, auth: _auth, baseURL, ...rest } = input + const defaults = { + ...rest, + endpoint: baseURL === undefined ? undefined : { baseURL }, + auth: AuthOptions.bearer(input, "MINIMAX_API_KEY"), + } + const messages = (modelID: string | ModelID) => + messagesRoute.with(defaults).model({ id: modelID }) + const chat = (modelID: string | ModelID) => + chatRoute.with(defaults).model({ + id: modelID, + compatibility: { supportsStore: false, supportsStrictMode: false }, + }) + const responses = (modelID: string | ModelID) => + responsesRoute.with(defaults).model({ id: modelID }) + return { id, model: messages, messages, chat, responses, configure } +} + +export const provider = configure() + +export const model: ProviderPackage.Definition, MessagesOptionsInput>["model"] = ( + modelID, + settings, +) => + configure({ + apiKey: settings.apiKey, + baseURL: settings.baseURL, + headers: settings.headers, + http: settings.body === undefined ? undefined : { body: { ...settings.body } }, + providerOptions: settings.providerOptions, + }).model(modelID) + +export const messages = provider.messages +export const chat = provider.chat +export const responses = provider.responses + +export * as MiniMax from "./minimax.js" diff --git a/packages/ai/src/providers/minimax/chat.ts b/packages/ai/src/providers/minimax/chat.ts new file mode 100644 index 00000000000..a569a79b14c --- /dev/null +++ b/packages/ai/src/providers/minimax/chat.ts @@ -0,0 +1,13 @@ +import type { ProviderPackage } from "../../provider-package.js" +import { MiniMax } from "../minimax.js" + +export type Settings = MiniMax.Settings + +export const model: ProviderPackage.Definition["model"] = (modelID, settings) => + MiniMax.configure({ + apiKey: settings.apiKey, + baseURL: settings.baseURL, + headers: settings.headers, + http: settings.body === undefined ? undefined : { body: { ...settings.body } }, + providerOptions: settings.providerOptions, + }).chat(modelID) diff --git a/packages/ai/src/providers/minimax/messages.ts b/packages/ai/src/providers/minimax/messages.ts new file mode 100644 index 00000000000..a373db900d8 --- /dev/null +++ b/packages/ai/src/providers/minimax/messages.ts @@ -0,0 +1 @@ +export { model, type Settings, type MessagesOptionsInput } from "../minimax.js" diff --git a/packages/ai/src/providers/minimax/responses.ts b/packages/ai/src/providers/minimax/responses.ts new file mode 100644 index 00000000000..625e090f46c --- /dev/null +++ b/packages/ai/src/providers/minimax/responses.ts @@ -0,0 +1,16 @@ +import type { ProviderPackage } from "../../provider-package.js" +import { MiniMax } from "../minimax.js" + +export type Settings = MiniMax.Settings + +export const model: ProviderPackage.Definition["model"] = ( + modelID, + settings, +) => + MiniMax.configure({ + apiKey: settings.apiKey, + baseURL: settings.baseURL, + headers: settings.headers, + http: settings.body === undefined ? undefined : { body: { ...settings.body } }, + providerOptions: settings.providerOptions, + }).responses(modelID) diff --git a/packages/ai/test/fixtures/recordings/minimax-chat/m3-continues-a-tool-loop-with-default-thinking.json b/packages/ai/test/fixtures/recordings/minimax-chat/m3-continues-a-tool-loop-with-default-thinking.json new file mode 100644 index 00000000000..117ac9aae80 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-chat/m3-continues-a-tool-loop-with-default-thinking.json @@ -0,0 +1,56 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-chat", + "provider:minimax", + "protocol:minimax-chat", + "tool", + "tool-loop", + "reasoning", + "continuation", + "usage" + ], + "name": "minimax-chat/m3-continues-a-tool-loop-with-default-thinking", + "recordedAt": "2026-09-07T16:53:28.103Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/chat/completions", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"}],\"tools\":[{\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false}}}],\"tool_choice\":\"auto\",\"stream\":true,\"stream_options\":{\"include_usage\":true},\"max_completion_tokens\":1536,\"reasoning_split\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "data: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\"The\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\"The\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" user wants me to\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" user wants me to\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" look up the current\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" look up the current\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" weather in Paris using\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" weather in Paris using\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" the get_weather\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" the get_weather\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" tool,\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" tool,\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" then report the weather\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" then report the weather\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" in one short sentence\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" in one short sentence\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\". I\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\". I\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" need to make\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" need to make\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" the tool call first\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" the tool call first\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\", then wait\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\", then wait\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" for the result before\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" for the result before\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" answering\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" answering\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[{\"finish_reason\":\"tool_calls\",\"index\":0,\"delta\":{\"content\":\"\",\"role\":\"assistant\",\"tool_calls\":[{\"id\":\"call_b20d520207124ba0917031bd\",\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\"},\"index\":0}],\"reasoning_content\":\".\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\".\"}]}}],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"902b203050ca43d3a8bebf495fba7da7\",\"choices\":[],\"created\":1788800005,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":{\"total_tokens\":503,\"total_characters\":0,\"prompt_tokens\":428,\"completion_tokens\":75},\"service_tier\":\"standard\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"\"}}\n\n" + } + }, + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/chat/completions", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"},{\"role\":\"assistant\",\"content\":null,\"tool_calls\":[{\"id\":\"call_b20d520207124ba0917031bd\",\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\"}}],\"reasoning_content\":\"The user wants me to look up the current weather in Paris using the get_weather tool, then report the weather in one short sentence. I need to make the tool call first, then wait for the result before answering.\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\"The user wants me to look up the current weather in Paris using the get_weather tool, then report the weather in one short sentence. I need to make the tool call first, then wait for the result before answering.\"}]},{\"role\":\"tool\",\"tool_call_id\":\"call_b20d520207124ba0917031bd\",\"content\":\"{\\\"condition\\\":\\\"sunny\\\",\\\"temperature\\\":\\\"18C\\\"}\"}],\"tools\":[{\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false}}}],\"tool_choice\":\"none\",\"stream\":true,\"stream_options\":{\"include_usage\":true},\"max_completion_tokens\":1536,\"reasoning_split\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "data: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\"The weather in\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\"The weather in\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" Paris is sunny with\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" Paris is sunny with\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" a temperature of \",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" a temperature of \"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\"18°C. I'll\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\"18°C. I'll\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" report\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" report\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"reasoning_content\":\" this in one short\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" this in one short\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\",\"role\":\"assistant\",\"reasoning_content\":\" sentence.\",\"reasoning_details\":[{\"type\":\"reasoning.text\",\"id\":\"reasoning-text-1\",\"format\":\"MiniMax-response-v1\",\"index\":0,\"text\":\" sentence.\"}]}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"The\",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" weather\",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" in Paris is currently\",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" sunny with\",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" a temperature of \",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"delta\":{\"content\":\"18°C.\",\"role\":\"assistant\"}}],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"92d4ae2658dda6c8f457cf543f896237\",\"choices\":[],\"created\":1788800006,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":{\"total_tokens\":344,\"total_characters\":0,\"prompt_tokens\":304,\"completion_tokens\":40},\"service_tier\":\"standard\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"\"}}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-chat/m3-streams-text-with-thinking-disabled.json b/packages/ai/test/fixtures/recordings/minimax-chat/m3-streams-text-with-thinking-disabled.json new file mode 100644 index 00000000000..32fecbe2d68 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-chat/m3-streams-text-with-thinking-disabled.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-chat", + "provider:minimax", + "protocol:minimax-chat", + "text", + "usage", + "thinking-off" + ], + "name": "minimax-chat/m3-streams-text-with-thinking-disabled", + "recordedAt": "2026-09-07T16:53:20.976Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/chat/completions", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":\"What is 173 multiplied by 219? Reply with only the final integer.\"}],\"stream\":true,\"stream_options\":{\"include_usage\":true},\"max_completion_tokens\":1536,\"thinking\":{\"type\":\"disabled\"},\"reasoning_split\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "data: {\"id\":\"d8d409a572a67df400527c6592b480df\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"}}],\"created\":1788800000,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"d8d409a572a67df400527c6592b480df\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"378\",\"role\":\"assistant\"}}],\"created\":1788800000,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"d8d409a572a67df400527c6592b480df\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"87\",\"role\":\"assistant\"}}],\"created\":1788800000,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"d8d409a572a67df400527c6592b480df\",\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"delta\":{\"role\":\"assistant\"}}],\"created\":1788800000,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":null,\"service_tier\":\"standard\"}\n\ndata: {\"id\":\"d8d409a572a67df400527c6592b480df\",\"choices\":[],\"created\":1788800000,\"model\":\"MiniMax-M3\",\"object\":\"chat.completion.chunk\",\"usage\":{\"total_tokens\":182,\"total_characters\":0,\"prompt_tokens\":179,\"completion_tokens\":3,\"prompt_tokens_details\":{\"cached_tokens\":128}},\"service_tier\":\"standard\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"\"}}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-messages/m2-7-streams-default-thinking.json b/packages/ai/test/fixtures/recordings/minimax-messages/m2-7-streams-default-thinking.json new file mode 100644 index 00000000000..9acd63dd4e2 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-messages/m2-7-streams-default-thinking.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M2.7", + "tags": [ + "prefix:minimax-messages", + "provider:minimax", + "protocol:anthropic-messages", + "text", + "usage", + "reasoning" + ], + "name": "minimax-messages/m2-7-streams-default-thinking", + "recordedAt": "2026-09-07T16:53:20.721Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M2.7\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What is 173 multiplied by 219? Reply with only the final integer.\"}]}],\"stream\":true,\"max_tokens\":1536}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"bd0c49bb4f5e6f26b77bab9b5a917484\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M2.7\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":57,\"output_tokens\":0}}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"thinking\",\"thinking\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"The user\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" asks: \\\"What is 173 multiplied by 219? Reply with only the final integer.\\\" So we compute 173 * 219. Compute:\\n\\n173 * 219 = \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"173 * (200 + 19) = 173*200 + 173*19 = 34600 + (173*19). 173*19 = 173*20\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" - 173 = 3460 - 173 = 3287. So total = 34600 + 3287 = 37887.\\n\\nAlternatively compute directly: 219 * \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"173 = 219 * 173 = (219 * 100) + (219 * 70) + (219 * 3) = 21900 + 15330 + 657\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" = 37887.\\n\\nThus answer is 37887. We must reply with only the final integer: \\\"37887\\\". No extra text.\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"signature_delta\",\"signature\":\"1625da2f905565076ee90b9c2919db39b1719731c0820eca2f2a1c9c28324e87\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"text_delta\",\"text\":\"37887\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"input_tokens\":57,\"output_tokens\":187,\"output_tokens_details\":{\"thinking_tokens\":184}}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-messages/m3-continues-a-tool-loop-with-adaptive-thinking.json b/packages/ai/test/fixtures/recordings/minimax-messages/m3-continues-a-tool-loop-with-adaptive-thinking.json new file mode 100644 index 00000000000..350ee604a08 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-messages/m3-continues-a-tool-loop-with-adaptive-thinking.json @@ -0,0 +1,56 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-messages", + "provider:minimax", + "protocol:anthropic-messages", + "tool", + "tool-loop", + "reasoning", + "continuation", + "usage" + ], + "name": "minimax-messages/m3-continues-a-tool-loop-with-adaptive-thinking", + "recordedAt": "2026-09-07T16:53:25.185Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"}]}],\"tools\":[{\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"input_schema\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false}}],\"tool_choice\":{\"type\":\"auto\"},\"stream\":true,\"max_tokens\":1536,\"thinking\":{\"type\":\"adaptive\"}}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"6a532037868639a6189e7c0b9e1c9aa2\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M3\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"},\"service_tier\":\"standard\"}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"thinking\",\"thinking\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"The user wants me\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" to look up the\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" current weather in Paris\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" using the get_\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"weather tool, then\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" report it\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" in one short sentence\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\". Let\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" me call the tool\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\".\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"signature_delta\",\"signature\":\"f05cb5f4873950f23d194289c41d79b96ebd37c9411a45b306ed44f135a910d4\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"call_01a07cc9f2d47d83a6424ff3\",\"name\":\"get_weather\",\"input\":{}}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\\\":\\\"Paris\\\"}\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\"},\"usage\":{\"input_tokens\":239,\"output_tokens\":63,\"cache_read_input_tokens\":203,\"service_tier\":\"standard\",\"output_tokens_details\":{\"thinking_tokens\":33}}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + }, + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"}]},{\"role\":\"assistant\",\"content\":[{\"type\":\"thinking\",\"thinking\":\"The user wants me to look up the current weather in Paris using the get_weather tool, then report it in one short sentence. Let me call the tool.\",\"signature\":\"f05cb5f4873950f23d194289c41d79b96ebd37c9411a45b306ed44f135a910d4\"},{\"type\":\"tool_use\",\"id\":\"call_01a07cc9f2d47d83a6424ff3\",\"name\":\"get_weather\",\"input\":{\"city\":\"Paris\"}}]},{\"role\":\"user\",\"content\":[{\"type\":\"tool_result\",\"tool_use_id\":\"call_01a07cc9f2d47d83a6424ff3\",\"content\":\"{\\\"condition\\\":\\\"sunny\\\",\\\"temperature\\\":\\\"18C\\\"}\"}]}],\"tools\":[{\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"input_schema\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false}}],\"tool_choice\":{\"type\":\"none\"},\"stream\":true,\"max_tokens\":1536,\"thinking\":{\"type\":\"adaptive\"}}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"e9e7ea89f63eca1cd17a037aef28eed1\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M3\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"},\"service_tier\":\"standard\"}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"The weather\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" in Paris is sunny\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" with\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" a\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" temperature of 18\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"°C.\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"input_tokens\":164,\"output_tokens\":16,\"cache_read_input_tokens\":128,\"service_tier\":\"standard\"}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-messages/m3-generates-a-named-tool-call-with-default-thinking-off.json b/packages/ai/test/fixtures/recordings/minimax-messages/m3-generates-a-named-tool-call-with-default-thinking-off.json new file mode 100644 index 00000000000..aa239c02d15 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-messages/m3-generates-a-named-tool-call-with-default-thinking-off.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-messages", + "provider:minimax", + "protocol:anthropic-messages", + "tool", + "thinking-off", + "usage" + ], + "name": "minimax-messages/m3-generates-a-named-tool-call-with-default-thinking-off", + "recordedAt": "2026-09-07T16:53:24.366Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Use get_weather to look up the current weather in Paris.\"}]}],\"tools\":[{\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"input_schema\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false}}],\"tool_choice\":{\"type\":\"tool\",\"name\":\"get_weather\"},\"stream\":true,\"max_tokens\":512}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"a60a8adb2eff7545f809b9df2689f1b8\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M3\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"},\"service_tier\":\"standard\"}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"I'll\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" look\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" up the current weather\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" in Paris for you\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\".\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"call_b0246853f3c4432ea455cc99\",\"name\":\"get_weather\",\"input\":{}}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\\\":\\\"Paris\\\"}\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\"},\"usage\":{\"input_tokens\":401,\"output_tokens\":39,\"service_tier\":\"standard\"}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-adaptive-thinking.json b/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-adaptive-thinking.json new file mode 100644 index 00000000000..b825a07f864 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-adaptive-thinking.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-messages", + "provider:minimax", + "protocol:anthropic-messages", + "text", + "usage", + "reasoning" + ], + "name": "minimax-messages/m3-streams-adaptive-thinking", + "recordedAt": "2026-09-07T16:53:16.470Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What is 173 multiplied by 219? Reply with only the final integer.\"}]}],\"stream\":true,\"max_tokens\":1536,\"thinking\":{\"type\":\"adaptive\"}}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"ece24e3da050a8b1d7e8b1ad924a9e17\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M3\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"},\"service_tier\":\"standard\"}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"thinking\",\"thinking\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"173\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" × 219\\n\\n\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"173 × 200\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" = 346\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"00\\n173 ×\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" 19 = \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"173 × 20\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" - 173 =\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" 3460\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" - 173 =\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\" 3287\\n\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"34600 + \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"3287 = \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"thinking_delta\",\"thinking\":\"37887\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"signature_delta\",\"signature\":\"af0089d30b3ee7aff92a96e68064f4ed9346ca97de4f579555d2b3e1e61b53ea\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"text_delta\",\"text\":\"37887\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"input_tokens\":64,\"output_tokens\":54,\"cache_read_input_tokens\":128,\"service_tier\":\"standard\",\"output_tokens_details\":{\"thinking_tokens\":49}}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-text-with-thinking-disabled.json b/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-text-with-thinking-disabled.json new file mode 100644 index 00000000000..9bf8100f8b6 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-messages/m3-streams-text-with-thinking-disabled.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-messages", + "provider:minimax", + "protocol:anthropic-messages", + "text", + "usage", + "thinking-off" + ], + "name": "minimax-messages/m3-streams-text-with-thinking-disabled", + "recordedAt": "2026-09-07T16:53:16.028Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/anthropic/v1/messages", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What is 173 multiplied by 219? Reply with only the final integer.\"}]}],\"stream\":true,\"max_tokens\":1536,\"thinking\":{\"type\":\"disabled\"}}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"01664c047875a0f573c966467c8cccc1\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"MiniMax-M3\",\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"},\"service_tier\":\"standard\"}}\n\nevent: ping\ndata: {\"type\":\"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"378\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"87\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"input_tokens\":51,\"output_tokens\":3,\"cache_read_input_tokens\":128,\"service_tier\":\"standard\"}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-responses/m3-continues-a-tool-loop-with-effort-minimal.json b/packages/ai/test/fixtures/recordings/minimax-responses/m3-continues-a-tool-loop-with-effort-minimal.json new file mode 100644 index 00000000000..d7a12bdbc99 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-responses/m3-continues-a-tool-loop-with-effort-minimal.json @@ -0,0 +1,56 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-responses", + "provider:minimax", + "protocol:open-responses", + "tool", + "tool-loop", + "reasoning", + "continuation", + "usage" + ], + "name": "minimax-responses/m3-continues-a-tool-loop-with-effort-minimal", + "recordedAt": "2026-09-07T16:53:31.031Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/responses", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"input\":[{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"}]}],\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"auto\",\"reasoning\":{\"effort\":\"minimal\"},\"max_output_tokens\":1536,\"stream\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"aefe001711e9f523f6860cf935e42724\",\"object\":\"response\",\"created_at\":1788800008,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.in_progress\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"aefe001711e9f523f6860cf935e42724\",\"object\":\"response\",\"created_at\":1788800008,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"item\":{\"id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"type\":\"reasoning\",\"status\":\"in_progress\",\"summary\":[],\"content\":[]},\"output_index\":0}\n\nevent: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"part\":{\"type\":\"reasoning_text\",\"text\":\"\"},\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":4,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\"The\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":5,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" user wants me to\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":6,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" look up the current\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":7,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" weather in Paris using\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":8,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" the get_weather\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":9,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" function\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":10,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" and\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":11,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" then report it\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":12,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\" in one short sentence\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":13,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"delta\":\".\"}\n\nevent: response.reasoning_text.done\ndata: {\"type\":\"response.reasoning_text.done\",\"sequence_number\":14,\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"text\":\"The user wants me to look up the current weather in Paris using the get_weather function and then report it in one short sentence.\"}\n\nevent: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":15,\"part\":{\"type\":\"reasoning_text\",\"text\":\"The user wants me to look up the current weather in Paris using the get_weather function and then report it in one short sentence.\"},\"output_index\":0,\"content_index\":0,\"item_id\":\"aefe001711e9f523f6860cf935e42724_rs\"}\n\nevent: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":16,\"item\":{\"status\":\"completed\",\"summary\":[],\"content\":[{\"type\":\"reasoning_text\",\"text\":\"The user wants me to look up the current weather in Paris using the get_weather function and then report it in one short sentence.\"}],\"id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"type\":\"reasoning\"},\"output_index\":0}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":17,\"item\":{\"id\":\"aefe001711e9f523f6860cf935e42724_fc_0\",\"type\":\"function_call\",\"status\":\"in_progress\",\"call_id\":\"call_9bd47592505a44ff8def95e2\",\"name\":\"get_weather\",\"arguments\":\"\"},\"output_index\":1}\n\nevent: response.function_call_arguments.delta\ndata: {\"type\":\"response.function_call_arguments.delta\",\"sequence_number\":18,\"output_index\":1,\"item_id\":\"aefe001711e9f523f6860cf935e42724_fc_0\",\"delta\":\"{\\\"city\\\":\\\"Paris\\\"}\"}\n\nevent: response.function_call_arguments.done\ndata: {\"type\":\"response.function_call_arguments.done\",\"sequence_number\":19,\"output_index\":1,\"item_id\":\"aefe001711e9f523f6860cf935e42724_fc_0\",\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\"}\n\nevent: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":20,\"item\":{\"type\":\"function_call\",\"status\":\"completed\",\"call_id\":\"call_9bd47592505a44ff8def95e2\",\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\",\"id\":\"aefe001711e9f523f6860cf935e42724_fc_0\"},\"output_index\":1}\n\nevent: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":21,\"response\":{\"id\":\"aefe001711e9f523f6860cf935e42724\",\"object\":\"response\",\"created_at\":1788800008,\"model\":\"MiniMax-M3\",\"status\":\"completed\",\"output\":[{\"id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"type\":\"reasoning\",\"status\":\"completed\",\"summary\":[],\"content\":[{\"type\":\"reasoning_text\",\"text\":\"The user wants me to look up the current weather in Paris using the get_weather function and then report it in one short sentence.\"}]},{\"id\":\"aefe001711e9f523f6860cf935e42724_fc_0\",\"type\":\"function_call\",\"status\":\"completed\",\"call_id\":\"call_9bd47592505a44ff8def95e2\",\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\"}],\"output_text\":null,\"usage\":{\"input_tokens\":428,\"output_tokens\":57,\"total_tokens\":485,\"input_tokens_details\":{\"cached_tokens\":256}},\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\n" + } + }, + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/responses", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"input\":[{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.\"}]},{\"type\":\"reasoning\",\"id\":\"aefe001711e9f523f6860cf935e42724_rs\",\"summary\":[{\"type\":\"summary_text\",\"text\":\"The user wants me to look up the current weather in Paris using the get_weather function and then report it in one short sentence.\"}],\"encrypted_content\":null},{\"type\":\"function_call\",\"id\":\"aefe001711e9f523f6860cf935e42724_fc_0\",\"call_id\":\"call_9bd47592505a44ff8def95e2\",\"name\":\"get_weather\",\"arguments\":\"{\\\"city\\\":\\\"Paris\\\"}\"},{\"type\":\"function_call_output\",\"call_id\":\"call_9bd47592505a44ff8def95e2\",\"output\":\"{\\\"condition\\\":\\\"sunny\\\",\\\"temperature\\\":\\\"18C\\\"}\"}],\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"none\",\"reasoning\":{\"effort\":\"minimal\"},\"max_output_tokens\":1536,\"stream\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"76db848c9dfddd85de9c214efc73544c\",\"object\":\"response\",\"created_at\":1788800009,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"none\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.in_progress\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"76db848c9dfddd85de9c214efc73544c\",\"object\":\"response\",\"created_at\":1788800009,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"none\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"item\":{\"type\":\"reasoning\",\"status\":\"in_progress\",\"summary\":[],\"content\":[],\"id\":\"76db848c9dfddd85de9c214efc73544c_rs\"},\"output_index\":0}\n\nevent: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"part\":{\"type\":\"reasoning_text\",\"text\":\"\"},\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":4,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\"The weather in\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":5,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" Paris is sunny with\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":6,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" a\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":7,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" temperature of 18\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":8,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\"°C. I'll\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":9,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" report\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":10,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" this in one short\"}\n\nevent: response.reasoning_text.delta\ndata: {\"type\":\"response.reasoning_text.delta\",\"sequence_number\":11,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"delta\":\" sentence.\"}\n\nevent: response.reasoning_text.done\ndata: {\"type\":\"response.reasoning_text.done\",\"sequence_number\":12,\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"text\":\"The weather in Paris is sunny with a temperature of 18°C. I'll report this in one short sentence.\"}\n\nevent: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":13,\"part\":{\"type\":\"reasoning_text\",\"text\":\"The weather in Paris is sunny with a temperature of 18°C. I'll report this in one short sentence.\"},\"output_index\":0,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_rs\"}\n\nevent: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":14,\"item\":{\"id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"type\":\"reasoning\",\"status\":\"completed\",\"summary\":[],\"content\":[{\"type\":\"reasoning_text\",\"text\":\"The weather in Paris is sunny with a temperature of 18°C. I'll report this in one short sentence.\"}]},\"output_index\":0}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":15,\"item\":{\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[],\"id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\"},\"output_index\":1}\n\nevent: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":16,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]},\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":17,\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"delta\":\"Paris\"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":18,\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"delta\":\" is currently sunny with\"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":19,\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"delta\":\" a temperature of \"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":20,\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"delta\":\"18°C.\"}\n\nevent: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":21,\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"text\":\"Paris is currently sunny with a temperature of 18°C.\"}\n\nevent: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":22,\"part\":{\"type\":\"output_text\",\"text\":\"Paris is currently sunny with a temperature of 18°C.\",\"annotations\":[]},\"output_index\":1,\"content_index\":0,\"item_id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\"}\n\nevent: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":23,\"item\":{\"id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"text\":\"Paris is currently sunny with a temperature of 18°C.\",\"annotations\":[],\"type\":\"output_text\"}]},\"output_index\":1}\n\nevent: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":24,\"response\":{\"id\":\"76db848c9dfddd85de9c214efc73544c\",\"object\":\"response\",\"created_at\":1788800009,\"model\":\"MiniMax-M3\",\"status\":\"completed\",\"output\":[{\"id\":\"76db848c9dfddd85de9c214efc73544c_rs\",\"type\":\"reasoning\",\"status\":\"completed\",\"summary\":[],\"content\":[{\"type\":\"reasoning_text\",\"text\":\"The weather in Paris is sunny with a temperature of 18°C. I'll report this in one short sentence.\"}]},{\"id\":\"76db848c9dfddd85de9c214efc73544c_msg_1\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Paris is currently sunny with a temperature of 18°C.\",\"annotations\":null}]}],\"output_text\":\"Paris is currently sunny with a temperature of 18°C.\",\"usage\":{\"input_tokens\":286,\"output_tokens\":37,\"total_tokens\":323,\"input_tokens_details\":{\"cached_tokens\":0}},\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":[{\"type\":\"function\",\"name\":\"get_weather\",\"description\":\"Get the current weather in a city\",\"parameters\":{\"type\":\"object\",\"properties\":{\"city\":{\"type\":\"string\",\"enum\":[\"Paris\"]}},\"required\":[\"city\"],\"additionalProperties\":false},\"strict\":false}],\"tool_choice\":\"none\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"minimal\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\n" + } + } + ] +} diff --git a/packages/ai/test/fixtures/recordings/minimax-responses/m3-streams-text-with-effort-none.json b/packages/ai/test/fixtures/recordings/minimax-responses/m3-streams-text-with-effort-none.json new file mode 100644 index 00000000000..b3fb4f36140 --- /dev/null +++ b/packages/ai/test/fixtures/recordings/minimax-responses/m3-streams-text-with-effort-none.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "metadata": { + "model": "MiniMax-M3", + "tags": [ + "prefix:minimax-responses", + "provider:minimax", + "protocol:open-responses", + "text", + "usage", + "thinking-off" + ], + "name": "minimax-responses/m3-streams-text-with-effort-none", + "recordedAt": "2026-09-07T16:53:21.223Z" + }, + "interactions": [ + { + "transport": "http", + "request": { + "method": "POST", + "url": "https://api.minimax.io/v1/responses", + "headers": { + "content-type": "application/json" + }, + "body": "{\"model\":\"MiniMax-M3\",\"input\":[{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"What is 173 multiplied by 219? Reply with only the final integer.\"}]}],\"reasoning\":{\"effort\":\"none\"},\"max_output_tokens\":1536,\"stream\":true}" + }, + "response": { + "status": 200, + "headers": { + "content-type": "text/event-stream; charset=utf-8" + }, + "body": "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0\",\"object\":\"response\",\"created_at\":1788800001,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":null,\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"none\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.in_progress\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0\",\"object\":\"response\",\"created_at\":1788800001,\"model\":\"MiniMax-M3\",\"status\":\"in_progress\",\"output\":[],\"output_text\":null,\"usage\":null,\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":null,\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"none\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"item\":{\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]},\"output_index\":0}\n\nevent: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]},\"output_index\":0,\"content_index\":0,\"item_id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"output_index\":0,\"content_index\":0,\"item_id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"delta\":\"378\"}\n\nevent: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"output_index\":0,\"content_index\":0,\"item_id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"delta\":\"87\"}\n\nevent: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":6,\"output_index\":0,\"content_index\":0,\"item_id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"text\":\"37887\"}\n\nevent: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":7,\"part\":{\"type\":\"output_text\",\"text\":\"37887\",\"annotations\":[]},\"output_index\":0,\"content_index\":0,\"item_id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\"}\n\nevent: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":8,\"item\":{\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"37887\",\"annotations\":[]}],\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"type\":\"message\"},\"output_index\":0}\n\nevent: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":9,\"response\":{\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0\",\"object\":\"response\",\"created_at\":1788800001,\"model\":\"MiniMax-M3\",\"status\":\"completed\",\"output\":[{\"id\":\"40d878e9c7ecc67905d069cdf9bec7c0_msg\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"37887\",\"annotations\":null}]}],\"output_text\":\"37887\",\"usage\":{\"input_tokens\":179,\"output_tokens\":3,\"total_tokens\":182,\"input_tokens_details\":{\"cached_tokens\":128}},\"error\":null,\"incomplete_details\":null,\"instructions\":null,\"metadata\":{},\"tools\":null,\"tool_choice\":\"auto\",\"temperature\":1,\"top_p\":0.95,\"text\":{\"format\":{\"type\":\"text\"}},\"reasoning\":{\"effort\":\"none\",\"summary\":null},\"max_output_tokens\":1536,\"parallel_tool_calls\":true,\"previous_response_id\":null,\"conversation\":null,\"store\":false,\"service_tier\":\"standard\",\"safety_identifier\":null,\"truncation\":\"disabled\"}}\n\n" + } + } + ] +} diff --git a/packages/ai/test/provider-options/minimax.types.ts b/packages/ai/test/provider-options/minimax.types.ts new file mode 100644 index 00000000000..89340a86820 --- /dev/null +++ b/packages/ai/test/provider-options/minimax.types.ts @@ -0,0 +1,26 @@ +import { LLM } from "../../src/index.js" +import { MiniMax } from "../../src/providers.js" + +const minimax = MiniMax.configure() + +LLM.request({ model: minimax.model("MiniMax-M3"), providerOptions: { thinking: { type: "adaptive" } } }) +LLM.request({ model: minimax.chat("MiniMax-M3"), providerOptions: { thinking: { type: "disabled" } } }) +LLM.request({ model: minimax.chat("MiniMax-M3"), providerOptions: { reasoningSplit: false } }) +LLM.request({ model: minimax.responses("MiniMax-M3"), providerOptions: { reasoningEffort: "minimal" } }) +LLM.request({ model: minimax.responses("MiniMax-M3"), providerOptions: { reasoningEffort: "future-effort" } }) + +LLM.request({ + model: minimax.model("MiniMax-M3"), + // @ts-expect-error MiniMax Messages has no documented effort setting. + providerOptions: { effort: "high" }, +}) +LLM.request({ + model: minimax.chat("MiniMax-M3"), + // @ts-expect-error Chat reasoning_split is a boolean. + providerOptions: { reasoningSplit: "true" }, +}) +LLM.request({ + model: minimax.responses("MiniMax-M3"), + // @ts-expect-error MiniMax Responses uses reasoning effort rather than Messages thinking. + providerOptions: { thinking: { type: "adaptive" } }, +}) diff --git a/packages/ai/test/provider-package.test.ts b/packages/ai/test/provider-package.test.ts index 18e326ac77d..0fac7b9f1f1 100644 --- a/packages/ai/test/provider-package.test.ts +++ b/packages/ai/test/provider-package.test.ts @@ -37,6 +37,10 @@ describe("provider package entrypoints", () => { import("@opencode-ai/ai/providers/fireworks"), import("@opencode-ai/ai/providers/cloudflare-ai-gateway"), import("@opencode-ai/ai/providers/cloudflare-workers-ai"), + import("@opencode-ai/ai/providers/minimax"), + import("@opencode-ai/ai/providers/minimax/messages"), + import("@opencode-ai/ai/providers/minimax/chat"), + import("@opencode-ai/ai/providers/minimax/responses"), ]) for (const module of modules) expect(module.model).toBeFunction() @@ -47,6 +51,31 @@ describe("provider package entrypoints", () => { expect(modules[19].model).not.toBe(modules[20].model) }) + test("maps MiniMax API entrypoints onto provider-owned routes", async () => { + const modules = await Promise.all([ + import("@opencode-ai/ai/providers/minimax"), + import("@opencode-ai/ai/providers/minimax/messages"), + import("@opencode-ai/ai/providers/minimax/chat"), + import("@opencode-ai/ai/providers/minimax/responses"), + ]) + expect(modules[0].model).toBe(modules[1].model) + const settings = { + apiKey: "fixture", + baseURL: "https://gateway.example/v1", + headers: { "x-application": "opencode" }, + body: { service_tier: "priority" }, + } + const routes = ["minimax-messages", "minimax-messages", "minimax-chat", "minimax-responses"] + modules.forEach((module, index) => { + const selected = module.model("MiniMax-M3", settings) + expect(selected.provider).toBe("minimax") + expect(selected.route.id).toBe(routes[index]) + expect(selected.route.endpoint.baseURL).toBe(settings.baseURL) + expect(selected.route.defaults.headers).toEqual(settings.headers) + expect(selected.route.defaults.http?.body).toEqual(settings.body) + }) + }) + test("maps DeepInfra package settings onto its native executable model", async () => { const DeepInfra = await import("@opencode-ai/ai/providers/deepinfra") const settings = { diff --git a/packages/ai/test/provider/minimax.recorded.test.ts b/packages/ai/test/provider/minimax.recorded.test.ts new file mode 100644 index 00000000000..dd3a815cdbc --- /dev/null +++ b/packages/ai/test/provider/minimax.recorded.test.ts @@ -0,0 +1,265 @@ +import { describe, expect } from "bun:test" +import { Effect } from "effect" +import { + LLM, + LLMEvent, + LLMRequest, + LLMResponse, + Message, + ToolChoice, + ToolDefinition, + type LanguageModel, +} from "../../src/index.js" +import { MiniMax } from "../../src/providers.js" +import { LLMClient } from "../../src/route.js" +import { compileRequest } from "../../src/route/client.js" +import { recordedTests } from "../recorded-test.js" + +const apiKey = process.env.MINIMAX_API_KEY ?? "fixture" +const minimax = MiniMax.configure({ apiKey }) +const weather = ToolDefinition.make({ + name: "get_weather", + description: "Get the current weather in a city", + inputSchema: { + type: "object", + properties: { city: { type: "string", enum: ["Paris"] } }, + required: ["city"], + additionalProperties: false, + }, +}) + +const textCases: ReadonlyArray<{ + name: string + api: string + protocol: string + model: LanguageModel + reasoning: boolean + body: Record +}> = [ + { + name: "M3 streams text with thinking disabled", + api: "messages", + protocol: "anthropic-messages", + model: MiniMax.configure({ apiKey, providerOptions: { thinking: { type: "disabled" } } }).model("MiniMax-M3"), + reasoning: false, + body: { thinking: { type: "disabled" } }, + }, + { + name: "M3 streams adaptive thinking", + api: "messages", + protocol: "anthropic-messages", + model: MiniMax.configure({ apiKey, providerOptions: { thinking: { type: "adaptive" } } }).messages("MiniMax-M3"), + reasoning: true, + body: { thinking: { type: "adaptive" } }, + }, + { + name: "M2.7 streams default thinking", + api: "messages", + protocol: "anthropic-messages", + model: minimax.model("MiniMax-M2.7"), + reasoning: true, + body: {}, + }, + { + name: "M3 streams text with thinking disabled", + api: "chat", + protocol: "minimax-chat", + model: MiniMax.configure({ apiKey, providerOptions: { thinking: { type: "disabled" } } }).chat("MiniMax-M3"), + reasoning: false, + body: { thinking: { type: "disabled" }, reasoning_split: true }, + }, + { + name: "M3 streams text with effort none", + api: "responses", + protocol: "open-responses", + model: MiniMax.configure({ apiKey, providerOptions: { reasoningEffort: "none" } }).responses("MiniMax-M3"), + reasoning: false, + body: { reasoning: { effort: "none" } }, + }, +] + +describe("MiniMax recorded", () => { + for (const item of textCases) { + const recorded = recordedTests({ + prefix: `minimax-${item.api}`, + provider: "minimax", + protocol: item.protocol, + requires: ["MINIMAX_API_KEY"], + metadata: { model: item.model.id }, + }) + recorded.effect.with( + item.name, + { tags: ["text", "usage", item.reasoning ? "reasoning" : "thinking-off"] }, + () => + Effect.gen(function* () { + const request = LLM.request({ + model: item.model, + prompt: "What is 173 multiplied by 219? Reply with only the final integer.", + generation: { maxTokens: 1536 }, + }) + const compiled = yield* compileRequest(request) + expect(compiled.body).toMatchObject(item.body) + + const response = yield* LLMClient.generate(request) + expect(response.text.replaceAll(",", "").trim()).toBe("37887") + expect(response.text).not.toContain("") + expect(response.reasoning.length > 0).toBe(item.reasoning) + expect(response.events.some(LLMEvent.is.reasoningDelta)).toBe(item.reasoning) + expect(response.events.some(LLMEvent.is.textDelta)).toBe(true) + expectUsage(response) + }), + 60_000, + ) + } + + const messages = recordedTests({ + prefix: "minimax-messages", + provider: "minimax", + protocol: "anthropic-messages", + requires: ["MINIMAX_API_KEY"], + metadata: { model: "MiniMax-M3" }, + }) + + messages.effect.with( + "M3 generates a named tool call with default thinking off", + { tags: ["tool", "thinking-off", "usage"] }, + () => + Effect.gen(function* () { + const response = yield* LLMClient.generate( + LLM.request({ + model: minimax.model("MiniMax-M3"), + prompt: "Use get_weather to look up the current weather in Paris.", + tools: [weather], + toolChoice: ToolChoice.named("get_weather"), + generation: { maxTokens: 512 }, + }), + ) + expect(response.finishReason.normalized).toBe("tool-calls") + expect(response.toolCalls).toMatchObject([{ name: "get_weather", input: { city: "Paris" } }]) + expect(response.reasoning).toBe("") + expect(response.events.some(LLMEvent.is.toolInputDelta)).toBe(true) + expectUsage(response) + }), + 60_000, + ) + + const loops: ReadonlyArray<{ api: string; protocol: string; mode: string; model: LanguageModel }> = [ + { + api: "messages", + protocol: "anthropic-messages", + mode: "adaptive thinking", + model: MiniMax.configure({ apiKey, providerOptions: { thinking: { type: "adaptive" } } }).model("MiniMax-M3"), + }, + { + api: "chat", + protocol: "minimax-chat", + mode: "default thinking", + model: minimax.chat("MiniMax-M3"), + }, + { + api: "responses", + protocol: "open-responses", + mode: "effort minimal", + model: MiniMax.configure({ apiKey, providerOptions: { reasoningEffort: "minimal" } }).responses("MiniMax-M3"), + }, + ] + + for (const item of loops) { + const recorded = recordedTests({ + prefix: `minimax-${item.api}`, + provider: "minimax", + protocol: item.protocol, + requires: ["MINIMAX_API_KEY"], + metadata: { model: item.model.id }, + }) + recorded.effect.with( + `M3 continues a tool loop with ${item.mode}`, + { tags: ["tool", "tool-loop", "reasoning", "continuation", "usage"] }, + () => + Effect.gen(function* () { + const request = LLM.request({ + model: item.model, + prompt: + "Look up the current weather in Paris using get_weather before answering. After receiving the result, report the weather in one short sentence.", + tools: [weather], + toolChoice: "auto", + generation: { maxTokens: 1536 }, + }) + const first = yield* LLMClient.generate(request) + expect(first.finishReason.normalized).toBe("tool-calls") + expect(first.toolCalls).toHaveLength(1) + expect(first.toolCalls).toMatchObject([{ name: "get_weather", input: { city: "Paris" } }]) + expect(first.reasoning.length).toBeGreaterThan(0) + expect(first.events.some(LLMEvent.is.reasoningDelta)).toBe(true) + expectUsage(first) + + const followUp = LLMRequest.update(request, { + toolChoice: ToolChoice.make("none"), + messages: [ + ...request.messages, + first.message, + ...first.toolCalls.map((call) => + Message.tool({ id: call.id, name: call.name, result: { condition: "sunny", temperature: "18C" } }), + ), + ], + }) + const replay = yield* compileRequest(followUp) + const reasoning = first.message.content.filter((part) => part.type === "reasoning") + if (item.api === "messages") { + reasoning.forEach((part) => expect(part.providerMetadata?.minimax?.signature).toEqual(expect.any(String))) + expect(replay.body.messages).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + role: "assistant", + content: expect.arrayContaining( + reasoning.map((part) => ({ + type: "thinking", + thinking: part.text, + signature: part.providerMetadata?.minimax?.signature, + })), + ), + }), + ]), + ) + } + if (item.api === "chat") { + expect(replay.body.messages).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + role: "assistant", + reasoning_content: first.reasoning, + reasoning_details: reasoning.flatMap( + (part) => part.providerMetadata?.minimax?.reasoningDetails ?? [], + ), + }), + ]), + ) + } + if (item.api === "responses") { + expect(replay.body.input).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + type: "reasoning", + summary: expect.arrayContaining([{ type: "summary_text", text: first.reasoning }]), + }), + ]), + ) + } + + const second = yield* LLMClient.generate(followUp) + expect(second.finishReason.normalized).toBe("stop") + expect(second.toolCalls).toHaveLength(0) + expect(second.text).toContain("Paris") + expect(second.text.toLowerCase()).toContain("sunny") + expectUsage(second) + }), + 120_000, + ) + } +}) + +function expectUsage(response: LLMResponse) { + expect(response.usage?.inputTokens).toBeGreaterThan(0) + expect(response.usage?.outputTokens).toBeGreaterThan(0) + expect(response.events.filter(LLMEvent.is.finish)).toHaveLength(1) +} diff --git a/packages/ai/test/provider/minimax.test.ts b/packages/ai/test/provider/minimax.test.ts new file mode 100644 index 00000000000..eb12815efad --- /dev/null +++ b/packages/ai/test/provider/minimax.test.ts @@ -0,0 +1,101 @@ +import { describe, expect, test } from "bun:test" +import { ConfigProvider, Effect } from "effect" +import { Headers } from "effect/unstable/http" +import { LLM } from "../../src/index.js" +import { MiniMax } from "../../src/providers.js" +import { AnthropicMessages } from "../../src/protocols/anthropic-messages.js" +import { OpenResponses } from "../../src/protocols/open-responses.js" +import { Auth } from "../../src/route/auth.js" +import { compileRequest } from "../../src/route/client.js" +import { Endpoint } from "../../src/route/endpoint.js" +import { it } from "../lib/effect.js" + +describe("MiniMax provider", () => { + test("composes the baseline Messages and Responses protocols", () => { + const minimax = MiniMax.configure() + expect(minimax.model).toBe(minimax.messages) + expect(minimax.model("MiniMax-M3").route.body).toBe(AnthropicMessages.protocol.body) + expect(minimax.responses("MiniMax-M3").route.body).toBe(OpenResponses.protocol.body) + }) + + it.effect("owns API endpoints, provider identity and environment bearer authentication", () => + Effect.gen(function* () { + const minimax = MiniMax.configure() + for (const item of [ + { model: minimax.model("MiniMax-M3"), path: "/anthropic/v1/messages" }, + { model: minimax.chat("MiniMax-M3"), path: "/v1/chat/completions" }, + { model: minimax.responses("MiniMax-M3"), path: "/v1/responses" }, + ]) { + const request = LLM.request({ model: item.model, prompt: "Hello" }) + const compiled = yield* compileRequest(request) + expect(item.model.provider).toBe("minimax") + expect(item.model.route.providerMetadataKey).toBe("minimax") + const url = Endpoint.render(item.model.route.endpoint, { request, body: compiled.body }).toString() + expect(url).toBe(`https://api.minimax.io${item.path}`) + const headers = yield* item.model.route.auth.apply({ + request, + method: "POST", + url, + body: "{}", + headers: Headers.empty, + }) + expect(headers.authorization).toBe("Bearer fixture-key") + expect(headers["x-api-key"]).toBeUndefined() + } + }).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: { MINIMAX_API_KEY: "fixture-key" } })))), + ) + + it.effect("honors explicit auth and custom API bases", () => + Effect.gen(function* () { + const model = MiniMax.configure({ + baseURL: "https://gateway.example/anthropic/v1", + auth: Auth.header("x-api-key", "gateway-key"), + }).model("custom-model") + const request = LLM.request({ model, prompt: "Hello" }) + const compiled = yield* compileRequest(request) + expect(Endpoint.render(model.route.endpoint, { request, body: compiled.body }).toString()).toBe( + "https://gateway.example/anthropic/v1/messages", + ) + expect(model.route.headers?.({ request })).toEqual({ "anthropic-version": "2023-06-01" }) + const headers = yield* model.route.auth.apply({ + request, + method: "POST", + url: "https://gateway.example/anthropic/v1/messages", + body: "{}", + headers: Headers.empty, + }) + expect(headers["x-api-key"]).toBe("gateway-key") + expect(headers.authorization).toBeUndefined() + }), + ) + + it.effect("keeps thinking controls native to the selected API", () => + Effect.gen(function* () { + const minimax = MiniMax.configure({ apiKey: "fixture" }) + const messages = yield* compileRequest( + LLM.request({ model: minimax.model("MiniMax-M3"), providerOptions: { thinking: { type: "adaptive" } } }), + ) + expect(messages.body.thinking).toEqual({ type: "adaptive" }) + expect(messages.body.output_config).toBeUndefined() + const chat = yield* compileRequest( + LLM.request({ + model: minimax.chat("MiniMax-M3"), + generation: { maxTokens: 128 }, + providerOptions: { thinking: { type: "disabled" }, reasoningSplit: false }, + }), + ) + expect(chat.body).toMatchObject({ + thinking: { type: "disabled" }, + reasoning_split: false, + max_completion_tokens: 128, + stream_options: { include_usage: true }, + }) + expect(chat.body.store).toBeUndefined() + const responses = yield* compileRequest( + LLM.request({ model: minimax.responses("MiniMax-M3"), providerOptions: { reasoningEffort: "minimal" } }), + ) + expect(responses.body.reasoning).toEqual({ effort: "minimal" }) + expect(responses.body.include).toBeUndefined() + }), + ) +})