feat(audit): persist message source and token usage
This commit is contained in:
@@ -169,6 +169,11 @@ func (e *AgentEngine) emitCompletionEvent(
|
||||
for _, ref := range state.KnowledgeRefs {
|
||||
knowledgeRefsInterface = append(knowledgeRefsInterface, ref)
|
||||
}
|
||||
var tokenUsage *types.TokenUsage
|
||||
if e.totalUsage.TotalTokens > 0 {
|
||||
usage := e.totalUsage
|
||||
tokenUsage = &usage
|
||||
}
|
||||
|
||||
e.eventBus.Emit(ctx, event.Event{
|
||||
ID: generateEventID("complete"),
|
||||
@@ -181,6 +186,7 @@ func (e *AgentEngine) emitCompletionEvent(
|
||||
TotalSteps: len(state.RoundSteps),
|
||||
TotalDurationMs: time.Since(startTime).Milliseconds(),
|
||||
MessageID: messageID, // Include message ID for proper message update
|
||||
TokenUsage: tokenUsage,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user