tweak: move the max token exclusions to plugins @rekram1-node (#21225)
parent
40e4cd27a1
commit
48c1b6b338
|
|
@ -599,5 +599,10 @@ export async function CodexAuthPlugin(input: PluginInput): Promise<Hooks> {
|
||||||
output.headers["User-Agent"] = `opencode/${Installation.VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`
|
output.headers["User-Agent"] = `opencode/${Installation.VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`
|
||||||
output.headers.session_id = input.sessionID
|
output.headers.session_id = input.sessionID
|
||||||
},
|
},
|
||||||
|
"chat.params": async (input, output) => {
|
||||||
|
if (input.model.providerID !== "openai") return
|
||||||
|
// Match codex cli
|
||||||
|
output.maxOutputTokens = undefined
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,14 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
"chat.params": async (incoming, output) => {
|
||||||
|
if (!incoming.model.providerID.includes("github-copilot")) return
|
||||||
|
|
||||||
|
// Match github copilot cli, omit maxOutputTokens for gpt models
|
||||||
|
if (incoming.model.api.id.includes("gpt")) {
|
||||||
|
output.maxOutputTokens = undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
"chat.headers": async (incoming, output) => {
|
"chat.headers": async (incoming, output) => {
|
||||||
if (!incoming.model.providerID.includes("github-copilot")) return
|
if (!incoming.model.providerID.includes("github-copilot")) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,11 +160,6 @@ export namespace LLM {
|
||||||
...input.messages,
|
...input.messages,
|
||||||
]
|
]
|
||||||
|
|
||||||
const maxOutputTokens =
|
|
||||||
isOpenaiOauth || provider.id.includes("github-copilot")
|
|
||||||
? undefined
|
|
||||||
: ProviderTransform.maxOutputTokens(input.model)
|
|
||||||
|
|
||||||
const params = await Plugin.trigger(
|
const params = await Plugin.trigger(
|
||||||
"chat.params",
|
"chat.params",
|
||||||
{
|
{
|
||||||
|
|
@ -180,7 +175,7 @@ export namespace LLM {
|
||||||
: undefined,
|
: undefined,
|
||||||
topP: input.agent.topP ?? ProviderTransform.topP(input.model),
|
topP: input.agent.topP ?? ProviderTransform.topP(input.model),
|
||||||
topK: ProviderTransform.topK(input.model),
|
topK: ProviderTransform.topK(input.model),
|
||||||
maxOutputTokens,
|
maxOutputTokens: ProviderTransform.maxOutputTokens(input.model),
|
||||||
options,
|
options,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -743,8 +743,7 @@ describe("session.llm.stream", () => {
|
||||||
expect((body.reasoning as { effort?: string } | undefined)?.effort).toBe("high")
|
expect((body.reasoning as { effort?: string } | undefined)?.effort).toBe("high")
|
||||||
|
|
||||||
const maxTokens = body.max_output_tokens as number | undefined
|
const maxTokens = body.max_output_tokens as number | undefined
|
||||||
const expectedMaxTokens = ProviderTransform.maxOutputTokens(resolved)
|
expect(maxTokens).toBe(undefined) // match codex cli behavior
|
||||||
expect(maxTokens).toBe(expectedMaxTokens)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue