feat: langfuse tracing 增加 thinking 参数记录

在 recordLLMObservation 中添加 thinking 配置(type/budgetTokens),
所有 provider(claude/gemini/openai)及 tokenEstimation、sideQuery
调用处同步传递 thinking 信息,便于 Langfuse 面板观察 thinking 使用情况。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-27 09:33:38 +08:00
parent 52b61c2c06
commit 36bf4f260f
6 changed files with 38 additions and 0 deletions

View File

@@ -78,6 +78,11 @@ export function recordLLMObservation(
endTime?: Date
completionStartTime?: Date
tools?: unknown
/** Thinking depth configuration used for this request */
thinking?: {
type: string
budgetTokens?: number
}
},
): void {
if (!rootSpan || !isLangfuseEnabled()) return
@@ -97,6 +102,10 @@ export function recordLLMObservation(
metadata: {
provider: params.provider,
model: params.model,
...(params.thinking && { thinkingType: params.thinking.type }),
...(params.thinking?.budgetTokens !== undefined && {
thinkingBudgetTokens: params.thinking.budgetTokens,
}),
},
...(params.completionStartTime && { completionStartTime: params.completionStartTime }),
},