{"record":{"id":"e6ce73b59148426d","repo":"ruvnet/ruflo","slug":"maxtokens-exceeds-limit-of-this-config-maxtokens","errorCode":null,"errorMessage":"maxTokens exceeds limit of ${this.config.maxTokensLimit}","messagePattern":"maxTokens exceeds limit of (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/mcp/src/sampling.ts","lineNumber":229,"sourceCode":"  } {\n    return {\n      requestCount: this.requestCount,\n      totalTokens: this.totalTokens,\n      providerCount: this.providers.size,\n      defaultProvider: this.defaultProvider,\n    };\n  }\n\n  /**\n   * Validate sampling request\n   */\n  private validateRequest(request: CreateMessageRequest): void {\n    if (!request.messages || request.messages.length === 0) {\n      throw new Error('Messages are required');\n    }\n\n    if (request.maxTokens > this.config.maxTokensLimit) {\n      throw new Error(`maxTokens exceeds limit of ${this.config.maxTokensLimit}`);\n    }\n\n    if (request.temperature !== undefined && (request.temperature < 0 || request.temperature > 2)) {\n      throw new Error('Temperature must be between 0 and 2');\n    }\n  }\n\n  /**\n   * Select provider based on preferences\n   */\n  private selectProvider(preferences?: ModelPreferences): LLMProvider | undefined {\n    // If hints provided, try to find matching provider\n    if (preferences?.hints) {\n      for (const hint of preferences.hints) {\n        if (hint.name && this.providers.has(hint.name)) {\n          return this.providers.get(hint.name);\n        }\n      }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/mcp/src/sampling.ts#L211-L247","documentation":"Request validation in SamplingManager: the requested maxTokens exceeds the server's configured maxTokensLimit. The refusal happens up front so providers never receive an over-budget completion request; lower maxTokens or raise the server limit.","triggerScenarios":"A sampling request specifies maxTokens larger than the server's configured maxTokensLimit.","commonSituations":"Client requests a very large completion, or the server's maxTokensLimit is set lower than the client's default.","solutions":["Reduce maxTokens in the request to a value at or below the server's maxTokensLimit.","Raise maxTokensLimit in the sampling configuration if the larger budget is legitimate.","Clamp maxTokens to the limit instead of rejecting when truncation is acceptable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}