Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): one-shot 按清单传 effort 并关闭 thinking (#2939)
Shinkuf75926b37806
diff --git a/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts b/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.tsindex a902853ee4..a9e82f5807 100644--- a/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts@@ -669,6 +669,7 @@ describe('generateTitleViaProvider — anthropic(Messages)', () => {expect(body.model).toBe('claude-haiku-4-5-20251001'); // 经 toSdkModelString 还原expect(body.messages).toEqual([{ role: 'user', content: '为这条消息起标题:编译报错' }]);expect(body.system).toBeUndefined(); // 不注入身份段+ expect(body.thinking).toEqual({ type: 'disabled' });});it('先验证完整响应再按旧契约截到 40 个 Unicode 字符', async () => {const longTitle = '标题'.repeat(30);@@ -837,11 +838,43 @@ describe('generateTitleViaProvider — xd(网关 chat-completions)', () => {model: 'deepseek/deepseek-v4-flash',max_tokens: 32,thinking: { type: 'disabled' },+ reasoning_effort: 'low',});} finally {setXdGatewayModels([]);}});+ it('网关模型未下发 efforts 时不传 reasoning_effort', async () => {+ setXdGatewayModels([+ xdGatewayModel('codex/gpt-5.6-luna', 'chat', { efforts: [], defaultEffort: null }),+ ]);+ try {+ const fetchImpl = fakeFetch(() => ({+ json: { choices: [{ message: { content: '下一步改超时' } }] },+ }));+ await generateTitleViaProvider(+ { sessionId: 's3', agentKind: 'claude-code', prompt: 'x' },+ {+ fetchImpl,+ readSessionProviderId: async () => 'xd',+ listConnectedProviders: async () => [providerStub('xd')],+ readGatewayKey: () => 'gk-1',+ },+ );+ const [, init] = vi.mocked(fetchImpl).mock.calls[0] as [+ string,+ { body: string },+ ];+ const body = JSON.parse(init.body) as Record<string, unknown>;+ expect(body).toMatchObject({+ model: 'codex/gpt-5.6-luna',+ thinking: { type: 'disabled' },+ });+ expect(body).not.toHaveProperty('reasoning_effort');+ } finally {+ setXdGatewayModels([]);+ }+ });it('网关清单无聊天模型 → 不发送请求、回落 null', async () => {setXdGatewayModels([xdGatewayModel('gpt-image-2', 'image')]);try {diff --git a/apps/desktop/src/main/maker-host/title-one-shot.ts b/apps/desktop/src/main/maker-host/title-one-shot.tsindex 2e1b7467e1..b9d25aea02 100644--- a/apps/desktop/src/main/maker-host/title-one-shot.ts+++ b/apps/desktop/src/main/maker-host/title-one-shot.ts@@ -285,6 +285,7 @@ async function fetchAnthropicTitle(signal: AbortSignal,maxTokens: number = TITLE_MAX_TOKENS,systemPrompt?: string,+ thinking?: typeof TITLE_GATEWAY_THINKING | null,): Promise<string> {// Anthropic Messages API 不支持 role: 'system' 消息 —— 系统指令必须写入// 顶层 `system` 字段,否则请求会被 API 拒绝。@@ -296,6 +297,10 @@ async function fetchAnthropicTitle(if (systemPrompt) {body.system = systemPrompt;}+ // 标题 / 预测只要短正文;有 thinking 的 Claude 档不关会先烧 token。+ if (thinking) {+ body.thinking = thinking;+ }const res = await fetchImpl(`${trimTrailingSlash(upstream)}/v1/messages`, {method: 'POST',signal,@@ -374,11 +379,14 @@ async function fetchGatewayTitle(signal: AbortSignal,maxTokens: number = TITLE_MAX_TOKENS,systemPrompt?: string,+ thinking?: typeof TITLE_GATEWAY_THINKING | null,+ effort?: Effort | null,): Promise<string> {const messages: Array<{ role: string; content: string }> = [];if (systemPrompt) messages.push({ role: 'system', content: systemPrompt });messages.push({ role: 'user', content: prompt });+ // thinking / reasoning_effort 都由调用方按 TitleTarget 传入,函数内不写死。const res = await fetchImpl(`${trimTrailingSlash(upstream)}/chat/completions`, {method: 'POST',signal,@@ -389,7 +397,8 @@ async function fetchGatewayTitle(body: JSON.stringify({model: modelId,max_tokens: maxTokens,- thinking: TITLE_GATEWAY_THINKING,+ ...(thinking ? { thinking } : {}),+ ...(effort ? { reasoning_effort: effort } : {}),messages,}),});@@ -677,6 +686,7 @@ log.debug('title oneShot skipped: no title target', {controller.signal,maxTokens,opts?.systemPrompt,+ TITLE_GATEWAY_THINKING,);break;}@@ -800,6 +810,8 @@ log.debug('title oneShot skipped: no title target', {controller.signal,maxTokens,opts?.systemPrompt,+ TITLE_GATEWAY_THINKING,+ target.effort,);break;}