mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
fix: langfuse tracing 兼容 budget_tokens snake_case 格式
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1777,7 +1777,9 @@ async function* queryModel(
|
||||
// (messagesForAPI, system, allTools, betas — the entire request-building
|
||||
// context), which would otherwise be pinned until the promise resolves.
|
||||
// Also capture thinking params for Langfuse observability.
|
||||
let langfuseThinking: { type: string; budgetTokens?: number } | undefined
|
||||
// Pass the entire thinking config object so all fields (type, budget_tokens,
|
||||
// and any future additions) flow through without cherry-picking.
|
||||
let langfuseThinking: BetaMessageStreamParams['thinking'] | undefined
|
||||
{
|
||||
const queryParams = paramsFromContext({
|
||||
model: options.model,
|
||||
@@ -1788,13 +1790,7 @@ async function* queryModel(
|
||||
const logThinkingType = queryParams.thinking?.type ?? 'disabled'
|
||||
const logEffortValue = queryParams.output_config?.effort
|
||||
if (queryParams.thinking && queryParams.thinking.type !== 'disabled') {
|
||||
langfuseThinking = {
|
||||
type: queryParams.thinking.type,
|
||||
...('budget_tokens' in queryParams.thinking &&
|
||||
typeof queryParams.thinking.budget_tokens === 'number' && {
|
||||
budgetTokens: queryParams.thinking.budget_tokens,
|
||||
}),
|
||||
}
|
||||
langfuseThinking = queryParams.thinking
|
||||
}
|
||||
void options.getToolPermissionContext().then(permissionContext => {
|
||||
logAPIQuery({
|
||||
|
||||
@@ -78,9 +78,14 @@ export function recordLLMObservation(
|
||||
endTime?: Date
|
||||
completionStartTime?: Date
|
||||
tools?: unknown
|
||||
/** Thinking depth configuration used for this request */
|
||||
/** Thinking depth configuration used for this request.
|
||||
* Accepts the full API thinking config object. Fields:
|
||||
* - type: thinking mode ("enabled", "adaptive", "disabled")
|
||||
* - budget_tokens (snake_case, from Anthropic API) or budgetTokens (camelCase)
|
||||
*/
|
||||
thinking?: {
|
||||
type: string
|
||||
budget_tokens?: number
|
||||
budgetTokens?: number
|
||||
}
|
||||
},
|
||||
@@ -103,8 +108,8 @@ export function recordLLMObservation(
|
||||
provider: params.provider,
|
||||
model: params.model,
|
||||
...(params.thinking && { thinkingType: params.thinking.type }),
|
||||
...(params.thinking?.budgetTokens !== undefined && {
|
||||
thinkingBudgetTokens: params.thinking.budgetTokens,
|
||||
...(params.thinking && (params.thinking.budget_tokens !== undefined || params.thinking.budgetTokens !== undefined) && {
|
||||
thinkingBudgetTokens: (params.thinking.budget_tokens ?? params.thinking.budgetTokens) as number,
|
||||
}),
|
||||
},
|
||||
...(params.completionStartTime && { completionStartTime: params.completionStartTime }),
|
||||
|
||||
Reference in New Issue
Block a user