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(utility-model): invalidate remembered reasoning steps when the provider route changes

fmfsaisaib4d23e7e8d95
diff --git a/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts b/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
index ffa95cc7e7..09bb311b06 100644
--- a/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
+++ b/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
@@ -4231,6 +4231,27 @@ describe('utility one-shot candidates', () => {
expect(bodyOf(0)).toMatchObject({ thinking: { type: 'disabled' } });
});
+ it('does not reuse a remembered step after the provider route revision changes', async () => {
+ await rememberLow('https://custom.example/v1', ['low', 'medium']);
+ // Same address and tiers; only headers / key changed, which bumps the revision.
+ providerRouteCredentialRevision.mockReturnValue(1);
+ fetchMock.mockResolvedValueOnce(chatOk('fresh') as never);
+
+ await expect(request()).resolves.toMatchObject({ ok: true, text: 'fresh' });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(bodyOf(0)).toMatchObject({ thinking: { type: 'disabled' } });
+ });
+
+ it('keeps a remembered step while the provider route revision is unchanged', async () => {
+ await rememberLow('https://custom.example/v1', ['low', 'medium']);
+ fetchMock.mockResolvedValueOnce(chatOk('reused') as never);
+
+ await expect(request()).resolves.toMatchObject({ ok: true, text: 'reused' });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(bodyOf(0)).toMatchObject({ reasoning_effort: 'low' });
+ expect(bodyOf(0)).not.toHaveProperty('thinking');
+ });
+
it('does not reuse a remembered step after only the query string changes', async () => {
await rememberLow('https://custom.example/v1?tenant=a', ['low', 'medium']);
activeCatalog.mockReturnValue(customChatCatalog({
diff --git a/apps/desktop/src/main/utility-model/oneShotCandidates.ts b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
index a68f65f1ca..9cc18f8edd 100644
--- a/apps/desktop/src/main/utility-model/oneShotCandidates.ts
+++ b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
@@ -2115,6 +2115,7 @@ function utilityRequestPlan(input: {
model: input.model,
wire: input.wire,
mode,
+ routeRevision: getProviderRouteCredentialRevision(input.providerId),
})
: undefined,
compat: {
diff --git a/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts b/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
index c784bcabd9..f7388bcf76 100644
--- a/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
+++ b/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
@@ -228,9 +228,14 @@ export function utilityReasoningMemoryKey(parts: {
model: string;
wire: UtilityProviderWire;
mode: UtilityReasoningMode;
+ /**
+ * 供应商路由代次(provider-route 的非敏感整数),覆盖请求头、凭证、能力的修改与
+ * 同 id 删除重建:这些变化不体现在地址和档位上,但旧路由记住的写法不该沿用。
+ */
+ routeRevision: number;
}): string {
const mode = parts.mode.kind === 'ladder' ? 'ladder' : `fixed:${utilityReasoningRungKey(parts.mode.rung)}`;
- return JSON.stringify([parts.providerId, parts.agentKind, parts.model, parts.wire, mode]);
+ return JSON.stringify([parts.providerId, parts.agentKind, parts.model, parts.wire, mode, parts.routeRevision]);
}
/**