mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:00:42 +00:00
fix(github-copilot): preserve reasoning IDs for Copilot Codex models (#71684)
* fix(github-copilot): preserve all reasoning IDs and add gpt-5.3-codex support
The existing guard (8fd15ed0e5) only skipped rewriting reasoning item IDs
when encrypted_content was a non-null string. When gpt-5.3-codex is used
via GitHub Copilot, the model falls through to the forward-compat catch-all
with reasoning:false, so encrypted_content is never requested and arrives
as null — bypassing the guard and causing a rewrite. Copilot validates
reasoning item IDs server-side regardless of whether the client includes
encrypted_content, so the rewritten id triggers the 400 error.
Two changes:
1. connection-bound-ids.ts: skip ALL reasoning items unconditionally.
Reasoning items always reference server-side state bound to their
original ID; rewriting any of them breaks Copilot's lookup.
2. models.ts + index.ts: extend the forward-compat cloning logic to
cover gpt-5.3-codex (adds it to the template-target set and to
CODEX_TEMPLATE_MODEL_IDS so it can also serve as a template source
for gpt-5.4). Adds gpt-5.3-codex to COPILOT_XHIGH_MODEL_IDS for
the thinking profile.
Thanks @InvalidPandaa.
* docs(github-copilot): clarify gpt-5.3-codex is a no-op template for itself
https://claude.ai/code/session_01EAFmq4WyKkiUkVAqRXp4Bm
* fix(github-copilot): remove dead reasoning prefix branch in deriveReplacementId
https://claude.ai/code/session_01EAFmq4WyKkiUkVAqRXp4Bm
* fix(github-copilot): align reasoning id replay tests
* test(plugin-sdk): use cjs sidecar for require fast path
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -6,12 +6,18 @@ import { normalizeModelCompat } from "openclaw/plugin-sdk/provider-model-shared"
|
||||
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
||||
export const PROVIDER_ID = "github-copilot";
|
||||
const CODEX_GPT_54_MODEL_ID = "gpt-5.4";
|
||||
const CODEX_TEMPLATE_MODEL_IDS = ["gpt-5.2-codex"] as const;
|
||||
const CODEX_FORWARD_COMPAT_TARGET_IDS = new Set(["gpt-5.4", "gpt-5.3-codex"]);
|
||||
// gpt-5.3-codex is only a useful template when gpt-5.4 is the target; it is
|
||||
// always a registry miss (and therefore skipped) when it is the target itself.
|
||||
const CODEX_TEMPLATE_MODEL_IDS = ["gpt-5.3-codex", "gpt-5.2-codex"] as const;
|
||||
|
||||
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
||||
const DEFAULT_MAX_TOKENS = 8192;
|
||||
|
||||
function isCopilotCodexModelId(modelId: string): boolean {
|
||||
return /(?:^|[-_.])codex(?:$|[-_.])/.test(modelId);
|
||||
}
|
||||
|
||||
export function resolveCopilotTransportApi(
|
||||
modelId: string,
|
||||
): "anthropic-messages" | "openai-responses" {
|
||||
@@ -35,9 +41,9 @@ export function resolveCopilotForwardCompatModel(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// For gpt-5.4 specifically, clone from the gpt-5.2-codex template
|
||||
// to preserve any special settings the registry has for codex models.
|
||||
if (lowerModelId === CODEX_GPT_54_MODEL_ID) {
|
||||
// For gpt-5.4 and gpt-5.3-codex, clone from a registered codex template
|
||||
// to inherit the correct reasoning and capability flags.
|
||||
if (CODEX_FORWARD_COMPAT_TARGET_IDS.has(lowerModelId)) {
|
||||
for (const templateId of CODEX_TEMPLATE_MODEL_IDS) {
|
||||
const template = ctx.modelRegistry.find(
|
||||
PROVIDER_ID,
|
||||
@@ -60,7 +66,7 @@ export function resolveCopilotForwardCompatModel(
|
||||
// model isn't available on the user's plan. This lets new models be used
|
||||
// by simply adding them to agents.defaults.models in openclaw.json — no
|
||||
// code change required.
|
||||
const reasoning = /^o[13](\b|$)/.test(lowerModelId);
|
||||
const reasoning = /^o[13](\b|$)/.test(lowerModelId) || isCopilotCodexModelId(lowerModelId);
|
||||
return normalizeModelCompat({
|
||||
id: trimmedModelId,
|
||||
name: trimmedModelId,
|
||||
|
||||
Reference in New Issue
Block a user