Skip to content

feat: add Enteprise AI chat solution#2620

Merged
PierrickVoulet merged 3 commits intogoogleworkspace:mainfrom
PierrickVoulet:enterprise-ai
Feb 23, 2026
Merged

feat: add Enteprise AI chat solution#2620
PierrickVoulet merged 3 commits intogoogleworkspace:mainfrom
PierrickVoulet:enterprise-ai

Conversation

@PierrickVoulet
Copy link
Contributor

Add Enteprise AI chat solution

@PierrickVoulet PierrickVoulet self-assigned this Feb 23, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @PierrickVoulet, 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 introduces a new Enterprise AI chat solution, providing a robust and secure AI assistant built on Gemini Enterprise. The solution integrates with Vertex AI Search for data querying and Google Chat for direct messaging, featuring dynamic authentication and configuration to ensure seamless operation within an enterprise environment. It aims to enhance user interaction with internal data and communication platforms.

Highlights

  • New Enterprise AI Agent Solution: Introduced a specialized Gemini Enterprise Agent designed to function as an Enterprise AI Assistant, leveraging Vertex AI Search and Google Chat API.
  • Dynamic Vertex AI Serving Configs: Implemented automatic discovery of the project's default_collection engine and dynamic binding to its default_serving_config for Vertex AI queries.
  • Dynamic Authentication with ToolContext: Enabled secure authentication by dynamically parsing bearer tokens injected into the ToolContext state by Gemini Enterprise, using regex pattern matching.
  • Graceful Timeouts: Configured explicit 15-second timeouts for McpToolset streaming components to prevent indefinite hanging due to backend network issues.
  • Google Chat Integration: Added a native send_direct_message tool powered by the google-apps-chat SDK, allowing the AI to send direct messages to users in Google Chat using the same extracted authentication token.
Changelog
  • solutions/enterprise-ai-agent/README.md
    • Added comprehensive documentation for the new Enterprise AI Agent, detailing its features, functionality, and deployment instructions.
  • solutions/enterprise-ai-agent/enterprise-ai/init.py
    • Initialized the Python package for the enterprise-ai agent.
  • solutions/enterprise-ai-agent/enterprise-ai/agent.py
    • Implemented the core logic for the Enterprise AI Agent, including functions for dynamic project ID and serving config discovery, secure token extraction from ToolContext, Google Chat direct messaging, and the main LlmAgent configuration.
  • solutions/enterprise-ai-agent/enterprise-ai/requirements.txt
    • Specified all necessary Python package dependencies for the Enterprise AI Agent, including google-adk, google-cloud-aiplatform, google-genai, and google-apps-chat.
  • solutions/enterprise-ai-agent/pyproject.toml
    • Configured project metadata and managed Python dependencies using Poetry, including development and deployment specific dependencies.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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

@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 introduces a new Enterprise AI agent solution. The implementation is a good start, but there are several critical areas that need improvement for robustness and correctness. Specifically, the agent has non-deterministic behavior when multiple discovery engines or authentication tokens are present. Error handling can be improved by using specific exception types instead of generic Exception. Additionally, there's a typo in the README.md that makes the provided example non-functional. I've added specific comments with suggestions to address these issues.

I am having trouble creating individual review comments. Click here to see my feedback.

solutions/enterprise-ai-agent/enterprise-ai/agent.py (61-63)

critical

This logic is not robust. It will pick the first matching key if multiple exist, which can be non-deterministic. Also, state_dict.get(...) can return None, which violates the function's return type hint str and will cause errors in downstream code. The code should validate that exactly one key is found and that its value is a non-empty string.

    if len(matching_keys) == 1:
        token = state_dict.get(matching_keys[0])
        if isinstance(token, str) and token:
            return token
    raise ValueError(f"Expected 1 valid bearer token, but found {len(matching_keys)} matching keys.")

solutions/enterprise-ai-agent/README.md (13)

high

There is a typo in the example authentication token and the regex pattern. enteprise-ai should be enterprise-ai. This will cause the regex to fail matching the token key, as it is defined as enterprise-ai in agent.py, making the example non-functional.

   When deployed as a Bring-Your-Own (BYO) model via Gemini Enterprise, the session state dynamically passes an authentication token (e.g., `enterprise-ai_12345`). This agent intercepts the `ToolContext` state and extracts the token at runtime using regex pattern matching (`^enterprise-ai_\d+$`) to securely execute calls using a Bearer token.

solutions/enterprise-ai-agent/enterprise-ai/agent.py (41)

high

Using the generic Exception is not a good practice as it can catch unexpected errors and makes specific error handling by callers difficult. Please use a more specific exception, like ValueError or RuntimeError.

    raise ValueError(f"Failed to resolve GCP Project ID from environment.")

solutions/enterprise-ai-agent/enterprise-ai/agent.py (49-51)

high

The loop iterates over engines and returns the first one it finds. If there are multiple discovery engines in the project, this will arbitrarily pick one, which could be the wrong one, as the API doesn't guarantee order. This can lead to non-deterministic behavior. The code should deterministically select the correct engine, or raise an error if more than one is found when only one is expected.

    engines_list = list(engines)
    if len(engines_list) != 1:
        raise RuntimeError(f"Expected 1 discovery engine, but found {len(engines_list)}.")
    return f"{engines_list[0].name}/servingConfigs/default_serving_config"

solutions/enterprise-ai-agent/enterprise-ai/agent.py (52)

high

Using the generic Exception is not a good practice as it can catch unexpected errors and makes specific error handling by callers difficult. Please use a more specific exception, like ValueError or RuntimeError.

    raise ValueError(f"No Discovery Engines found in project {project_id}")

@PierrickVoulet PierrickVoulet merged commit 9f6332f into googleworkspace:main Feb 23, 2026
7 of 8 checks passed
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.

1 participant