mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 06:45:50 +00:00
feat: 增强 auto mode 的易用性 (#312)
* feat: poor 模式降级 yolo 审阅模型 * feat: 为多模块添加 Langfuse tracing 支持 在 web search、agent creation、away summary、token estimation、 skill improvement 等模块中集成 Langfuse trace,并透传至 compact/apiQueryHook/execPromptHook 等调用链。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 让 auto mode 记录回主 trace * fix: reopen auto mode prompt when classifier is unavailable * fix: 修复 auto mode 情况下, llm 报错导致弹窗也不打开的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,9 @@ import { getSmallFastModel } from '../utils/model/model.js'
|
||||
import { asSystemPrompt } from '../utils/systemPromptType.js'
|
||||
import { getResolvedLanguage } from '../utils/language.js'
|
||||
import { queryModelWithoutStreaming } from './api/claude.js'
|
||||
import { createTrace, endTrace, isLangfuseEnabled } from './langfuse/index.js'
|
||||
import { getSessionId } from '../bootstrap/state.js'
|
||||
import { getAPIProvider } from '../utils/model/providers.js'
|
||||
import { getSessionMemoryContent } from './SessionMemory/sessionMemoryUtils.js'
|
||||
|
||||
// Recap only needs recent context — truncate to avoid "prompt too long" on
|
||||
@@ -42,6 +45,16 @@ export async function generateAwaySummary(
|
||||
return null
|
||||
}
|
||||
|
||||
const model = getSmallFastModel()
|
||||
const langfuseTrace = isLangfuseEnabled()
|
||||
? createTrace({
|
||||
sessionId: getSessionId(),
|
||||
model,
|
||||
provider: getAPIProvider(),
|
||||
name: 'away-summary',
|
||||
})
|
||||
: null
|
||||
|
||||
try {
|
||||
const memory = await getSessionMemoryContent()
|
||||
const recent = messages.slice(-RECENT_MESSAGE_WINDOW)
|
||||
@@ -54,7 +67,7 @@ export async function generateAwaySummary(
|
||||
signal,
|
||||
options: {
|
||||
getToolPermissionContext: async () => getEmptyToolPermissionContext(),
|
||||
model: getSmallFastModel(),
|
||||
model,
|
||||
toolChoice: undefined,
|
||||
isNonInteractiveSession: false,
|
||||
hasAppendSystemPrompt: false,
|
||||
@@ -62,6 +75,7 @@ export async function generateAwaySummary(
|
||||
querySource: 'away_summary',
|
||||
mcpTools: [],
|
||||
skipCacheWrite: true,
|
||||
langfuseTrace,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -69,14 +83,17 @@ export async function generateAwaySummary(
|
||||
logForDebugging(
|
||||
`[awaySummary] API error: ${getAssistantMessageText(response)}`,
|
||||
)
|
||||
endTrace(langfuseTrace, undefined, 'error')
|
||||
return null
|
||||
}
|
||||
endTrace(langfuseTrace)
|
||||
return getAssistantMessageText(response)
|
||||
} catch (err) {
|
||||
if (err instanceof APIUserAbortError || signal.aborted) {
|
||||
return null
|
||||
}
|
||||
logForDebugging(`[awaySummary] generation failed: ${err}`)
|
||||
endTrace(langfuseTrace, undefined, 'error')
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user