Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(codex): preserve raw same-provider thread identity

Cindycf875471fb5c
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
index 7d3ec852f1..5e2078d376 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
@@ -155,6 +155,20 @@ describe('shouldCloseSessionForCredentialSwitch codex mode', () => {
expect(shouldCloseSessionForCredentialSwitch(input)).toBe(true);
});
+ it('keeps a raw provider identity for same-provider model changes', () => {
+ const input = {
+ agentKind: 'codex',
+ currentProviderId: 'openai',
+ nextProviderId: 'openai',
+ currentModel: 'gpt-5.4',
+ nextModel: 'gpt-5.5',
+ currentCodexProxyActive: true,
+ currentCodexThreadModelProviderId: 'openai',
+ } as const;
+ expect(isCodexThreadModelProviderIdentityMismatch(input)).toBe(false);
+ expect(shouldCloseSessionForCredentialSwitch(input)).toBe(false);
+ });
+
it('still closes a gateway Codex session when switching to OAuth on a proxy-active host', () => {
expect(shouldCloseSessionForCredentialSwitch({
agentKind: 'codex',
diff --git a/apps/desktop/src/main/maker-host/codex-credential-switch.ts b/apps/desktop/src/main/maker-host/codex-credential-switch.ts
index b3d988305b..830c95c422 100644
--- a/apps/desktop/src/main/maker-host/codex-credential-switch.ts
+++ b/apps/desktop/src/main/maker-host/codex-credential-switch.ts
@@ -210,6 +210,13 @@ export function isCodexThreadModelProviderIdentityMismatch(
const actualIsAppliedCustomProviderIdentity = isAppliedCodexCustomProviderIdentity(
actualThreadModelProviderId,
);
+ // Older app-server versions may report the logical provider id directly
+ // (for example `openai`) instead of Cindy's materialized `cindy_openai`
+ // alias. When the target logical route is the same provider, that raw id is
+ // a matching identity; only a route crossing needs a rebuild.
+ const actualMatchesTargetLogicalProvider =
+ actualThreadModelProviderId !== null &&
+ actualThreadModelProviderId === nextProviderId;
// The app-server may report a provider id that is not one of Cindy's
// materialized identities (for example `openai`, Azure, or a custom provider).
// It is still a sticky thread identity. Treating those ids as unknown lets a
@@ -218,6 +225,7 @@ export function isCodexThreadModelProviderIdentityMismatch(
// A missing id is the only case where there is no identity to compare.
return (
!actualIsAppliedCustomProviderIdentity &&
+ !actualMatchesTargetLogicalProvider &&
actualThreadModelProviderId !== null &&
expectedThreadModelProviderId !== null &&
actualThreadModelProviderId !== expectedThreadModelProviderId