mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-30 14:14:20 +01:00
fix: max output tokens when setting budget thinking tokens (#2056)
Co-authored-by: rekram1-node <aidenpcline@gmail.com>
This commit is contained in:
@@ -98,4 +98,18 @@ export namespace ProviderTransform {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function maxOutputTokens(providerID: string, outputLimit: number, options: Record<string, any>): number {
|
||||||
|
if (providerID === "anthropic") {
|
||||||
|
const thinking = options["thinking"]
|
||||||
|
if (typeof thinking === "object" && thinking !== null) {
|
||||||
|
const type = thinking["type"]
|
||||||
|
const budgetTokens = thinking["budgetTokens"]
|
||||||
|
if (type === "enabled" && typeof budgetTokens === "number" && budgetTokens > 0) {
|
||||||
|
return outputLimit - budgetTokens
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outputLimit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1019,7 +1019,7 @@ export namespace Session {
|
|||||||
: undefined,
|
: undefined,
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
|
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
|
||||||
maxOutputTokens: outputLimit,
|
maxOutputTokens: ProviderTransform.maxOutputTokens(model.providerID, outputLimit, params.options),
|
||||||
abortSignal: abort.signal,
|
abortSignal: abort.signal,
|
||||||
stopWhen: async ({ steps }) => {
|
stopWhen: async ({ steps }) => {
|
||||||
if (steps.length >= 1000) {
|
if (steps.length >= 1000) {
|
||||||
|
|||||||
Reference in New Issue
Block a user