fix(plugin): migrate chat.params to maxOutputTokens for v1.4.0
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -123,10 +123,10 @@ describe("createChatParamsHandler", () => {
|
|||||||
setSessionPromptParams("ses_chat_params_temperature", {
|
setSessionPromptParams("ses_chat_params_temperature", {
|
||||||
temperature: 0.4,
|
temperature: 0.4,
|
||||||
topP: 0.7,
|
topP: 0.7,
|
||||||
|
maxOutputTokens: 4096,
|
||||||
options: {
|
options: {
|
||||||
reasoningEffort: "high",
|
reasoningEffort: "high",
|
||||||
thinking: { type: "disabled" },
|
thinking: { type: "disabled" },
|
||||||
maxTokens: 4096,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -157,31 +157,29 @@ describe("createChatParamsHandler", () => {
|
|||||||
temperature: 0.4,
|
temperature: 0.4,
|
||||||
topP: 0.7,
|
topP: 0.7,
|
||||||
topK: 1,
|
topK: 1,
|
||||||
|
maxOutputTokens: 4096,
|
||||||
options: {
|
options: {
|
||||||
existing: true,
|
existing: true,
|
||||||
reasoningEffort: "high",
|
reasoningEffort: "high",
|
||||||
thinking: { type: "disabled" },
|
thinking: { type: "disabled" },
|
||||||
maxTokens: 4096,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
expect(getSessionPromptParams("ses_chat_params_temperature")).toEqual({
|
expect(getSessionPromptParams("ses_chat_params_temperature")).toEqual({
|
||||||
temperature: 0.4,
|
temperature: 0.4,
|
||||||
topP: 0.7,
|
topP: 0.7,
|
||||||
|
maxOutputTokens: 4096,
|
||||||
options: {
|
options: {
|
||||||
reasoningEffort: "high",
|
reasoningEffort: "high",
|
||||||
thinking: { type: "disabled" },
|
thinking: { type: "disabled" },
|
||||||
maxTokens: 4096,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("drops gpt-5.4 temperature and clamps maxTokens from bundled model capabilities", async () => {
|
test("drops gpt-5.4 temperature and clamps maxOutputTokens from bundled model capabilities", async () => {
|
||||||
//#given
|
//#given
|
||||||
setSessionPromptParams("ses_chat_params_temperature", {
|
setSessionPromptParams("ses_chat_params_temperature", {
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
options: {
|
maxOutputTokens: 200_000,
|
||||||
maxTokens: 200_000,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = createChatParamsHandler({
|
const handler = createChatParamsHandler({
|
||||||
@@ -210,9 +208,8 @@ describe("createChatParamsHandler", () => {
|
|||||||
expect(output).toEqual({
|
expect(output).toEqual({
|
||||||
topP: 1,
|
topP: 1,
|
||||||
topK: 1,
|
topK: 1,
|
||||||
options: {
|
maxOutputTokens: 128_000,
|
||||||
maxTokens: 128_000,
|
options: {},
|
||||||
},
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type ChatParamsOutput = {
|
|||||||
temperature?: number
|
temperature?: number
|
||||||
topP?: number
|
topP?: number
|
||||||
topK?: number
|
topK?: number
|
||||||
|
maxOutputTokens?: number
|
||||||
options: Record<string, unknown>
|
options: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +100,9 @@ export function createChatParamsHandler(args: {
|
|||||||
if (storedPromptParams.topP !== undefined) {
|
if (storedPromptParams.topP !== undefined) {
|
||||||
output.topP = storedPromptParams.topP
|
output.topP = storedPromptParams.topP
|
||||||
}
|
}
|
||||||
|
if (storedPromptParams.maxOutputTokens !== undefined) {
|
||||||
|
output.maxOutputTokens = storedPromptParams.maxOutputTokens
|
||||||
|
}
|
||||||
if (storedPromptParams.options) {
|
if (storedPromptParams.options) {
|
||||||
output.options = {
|
output.options = {
|
||||||
...output.options,
|
...output.options,
|
||||||
@@ -124,7 +128,7 @@ export function createChatParamsHandler(args: {
|
|||||||
: undefined,
|
: undefined,
|
||||||
temperature: typeof output.temperature === "number" ? output.temperature : undefined,
|
temperature: typeof output.temperature === "number" ? output.temperature : undefined,
|
||||||
topP: typeof output.topP === "number" ? output.topP : undefined,
|
topP: typeof output.topP === "number" ? output.topP : undefined,
|
||||||
maxTokens: typeof output.options.maxTokens === "number" ? output.options.maxTokens : undefined,
|
maxTokens: typeof output.maxOutputTokens === "number" ? output.maxOutputTokens : undefined,
|
||||||
thinking: isRecord(output.options.thinking) ? output.options.thinking : undefined,
|
thinking: isRecord(output.options.thinking) ? output.options.thinking : undefined,
|
||||||
},
|
},
|
||||||
capabilities,
|
capabilities,
|
||||||
@@ -163,9 +167,9 @@ export function createChatParamsHandler(args: {
|
|||||||
|
|
||||||
if ("maxTokens" in compatibility) {
|
if ("maxTokens" in compatibility) {
|
||||||
if (compatibility.maxTokens !== undefined) {
|
if (compatibility.maxTokens !== undefined) {
|
||||||
output.options.maxTokens = compatibility.maxTokens
|
output.maxOutputTokens = compatibility.maxTokens
|
||||||
} else {
|
} else {
|
||||||
delete output.options.maxTokens
|
delete output.maxOutputTokens
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export type SessionPromptParams = {
|
export type SessionPromptParams = {
|
||||||
temperature?: number
|
temperature?: number
|
||||||
topP?: number
|
topP?: number
|
||||||
|
maxOutputTokens?: number
|
||||||
options?: Record<string, unknown>
|
options?: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ export function setSessionPromptParams(sessionID: string, params: SessionPromptP
|
|||||||
sessionPromptParams.set(sessionID, {
|
sessionPromptParams.set(sessionID, {
|
||||||
...(params.temperature !== undefined ? { temperature: params.temperature } : {}),
|
...(params.temperature !== undefined ? { temperature: params.temperature } : {}),
|
||||||
...(params.topP !== undefined ? { topP: params.topP } : {}),
|
...(params.topP !== undefined ? { topP: params.topP } : {}),
|
||||||
|
...(params.maxOutputTokens !== undefined ? { maxOutputTokens: params.maxOutputTokens } : {}),
|
||||||
...(params.options !== undefined ? { options: { ...params.options } } : {}),
|
...(params.options !== undefined ? { options: { ...params.options } } : {}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -21,6 +23,7 @@ export function getSessionPromptParams(sessionID: string): SessionPromptParams |
|
|||||||
return {
|
return {
|
||||||
...(params.temperature !== undefined ? { temperature: params.temperature } : {}),
|
...(params.temperature !== undefined ? { temperature: params.temperature } : {}),
|
||||||
...(params.topP !== undefined ? { topP: params.topP } : {}),
|
...(params.topP !== undefined ? { topP: params.topP } : {}),
|
||||||
|
...(params.maxOutputTokens !== undefined ? { maxOutputTokens: params.maxOutputTokens } : {}),
|
||||||
...(params.options !== undefined ? { options: { ...params.options } } : {}),
|
...(params.options !== undefined ? { options: { ...params.options } } : {}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user