Note: This project is part of the official Google Codelab Integrate Gemini Enterprise Agents with Google Workspace.
This sample contains a specialized Gemini Enterprise Agent built using the Google Agent Development Kit (ADK). This agent acts as an Enterprise AI Assistant by querying user's data corpus using the Vertex AI Search MCP toolset and sending Chat messages to DM spaces using a custom Function tool & Google Chat API.
-
Dynamic Vertex AI Serving Configs: The agent automatically discovers your project's
default_collectionengine and dynamically binds its queries to thedefault_serving_config. -
Dynamic Authentication (
ToolContext): 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 theToolContextstate and extracts the token at runtime using regex pattern matching (^enterprise-ai_\d+$) to securely execute calls using a Bearer token. -
Graceful Timeouts: The
McpToolsetstreaming components have been intentionally configured with an explicit 15-secondtimeoutandsse_read_timeoutto prevent the agent from hanging infinitely on backend network issues. -
Google Chat Integration: The agent natively includes a
send_direct_messagetool powered by thegoogle-apps-chatSDK. This allows the AI to immediately send direct messages to users inside Google Chat. It seamlessly reuses the same authentication token extracted from theToolContextused for Vertex AI.
This agent is designed exclusively to be deployed as a backend for a Gemini Enterprise (GE) Bring-Your-Own (BYO) Agent. It will not work successfully if tested locally via standard ADK run commands because it relies entirely on the external GE gateway to dynamically inject OAuth tokens into the ToolContext at runtime.
Deploy this agent directly to Vertex AI Agent Engines using the ADK CLI:
adk deploy agent_engine \
--project=your-gcp-project-id \
--region=us-central1 \
--display_name="Enterprise AI" \
enterprise_aiRegister the deployed agent in the Gemini Enterprise UI as a BYO agent.