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): scope remembered reasoning steps to the active account

fmfsaisaibba1970320c0
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 09bb311b06..a39ec6f666 100644
--- a/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
+++ b/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
@@ -4242,6 +4242,27 @@ describe('utility one-shot candidates', () => {
expect(bodyOf(0)).toMatchObject({ thinking: { type: 'disabled' } });
});
+ it('keeps remembered steps per account scope', async () => {
+ ownerState.key = 'owner-a';
+ await rememberLow('https://custom.example/v1', ['low', 'medium']);
+
+ // Account B: same provider id, model, address and route revision.
+ ownerState.key = 'owner-b';
+ fetchMock.mockResolvedValueOnce(chatOk('account-b') as never);
+ await expect(request()).resolves.toMatchObject({ ok: true, text: 'account-b' });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(bodyOf(0)).toMatchObject({ thinking: { type: 'disabled' } });
+
+ // Back to the same account A scope: its remembered `low` is still used.
+ fetchMock.mockClear();
+ ownerState.key = 'owner-a';
+ fetchMock.mockResolvedValueOnce(chatOk('account-a') as never);
+ await expect(request()).resolves.toMatchObject({ ok: true, text: 'account-a' });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(bodyOf(0)).toMatchObject({ reasoning_effort: 'low' });
+ expect(bodyOf(0)).not.toHaveProperty('thinking');
+ });
+
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);
diff --git a/apps/desktop/src/main/utility-model/oneShotCandidates.ts b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
index 9cc18f8edd..f247ab70d8 100644
--- a/apps/desktop/src/main/utility-model/oneShotCandidates.ts
+++ b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
@@ -2116,6 +2116,7 @@ function utilityRequestPlan(input: {
wire: input.wire,
mode,
routeRevision: getProviderRouteCredentialRevision(input.providerId),
+ ownerScope: activeOwnerScopeKey(),
})
: undefined,
compat: {
diff --git a/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts b/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
index f7388bcf76..5d1d4d9954 100644
--- a/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
+++ b/apps/desktop/src/main/utility-model/utilityReasoningPlan.ts
@@ -233,9 +233,22 @@ export function utilityReasoningMemoryKey(parts: {
* 同 id 删除重建:这些变化不体现在地址和档位上,但旧路由记住的写法不该沿用。
*/
routeRevision: number;
+ /**
+ * 当前账号作用域:自定义供应商的密钥按账号分别保存,切换账号不经过路由代次,
+ * 另一个账号同 id、同地址的路由不能沿用这里记住的写法。
+ */
+ ownerScope: string;
}): 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, parts.routeRevision]);
+ return JSON.stringify([
+ parts.providerId,
+ parts.agentKind,
+ parts.model,
+ parts.wire,
+ mode,
+ parts.routeRevision,
+ parts.ownerScope,
+ ]);
}
/**