MCPcopy Create free account
hub / github.com/arctic-cli/interface / maxOutputTokens

Function maxOutputTokens

packages/arctic/src/provider/transform.ts:350–373  ·  view source on GitHub ↗
(
    npm: string,
    options: Record<string, any>,
    modelLimit: number,
    globalLimit: number,
  )

Source from the content-addressed store, hash-verified

348 }
349
350 export function maxOutputTokens(
351 npm: string,
352 options: Record<string, any>,
353 modelLimit: number,
354 globalLimit: number,
355 ): number {
356 const modelCap = modelLimit || globalLimit
357 const standardLimit = Math.min(modelCap, globalLimit)
358
359 if (npm === "@ai-sdk/anthropic") {
360 const thinking = options?.["thinking"]
361 const budgetTokens = typeof thinking?.["budgetTokens"] === "number" ? thinking["budgetTokens"] : 0
362 const enabled = thinking?.["type"] === "enabled"
363 if (enabled && budgetTokens > 0) {
364 // Return text tokens so that text + thinking <= model cap, preferring 32k text when possible.
365 if (budgetTokens + standardLimit <= modelCap) {
366 return standardLimit
367 }
368 return modelCap - budgetTokens
369 }
370 }
371
372 return standardLimit
373 }
374
375 export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema) {
376 /*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected