mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(ai): keep the prompt cache when changing thinking level on OpenAI GPT-6 (#10930)
With an API key, GPT-6 models on the openai provider now keep reasoning.effort fixed and send the thinking level as configuration_update input items. Each reply records its level, so earlier items are rebuilt unchanged on every request. Controlled by compat.supportsMidConvoEffort; skipped for Sign in with ChatGPT and thinking off. closes #10853
This commit is contained in:
parent
195120a915
commit
60ac3bcc3b
8 changed files with 307 additions and 13 deletions
|
|
@ -388,6 +388,9 @@ const OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = new Set([
|
|||
"gpt-6-luna",
|
||||
"gpt-6.1-sol",
|
||||
]);
|
||||
// OpenAI documents configuration_update for the GPT-6 family.
|
||||
// https://developers.openai.com/api/docs/guides/reasoning
|
||||
const OPENAI_MID_CONVO_EFFORT_MODEL_IDS = new Set(["gpt-6-astra", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-sol"]);
|
||||
const OPENAI_LONG_CONTEXT_INPUT_THRESHOLD = 272000;
|
||||
const OPENAI_SHORT_CONTEXT_CAPPED_MODEL_IDS = new Set([
|
||||
"gpt-5.4",
|
||||
|
|
@ -976,6 +979,18 @@ function applyOpenAIExplicitPromptCacheMetadata(model: Model<Api>): void {
|
|||
};
|
||||
}
|
||||
|
||||
// GPT-6 models accept `configuration_update` input items that change the reasoning effort
|
||||
// without changing the cached prompt prefix. Not enabled for openai-codex (Codex CLI keeps it
|
||||
// behind a flag that is off by default) or proxies.
|
||||
function applyOpenAIMidConvoEffortMetadata(model: Model<Api>): void {
|
||||
if (model.provider !== "openai" || model.api !== "openai-responses") return;
|
||||
if (!OPENAI_MID_CONVO_EFFORT_MODEL_IDS.has(model.id)) return;
|
||||
model.compat = {
|
||||
...(model.compat as OpenAIResponsesCompat | undefined),
|
||||
supportsMidConvoEffort: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Anthropic ephemeral entries have a hard five-minute lifetime; `ttl: "1h"`
|
||||
// extends it to one hour. Only direct Anthropic is annotated so cache warming
|
||||
// does not assume equivalent behavior through proxies.
|
||||
|
|
@ -3348,6 +3363,7 @@ async function generateModels() {
|
|||
applyOpenAICompletionsTranscriptMetadata(model);
|
||||
applyOpenAIResponsesTranscriptMetadata(model);
|
||||
applyOpenAIExplicitPromptCacheMetadata(model);
|
||||
applyOpenAIMidConvoEffortMetadata(model);
|
||||
applyPromptCacheMetadata(model);
|
||||
applyImageInputMetadata(model);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue