feat(log): prompt tokens (#2047)

This commit is contained in:
Mauro 2026-03-27 19:00:12 +01:00 committed by GitHub
parent b646d3b8fe
commit 60d7ec20a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2110,8 +2110,7 @@ turnLoop:
},
)
logger.DebugCF("agent", "LLM response",
map[string]any{
llmResponseFields := map[string]any{
"agent_id": ts.agent.ID,
"iteration": iteration,
"content_chars": len(response.Content),
@ -2119,7 +2118,13 @@ turnLoop:
"reasoning": response.Reasoning,
"target_channel": al.targetReasoningChannelID(ts.channel),
"channel": ts.channel,
})
}
if response.Usage != nil {
llmResponseFields["prompt_tokens"] = response.Usage.PromptTokens
llmResponseFields["completion_tokens"] = response.Usage.CompletionTokens
llmResponseFields["total_tokens"] = response.Usage.TotalTokens
}
logger.DebugCF("agent", "LLM response", llmResponseFields)
if len(response.ToolCalls) == 0 || gracefulTerminal {
responseContent := response.Content