Agents: MiniMax provider silently caps output at 4096 tokens (no maxOutputTokens default for minimax/, no config override)
Bug Description
n8n Agents (the first-class agents module) configured with the MiniMax provider (minimax/MiniMax-M3, credential type minimaxApi) fail with
The model reached its output token limit before it returned an answer. Reduce the request scope or use another model.
whenever a single model turn needs more than 4096 output tokens (long final answer, or reasoning + answer). The same agent, same prompt and same model through OpenRouter (openrouter/minimax/minimax-m3) completes normally, because that path does not send max_tokens.
Root cause (traced in the installed code):
@n8n/agents/dist/runtime/model/model-factory.jsbuilds theminimaxprovider with@ai-sdk/minimax, which wrapsAnthropicLanguageModeland talks to MiniMax's Anthropic-compatible endpoint (https://api.minimax.io/anthropic/v1). The Anthropic Messages API requiresmax_tokenson every request.@n8n/agents/dist/runtime/model/provider-quirks.jsonly sets a default output limit for Kimi:function resolveDefaultMaxOutputTokens(modelId) { if (modelId.toLowerCase().includes('kimi-k3')) { return exports.HIGH_REASONING_DEFAULT_MAX_OUTPUT_TOKENS; // 65_536 } return undefined; }- With
maxOutputTokensundefined,@ai-sdk/anthropic(getModelCapabilities) treatsMiniMax-M3as an unknown model and falls back tomaxOutputTokens: 4096, so every request is sent withmax_tokens: 4096(plus acompatibilitywarning that is not surfaced to the user). - There is no way to override it: the Agent JSON
configschema (reasoning,promptCaching,webSearch,toolCallConcurrency,maxIterations) does not acceptmaxOutputTokens, and the runtime only passesexecOptions.maxOutputTokensinternally.
MiniMax-M3 supports up to 512k output tokens, so 4096 is far below the model's capability and below what a reasoning model needs for a normal long answer.
Measured on our instance (SOC triage agents, 4 clients): over the first hour after switching agents from OpenRouter to the direct MiniMax provider, 4 of 56 agent executions (7 %) failed with the error above at 7.3k–11.4k completion tokens; 0 of 209 executions failed that way on OpenRouter the day before. A local patch adding MiniMax to resolveDefaultMaxOutputTokens (131072) removed the failures (0 of 21+ executions since).
Suggested fix: give the MiniMax provider a sane default output limit in resolveDefaultMaxOutputTokens (e.g. the same 65_536 used for Kimi, or higher), and/or expose maxOutputTokens in the Agent config so operators can set it per agent. Ideally also surface the AI SDK compatibility warning ("The model ... is unknown. The max output tokens have been limited to 4096") in the execution error, so the cause is visible.
To Reproduce
- Create a
minimaxApicredential and an Agent with modelminimax/MiniMax-M3,reasoning: high, no tools needed. - Ask it for a long structured answer (e.g. "write a 6000-word incident report with 9 sections").
- Run it via
Message an Agent(or the agent chat). - The execution fails with "The model reached its output token limit before it returned an answer";
agent_execution.completionTokensshows the run stopped around 4k visible output tokens. - Same agent with
openrouter/minimax/minimax-m3completes the same request.
Expected behavior
The MiniMax provider should not silently cap output at 4096 tokens. Either a realistic default (resolveDefaultMaxOutputTokens for minimax/) or a configurable maxOutputTokens on the Agent, and the underlying "model is unknown, limited to 4096" warning should be visible.
Debug Info
n8n: 2.39.6 (docker image n8nio/n8n:latest), @n8n/agents 0.24.4, @ai-sdk/minimax 3.0.15, @ai-sdk/anthropic 4.0.36
Execution mode: queue (1 main + 4 workers), Database: PostgreSQL 16, Redis 7
Agents module enabled (N8N_ENABLED_MODULES=agents)
Agent error text: {"code":"length"} -> "The model reached its output token limit before it returned an answer. Reduce the request scope or use another model."
Workaround in place: bind-mount over @n8n/agents/dist/runtime/model/provider-quirks.js with
if (modelId.toLowerCase().startsWith('minimax/')) return 131072;
Operating System
Docker (Alpine-based official image) on Ubuntu Server host
n8n Version
2.39.6
Node.js Version
v26.7.0 (bundled in the official image)
Database
PostgreSQL
Execution mode
queue
Hosting
self hosted
Source: n8n-io/n8n