#38972·n8n

Agents: MiniMax provider silently caps output at 4096 tokens (no maxOutputTokens default for minimax/, no config override)

Author: JonathanLeon22Created Sep 17, 2026Updated Sep 17, 2026
Labelsstatus:in-linear

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):

  1. @n8n/agents/dist/runtime/model/model-factory.js builds the minimax provider with @ai-sdk/minimax, which wraps AnthropicLanguageModel and talks to MiniMax's Anthropic-compatible endpoint (https://api.minimax.io/anthropic/v1). The Anthropic Messages API requires max_tokens on every request.
  2. @n8n/agents/dist/runtime/model/provider-quirks.js only 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;
    }
    
  3. With maxOutputTokens undefined, @ai-sdk/anthropic (getModelCapabilities) treats MiniMax-M3 as an unknown model and falls back to maxOutputTokens: 4096, so every request is sent with max_tokens: 4096 (plus a compatibility warning that is not surfaced to the user).
  4. There is no way to override it: the Agent JSON config schema (reasoning, promptCaching, webSearch, toolCallConcurrency, maxIterations) does not accept maxOutputTokens, and the runtime only passes execOptions.maxOutputTokens internally.

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

  1. Create a minimaxApi credential and an Agent with model minimax/MiniMax-M3, reasoning: high, no tools needed.
  2. Ask it for a long structured answer (e.g. "write a 6000-word incident report with 9 sections").
  3. Run it via Message an Agent (or the agent chat).
  4. The execution fails with "The model reached its output token limit before it returned an answer"; agent_execution.completionTokens shows the run stopped around 4k visible output tokens.
  5. Same agent with openrouter/minimax/minimax-m3 completes 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