mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55: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:
@@ -19,6 +19,7 @@ import { createTrace, createChildSpan, endTrace, recordLLMObservation } from '..
|
||||
import type { LangfuseSpan } from '../services/langfuse/index.js'
|
||||
import { convertMessagesToLangfuse, convertOutputToLangfuse, convertToolsToLangfuse } from '../services/langfuse/convert.js'
|
||||
import { getModelBetas, modelSupportsStructuredOutputs } from './betas.js'
|
||||
import { logForDebugging } from './debug.js'
|
||||
import { errorMessage } from './errors.js'
|
||||
import { computeFingerprint } from './fingerprint.js'
|
||||
import { getAPIProvider } from './model/providers.js'
|
||||
@@ -194,21 +195,35 @@ export async function sideQuery(opts: SideQueryOptions): Promise<BetaMessage> {
|
||||
|
||||
// When parentSpan is provided, create a child span nested under the
|
||||
// main agent trace; otherwise create a standalone root trace.
|
||||
const langfuseTrace = opts.parentSpan
|
||||
? createChildSpan(opts.parentSpan, {
|
||||
const _ps = opts.parentSpan
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
if (opts.querySource === 'auto_mode') {
|
||||
logForDebugging(
|
||||
`[sideQuery] auto_mode parentSpan=${_ps ? `id=${(_ps as unknown as Record<string, unknown>).id ?? 'present'}` : 'null/undefined'} querySource=${opts.querySource}`,
|
||||
)
|
||||
}
|
||||
// When parentSpan is provided, create a child span nested under the
|
||||
// main agent trace. For auto_mode queries, we must always nest under
|
||||
// a parent span — never create a standalone root trace (agent type),
|
||||
// as auto_mode observations should appear as spans within the parent.
|
||||
// For other query sources without a parent, create a standalone trace.
|
||||
const langfuseTrace = _ps
|
||||
? createChildSpan(_ps, {
|
||||
name: traceName,
|
||||
sessionId: getSessionId(),
|
||||
model: normalizedModel,
|
||||
provider,
|
||||
querySource: opts.querySource,
|
||||
})
|
||||
: createTrace({
|
||||
sessionId: getSessionId(),
|
||||
model: normalizedModel,
|
||||
provider,
|
||||
name: traceName,
|
||||
querySource: opts.querySource,
|
||||
})
|
||||
: opts.querySource === 'auto_mode'
|
||||
? null
|
||||
: createTrace({
|
||||
sessionId: getSessionId(),
|
||||
model: normalizedModel,
|
||||
provider,
|
||||
name: traceName,
|
||||
querySource: opts.querySource,
|
||||
})
|
||||
|
||||
let response: BetaMessage
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user