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。

test(utility-model): lock the custom Auto-review fallback's reasoning parameters

fmfsaisaic1a5e59f34c2
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 e68254b4b8..bfa4235439 100644
--- a/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
+++ b/apps/desktop/src/main/utility-model/__tests__/oneShotCandidates.test.ts
@@ -316,6 +316,47 @@ describe('utility one-shot candidates', () => {
expect(body).not.toHaveProperty('tools');
});
+ it('turns Chat thinking off on the first fallback request', async () => {
+ fetchMock.mockResolvedValueOnce(response('{"verdict":"allow"}'));
+
+ await expect(createCustomAutoReviewFallback()!(prompt, options)).resolves.toMatchObject({ ok: true });
+ expect(JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body))).toEqual({
+ model: 'small',
+ max_tokens: 384,
+ thinking: { type: 'disabled' },
+ reasoning_effort: 'minimal',
+ messages: [
+ { role: 'system', content: 'Review policy' },
+ { role: 'user', content: '<review_input>\nuser request and action\n</review_input>' },
+ ],
+ });
+ });
+
+ it('starts a Responses fallback at the lowest catalog effort, not a fixed low', async () => {
+ chainState.refs = ['cat:review-r:codex:graded'];
+ activeCatalog.mockReturnValue({ providers: [{
+ id: 'review-r', name: 'review-r', source: 'user', agents: ['codex'],
+ auth: { method: 'apiKey' },
+ routing: { codex: {
+ upstream: 'https://review-r.example/v1',
+ wireProtocol: 'openai-responses',
+ authStrategy: 'api-key-header',
+ } },
+ models: { codex: [{ id: 'graded', name: 'Graded', contextWindow: 100_000, efforts: ['high', 'medium'] }] },
+ }] } as never);
+ fetchMock.mockResolvedValueOnce({
+ ok: true, text: async () => JSON.stringify({ output_text: '{"verdict":"ask"}' }),
+ } as never);
+
+ await expect(createCustomAutoReviewFallback()!(prompt, options)).resolves.toMatchObject({
+ ok: true, providerId: 'review-r',
+ });
+ expect(fetchMock.mock.calls[0]?.[0]).toBe('https://review-r.example/v1/responses');
+ const body = JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body));
+ expect(body).toMatchObject({ reasoning: { effort: 'medium' }, max_output_tokens: 384 });
+ expect(body).not.toHaveProperty('thinking');
+ });
+
it('does not expand an exhausted custom chain into defaults or the gateway', async () => {
readKey.mockReturnValue('gateway-key');
readCustomKey.mockReturnValue(null);
diff --git a/apps/desktop/src/main/utility-model/oneShotCandidates.ts b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
index 2657f88e1d..b6c244da93 100644
--- a/apps/desktop/src/main/utility-model/oneShotCandidates.ts
+++ b/apps/desktop/src/main/utility-model/oneShotCandidates.ts
@@ -519,8 +519,9 @@ export function createCustomAutoReviewFallback(): AutoReviewAuxiliaryFallback |
timeoutMs: opts.timeoutMs,
signal,
reasoningEffort: 'low',
- // Use the auxiliary transport's short-output policy: switch off optional
- // thinking; Responses maps this to its supported low effort instead.
+ // Use the auxiliary transport's short-output policy: the least thinking the
+ // model allows (Chat / Messages try off first; Responses starts at the
+ // lowest catalog effort). See utilityReasoningPlan.ts.
disableReasoning: true,
validateResponse: opts.validateResponse,
beforeDispatch: async () => !signal.aborted && stillCurrent(),