mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25: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
|
// (messagesForAPI, system, allTools, betas — the entire request-building
|
||||||
// context), which would otherwise be pinned until the promise resolves.
|
// context), which would otherwise be pinned until the promise resolves.
|
||||||
// Also capture thinking params for Langfuse observability.
|
// 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({
|
const queryParams = paramsFromContext({
|
||||||
model: options.model,
|
model: options.model,
|
||||||
@@ -1788,13 +1790,7 @@ async function* queryModel(
|
|||||||
const logThinkingType = queryParams.thinking?.type ?? 'disabled'
|
const logThinkingType = queryParams.thinking?.type ?? 'disabled'
|
||||||
const logEffortValue = queryParams.output_config?.effort
|
const logEffortValue = queryParams.output_config?.effort
|
||||||
if (queryParams.thinking && queryParams.thinking.type !== 'disabled') {
|
if (queryParams.thinking && queryParams.thinking.type !== 'disabled') {
|
||||||
langfuseThinking = {
|
langfuseThinking = queryParams.thinking
|
||||||
type: queryParams.thinking.type,
|
|
||||||
...('budget_tokens' in queryParams.thinking &&
|
|
||||||
typeof queryParams.thinking.budget_tokens === 'number' && {
|
|
||||||
budgetTokens: queryParams.thinking.budget_tokens,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void options.getToolPermissionContext().then(permissionContext => {
|
void options.getToolPermissionContext().then(permissionContext => {
|
||||||
logAPIQuery({
|
logAPIQuery({
|
||||||
|
|||||||
@@ -78,9 +78,14 @@ export function recordLLMObservation(
|
|||||||
endTime?: Date
|
endTime?: Date
|
||||||
completionStartTime?: Date
|
completionStartTime?: Date
|
||||||
tools?: unknown
|
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?: {
|
thinking?: {
|
||||||
type: string
|
type: string
|
||||||
|
budget_tokens?: number
|
||||||
budgetTokens?: number
|
budgetTokens?: number
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -103,8 +108,8 @@ export function recordLLMObservation(
|
|||||||
provider: params.provider,
|
provider: params.provider,
|
||||||
model: params.model,
|
model: params.model,
|
||||||
...(params.thinking && { thinkingType: params.thinking.type }),
|
...(params.thinking && { thinkingType: params.thinking.type }),
|
||||||
...(params.thinking?.budgetTokens !== undefined && {
|
...(params.thinking && (params.thinking.budget_tokens !== undefined || params.thinking.budgetTokens !== undefined) && {
|
||||||
thinkingBudgetTokens: params.thinking.budgetTokens,
|
thinkingBudgetTokens: (params.thinking.budget_tokens ?? params.thinking.budgetTokens) as number,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
...(params.completionStartTime && { completionStartTime: params.completionStartTime }),
|
...(params.completionStartTime && { completionStartTime: params.completionStartTime }),
|
||||||
|
|||||||
Reference in New Issue
Block a user