feat(ai-statistics): add session ID tracking for multi-turn agent conversations (#3420)

This commit is contained in:
澄潭
2026-02-01 00:35:50 +08:00
committed by GitHub
parent 93075cbc03
commit 1b0ee6e837
5 changed files with 1105 additions and 38 deletions

View File

@@ -0,0 +1,15 @@
--- a/main.go
+++ b/main.go
@@ -790,6 +790,14 @@
buffer = extractStreamingToolCalls(body, buffer)
ctx.SetContext(CtxStreamingToolCallsBuffer, buffer)
+ // Also set tool_calls to user attributes so they appear in ai_log
+ toolCalls := getToolCallsFromBuffer(buffer)
+ if len(toolCalls) > 0 {
+ ctx.SetUserAttribute(BuiltinToolCallsKey, toolCalls)
+ return toolCalls
+ }
}
} else if source == ResponseBody {
if value := gjson.GetBytes(body, ToolCallsPathNonStreaming).Value(); value != nil {