Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/types/src/providers/groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type GroqModelId =
| "qwen-qwq-32b"
| "qwen/qwen3-32b"
| "deepseek-r1-distill-llama-70b"
| "moonshotai/kimi-k2-instruct"

export const groqDefaultModelId: GroqModelId = "llama-3.3-70b-versatile" // Defaulting to Llama3 70B Versatile

Expand Down Expand Up @@ -87,4 +88,13 @@ export const groqModels = {
outputPrice: 0.99,
description: "DeepSeek R1 Distill Llama 70B model, 128K context.",
},
"moonshotai/kimi-k2-instruct": {
maxTokens: 131072,
contextWindow: 131072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 1.0,
outputPrice: 3.0,
description: "Moonshot AI Kimi K2 Instruct 1T model, 128K context.",
},
} as const satisfies Record<string, ModelInfo>
13 changes: 6 additions & 7 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { ClineAskResponse } from "../../shared/WebviewMessage"
import { defaultModeSlug } from "../../shared/modes"
import { DiffStrategy } from "../../shared/tools"
import { EXPERIMENT_IDS, experiments } from "../../shared/experiments"
import { getModelMaxOutputTokens } from "../../shared/api"

// services
import { UrlContentFetcher } from "../../services/browser/UrlContentFetcher"
Expand Down Expand Up @@ -1716,15 +1717,13 @@ export class Task extends EventEmitter<ClineEvents> {
const { contextTokens } = this.getTokenUsage()

if (contextTokens) {
// Default max tokens value for thinking models when no specific
// value is set.
const DEFAULT_THINKING_MODEL_MAX_TOKENS = 16_384

const modelInfo = this.api.getModel().info

const maxTokens = modelInfo.supportsReasoningBudget
? this.apiConfiguration.modelMaxTokens || DEFAULT_THINKING_MODEL_MAX_TOKENS
: modelInfo.maxTokens
const maxTokens = getModelMaxOutputTokens({
modelId: this.api.getModel().id,
model: modelInfo,
settings: this.apiConfiguration,
})

const contextWindow = modelInfo.contextWindow

Expand Down
9 changes: 6 additions & 3 deletions src/shared/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ export const getModelMaxOutputTokens = ({
return ANTHROPIC_DEFAULT_MAX_TOKENS
}

// If maxTokens is 0 or undefined, fall back to 20% of context window
// This matches the sliding window logic
return model.maxTokens || Math.ceil(model.contextWindow * 0.2)
// If maxTokens is 0 or undefined or the full context window, fall back to 20% of context window
if (model.maxTokens && model.maxTokens !== model.contextWindow) {
return model.maxTokens
} else {
return Math.ceil(model.contextWindow * 0.2)
}
}

// GetModelsOptions
Expand Down