Skip to content

Conversation

@baptmont
Copy link
Contributor

@baptmont baptmont commented Nov 7, 2025

crocodilys and others added 4 commits November 6, 2025 15:53
- Move vertexai session service to separate package.
- Allow multiple app usage by having different reasoning engine.
- Add create_engine example.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @baptmont, 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 significantly enhances the application's ability to manage sessions within Google Cloud's Vertex AI platform. It introduces a specialized Vertex AI session service, moving from a more generalized approach to a dedicated, API-driven implementation. This change provides a more structured and robust way to handle session lifecycle and event logging, ensuring better integration and scalability with Vertex AI reasoning engines.

Highlights

  • New Vertex AI Session Service: Introduced a dedicated session/vertexai package to provide a robust session service implementation for Vertex AI, aligning with the Python ADK reference.
  • Refactored Session Logic: The previous generic session.VertexAIService function has been removed and its functionality, along with detailed session management, is now encapsulated within the new session/vertexai package.
  • Vertex AI API Integration: A new vertexAiClient has been added to handle interactions with the Google Cloud AI Platform API (specifically apiv1beta1), enabling creation, retrieval, listing, deletion of sessions, and event management for Vertex AI Reasoning Engines.
  • Updated Example Usage: The examples/vertexai/agent.go file has been updated to utilize the new vertexai.NewSessionService and now requires environment variables (CLOUD_PROJECT_ID, CLOUD_LOCATION, VERTEX_ENGINE_ID) for configuration. A new example examples/vertexai/vertexengine/create_engine.go demonstrates how to create a Vertex AI Reasoning Engine.
  • Dependency Updates: The go.mod and go.sum files have been updated to include cloud.google.com/go/aiplatform and google.golang.org/protobuf dependencies, necessary for interacting with the Vertex AI API.
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.

@baptmont
Copy link
Contributor Author

baptmont commented Nov 7, 2025

missing state scopes
currently only text events are stored

@baptmont baptmont marked this pull request as draft November 7, 2025 17:35
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 refactors the Vertex AI session service into its own session/vertexai package, which is a good structural improvement. It also adds a new example for creating a reasoning engine. The changes are mostly well-implemented, but I've found a few critical issues: a typo using a Cyrillic character that will break compilation, an unsafe type assertion, and a potential panic from incorrect slice indexing. I've also pointed out a high-severity race condition in state handling and a couple of medium-severity issues related to error handling and performance. Please address the critical issues before merging.

Comment on lines +128 to +142
func (s *state) All() iter.Seq2[string, any] {
return func(yield func(key string, val any) bool) {
s.mu.RLock()

for k, v := range s.state {
s.mu.RUnlock()
if !yield(k, v) {
return
}
s.mu.RLock()
}

s.mu.RUnlock()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This implementation of All() has a potential race condition. The mutex is unlocked before calling yield and re-locked after. Between the unlock and re-lock, another goroutine can modify s.state (e.g., by calling Set). Modifying a map while iterating over it can lead to unpredictable behavior. A safer approach is to create a copy of the state map while holding the lock, and then iterate over the copy.

func (s *state) All() iter.Seq2[string, any] {
	s.mu.RLock()
	// Create a copy of the state to iterate over it without holding the lock.
	stateCopy := make(map[string]any, len(s.state))
	for k, v := range s.state {
		stateCopy[k] = v
	}
	s.mu.RUnlock()

	return func(yield func(key string, val any) bool) {
		for k, v := range stateCopy {
			if !yield(k, v) {
				return
			}
		}
	}
}

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.

2 participants