Skip to content

Comments

fix: generateRequestConfirmationEvent creates events with empty ID#588

Open
dannovikov wants to merge 3 commits intogoogle:mainfrom
dannovikov:patch-1
Open

fix: generateRequestConfirmationEvent creates events with empty ID#588
dannovikov wants to merge 3 commits intogoogle:mainfrom
dannovikov:patch-1

Conversation

@dannovikov
Copy link

Closes #587

Description:

generateRequestConfirmationEvent in internal/llminternal/functions.go constructs the confirmation event using a raw &session.Event{...} struct literal, which leaves the ID field as "". In the Python ADK, Event.model_post_init auto-assigns a UUID on every construction. The Go equivalent is session.NewEvent(), which assigns uuid.NewString().

The fix replaces the raw struct literal with session.NewEvent(), which also handles Timestamp and StateDelta initialisation — making the explicit time.Now() and Actions: session.EventActions{} unnecessary.

Go (internal/llminternal/functions.go:81):

// Before:
return &session.Event{
    InvocationID: invocationContext.InvocationID(),
    Author:       invocationContext.Agent().Name(),
    ...
    Timestamp:    time.Now(),
    Actions:      session.EventActions{},
}

// After:
ev := session.NewEvent(invocationContext.InvocationID())
ev.Author = invocationContext.Agent().Name()
...

Python (src/google/adk/events/event.py:69-71):

def model_post_init(self, __context):
    if not self.id:
        self.id = Event.new_id()   # str(uuid.uuid4())

Testing:

Added TestGenerateRequestConfirmationEventHasID to functions_test.go which:

  • Constructs a valid confirmation scenario (matching function call + confirmation request)
  • Asserts got.ID != "" — fails before the fix, passes after
  • Asserts got.InvocationID == "inv_1" for correctness

Updated the existing TestGenerateRequestConfirmationEvent expected wantEvent to include StateDelta: map[string]any{} (initialised by NewEvent).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dannovikov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug in the Go ADK where events generated by generateRequestConfirmationEvent were missing IDs. This was due to the direct instantiation of the session.Event struct, bypassing the automatic UUID assignment. The fix replaces the struct literal with session.NewEvent(), ensuring that all events have a unique ID, which is crucial for features like time-travel and session lookup. Additionally, a new test case has been added to prevent regressions.

Highlights

  • Fix for Empty Event IDs: This PR addresses an issue where generateRequestConfirmationEvent was creating events with empty IDs due to using a raw struct literal instead of session.NewEvent().
  • Go ADK Event Creation: The PR updates the Go ADK to align with the Python ADK by ensuring that events are created with session.NewEvent() to automatically assign UUIDs.
  • Testing: A new test case, TestGenerateRequestConfirmationEventHasID, was added to verify that events generated by generateRequestConfirmationEvent always have a non-empty ID.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • internal/llminternal/functions.go
    • Replaced raw struct literal with session.NewEvent() to ensure events have a UUID.
  • internal/llminternal/functions_test.go
    • Added TestGenerateRequestConfirmationEventHasID to verify that events have non-empty IDs.
    • Updated TestGenerateRequestConfirmationEvent to include StateDelta in the expected event.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses a bug where generateRequestConfirmationEvent created events with an empty ID. The fix properly uses the session.NewEvent() factory function, which ensures a unique ID is always assigned. This change also simplifies the event creation logic by leveraging the initialization of Timestamp and StateDelta done by NewEvent(). The accompanying changes in the tests are well-written: the existing test is correctly updated to reflect the new event structure, and a new test is added to specifically verify that the generated event has a non-empty ID, preventing future regressions. The changes are solid and improve the robustness of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generateRequestConfirmationEvent creates events with empty ID

1 participant