diff --git a/internal/llminternal/functions.go b/internal/llminternal/functions.go index b1771bdea..6c39c2b83 100644 --- a/internal/llminternal/functions.go +++ b/internal/llminternal/functions.go @@ -15,8 +15,6 @@ package llminternal import ( - "time" - "google.golang.org/genai" "google.golang.org/adk/agent" @@ -78,18 +76,15 @@ func generateRequestConfirmationEvent( return nil } - return &session.Event{ - InvocationID: invocationContext.InvocationID(), - Author: invocationContext.Agent().Name(), - Branch: invocationContext.Branch(), - LLMResponse: model.LLMResponse{ - Content: &genai.Content{ - Parts: parts, - Role: genai.RoleModel, - }, + event := session.NewEvent(invocationContext.InvocationID()) + event.Author = invocationContext.Agent().Name() + event.Branch = invocationContext.Branch() + event.LLMResponse = model.LLMResponse{ + Content: &genai.Content{ + Parts: parts, + Role: genai.RoleModel, }, - Timestamp: time.Now(), - LongRunningToolIDs: longRunningToolIDs, - Actions: session.EventActions{}, } + event.LongRunningToolIDs = longRunningToolIDs + return event } diff --git a/internal/llminternal/functions_test.go b/internal/llminternal/functions_test.go index 63aa27169..0db69fc59 100644 --- a/internal/llminternal/functions_test.go +++ b/internal/llminternal/functions_test.go @@ -146,6 +146,7 @@ func TestGenerateRequestConfirmationEvent(t *testing.T) { InvocationID: "inv_1", Author: "agent_1", Branch: "main", + Actions: session.EventActions{StateDelta: map[string]any{}}, LLMResponse: model.LLMResponse{ Content: &genai.Content{ Role: genai.RoleModel, @@ -180,6 +181,12 @@ func TestGenerateRequestConfirmationEvent(t *testing.T) { } if got != nil { + if got.ID == "" { + t.Errorf("expected event ID to be set, got empty string") + } + if got.Timestamp.IsZero() { + t.Errorf("expected event Timestamp to be set, got zero value") + } for _, s := range got.LongRunningToolIDs { if s == "" { t.Errorf("empty long running tool id")