{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "cf1e9798-cbff-4a30-90fc-cdd3d0814a7c",
      "metadata": {
        "id": "1Vs2C5ZBkrjmrHTfAyz77hpV"
      },
      "outputs": [],
      "source": [
        "# Copyright 2025 Google LLC\n",
        "#\n",
        "# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "# you may not use this file except in compliance with the License.\n",
        "# You may obtain a copy of the License at\n",
        "#\n",
        "#     https://www.apache.org/licenses/LICENSE-2.0\n",
        "#\n",
        "# Unless required by applicable law or agreed to in writing, software\n",
        "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "# See the License for the specific language governing permissions and\n",
        "# limitations under the License."
      ]
    },
    {
      "cell_type": "markdown",
      "id": "08dd40a3-3ecd-4d2b-bbad-cd4486cc1f21",
      "metadata": {
        "id": "VoJZgH6X77se"
      },
      "source": [
        "# Gemini Enterprise custom agent with Vertex AI session"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "efddf600-bb65-408f-ac49-72d4c2782b54",
      "metadata": {
        "id": "qfDq3m0R8Fe1"
      },
      "source": [
        "<table align=\"left\">\n",
        "  <td style=\"text-align: center\">\n",
        "    <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\">\n",
        "      <img width=\"32px\" src=\"https://www.gstatic.com/pantheon/images/bigquery/welcome_page/colab-logo.svg\" alt=\"Google Colaboratory logo\"><br> Open in Colab\n",
        "    </a>\n",
        "  </td>\n",
        "  <td style=\"text-align: center\">\n",
        "    <a href=\"https://console.cloud.google.com/vertex-ai/colab/import/https:%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fsearch%2Fgemini-enterprise%2Fgemini_enterprise_session.ipynb\">\n",
        "      <img width=\"32px\" src=\"https://lh3.googleusercontent.com/JmcxdQi-qOpctIvWKgPtrzZdJJK-J3sWE1RsfjZNwshCFgE_9fULcNpuXYTilIR2hjwN\" alt=\"Google Cloud Colab Enterprise logo\"><br> Open in Colab Enterprise\n",
        "    </a>\n",
        "  </td>\n",
        "  <td style=\"text-align: center\">\n",
        "    <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/generative-ai/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\">\n",
        "      <img src=\"https://www.gstatic.com/images/branding/gcpiconscolors/vertexai/v1/32px.svg\" alt=\"Vertex AI logo\"><br> Open in Vertex AI Workbench\n",
        "    </a>\n",
        "  </td>\n",
        "  <td style=\"text-align: center\">\n",
        "    <a href=\"https://github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\">\n",
        "      <img width=\"32px\" src=\"https://raw.githubusercontent.com/primer/octicons/refs/heads/main/icons/mark-github-24.svg\" alt=\"GitHub logo\"><br> View on GitHub\n",
        "    </a>\n",
        "  </td>\n",
        "</table>\n",
        "\n",
        "<div style=\"clear: both;\"></div>\n",
        "\n",
        "<b>Share to:</b>\n",
        "\n",
        "<a href=\"https://www.linkedin.com/sharing/share-offsite/?url=https%3A//github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\" target=\"_blank\">\n",
        "  <img width=\"20px\" src=\"https://upload.wikimedia.org/wikipedia/commons/8/81/LinkedIn_icon.svg\" alt=\"LinkedIn logo\">\n",
        "</a>\n",
        "\n",
        "<a href=\"https://bsky.app/intent/compose?text=https%3A//github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\" target=\"_blank\">\n",
        "  <img width=\"20px\" src=\"https://upload.wikimedia.org/wikipedia/commons/7/7a/Bluesky_Logo.svg\" alt=\"Bluesky logo\">\n",
        "</a>\n",
        "\n",
        "<a href=\"https://twitter.com/intent/tweet?url=https%3A//github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\" target=\"_blank\">\n",
        "  <img width=\"20px\" src=\"https://upload.wikimedia.org/wikipedia/commons/5/5a/X_icon_2.svg\" alt=\"X logo\">\n",
        "</a>\n",
        "\n",
        "<a href=\"https://reddit.com/submit?url=https%3A//github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\" target=\"_blank\">\n",
        "  <img width=\"20px\" src=\"https://redditinc.com/hubfs/Reddit%20Inc/Brand/Reddit_Logo.png\" alt=\"Reddit logo\">\n",
        "</a>\n",
        "\n",
        "<a href=\"https://www.facebook.com/sharer/sharer.php?u=https%3A//github.com/GoogleCloudPlatform/generative-ai/blob/main/search/gemini-enterprise/gemini_enterprise_session.ipynb\" target=\"_blank\">\n",
        "  <img width=\"20px\" src=\"https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg\" alt=\"Facebook logo\">\n",
        "</a>"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "11811f0a-c6ee-4a35-a3ae-f387abb4a810",
      "metadata": {
        "id": "UD1Cy9O88Zn9"
      },
      "source": [
        "| Authors |\n",
        "| --- |\n",
        "| Rupjit Chakraborty|\n",
        "| Sharmila Devi |\n",
        "| Parag Mhatre |"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "fd037092-f37a-4137-8180-978f6558a767",
      "metadata": {
        "id": "28b524cdd168"
      },
      "source": [
        "## Overview : Custom agent with sessions in Gemini Enterprise\n",
        "\n",
        "This notebook demonstrates an end-to-end example of a custom agent integrated with Gemini Enterprise that uses [VertexAISessionService](https://google.github.io/adk-docs/sessions/session/#managing-sessions-with-a-sessionservice). In this case, a simple example of a travel planner has been demonstrated, which takes the help of two sub-agents, viz. query completeness checker and itinerary \n",
        "generator. This agent helps a user plan their travel based on their travel destination and time of travel. Due to the use of Vertex AI Session service, this agent can also modify generated itineraries.\n",
        "\n",
        "### Background\n",
        "\n",
        "Custom agents integrated with Gemini Enterprise may need to leverage a user's previous conversations and preferences to answer a query satisfactorily. By default, [`AdkApp` template is already connected to Vertex AI Agent Engine Sessions through `session_service`](https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/sessions/manage-sessions-adk#python). However, this session service is not persistent. There are two persistent session service - `VertexAiSessionService` and `DatabaseSessionService`. The use of `VertexAiSessionService` has been demonstrated below.\n",
        "\n",
        "### Business Application Scenario\n",
        "\n",
        "We demonstrate a simple scenario where a user is planning a travel to a certain location. The user provides destination information first but to generate a suitable itinerary the agent also needs a time information. The agent requests the user for time information and after the user provides it, the agent generates the itinerary. After the itinerary generation the user requests modification based on a certain criteria and agent updates the itinerary based on that.\n",
        "\n",
        "### Notebook Overview\n",
        "\n",
        "This notebook guides you through the following key steps:\n",
        "\n",
        "1. Creation of custom travel agent\n",
        "    a. Create the sub-agents - query completeness checker and itinerary generator  \n",
        "    b. Create the root agent to call the sub-agents to respond to a user query\n",
        "2. Local demo of the custom travel agent using VertexAISessionService\n",
        "    a. Create an Agent Engine instance and VertexAISessionService  \n",
        "    b. Demo user query response using the VertexAISessionService\n",
        "3. Update/Deploy the custom travel agent to agent engine and demo user queries \n",
        "    a. Update the agent engine instance created in 2.  \n",
        "    b. Demo user query response using the VertexAISessionService via Agent Engine remote agent.\n",
        "4. Integrate the agent with Gemini Enterprise\n",
        "    a. Register the agent in Gemini Enterprise"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "73051a45bd86"
      },
      "outputs": [],
      "source": [
        "%pip install --upgrade google-adk google-genai google-cloud-aiplatform"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "cbbd420a-328e-4c29-9b75-329a8b6128da",
      "metadata": {
        "id": "37f300fa5e86"
      },
      "source": [
        "## Imports"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "e5e6755d-f1f2-41c9-8ae9-176a7d56cb56",
      "metadata": {
        "id": "79697b7e4ea7"
      },
      "outputs": [],
      "source": [
        "import vertexai\n",
        "from dotenv import load_dotenv\n",
        "from google import adk\n",
        "from google.adk.agents import Agent\n",
        "from google.adk.sessions import VertexAiSessionService\n",
        "from google.adk.tools.agent_tool import AgentTool\n",
        "from google.genai import types\n",
        "from vertexai import agent_engines\n",
        "from vertexai.preview import reasoning_engines"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "94c74b28-3dc3-4f45-aa55-2f8b470777b5",
      "metadata": {
        "id": "9a02fc0443de"
      },
      "source": [
        "## Constants and Initializations"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "541b8f47-ce1a-42a1-9e7f-f85e5f7530be",
      "metadata": {
        "id": "09ba8e3747ff"
      },
      "outputs": [],
      "source": [
        "# TODO for Developer: Update project, location, bucket details\n",
        "\n",
        "PROJECT_ID = \"[your-project-name]\"\n",
        "PROJECT_NUMBER = \"[your-project-number]\"\n",
        "LOCATION = \"[your-location]\"\n",
        "STAGING_BUCKET = \"[your-bucket]\"\n",
        "\n",
        "vertexai.init(\n",
        "    project=PROJECT_ID,\n",
        "    location=LOCATION,\n",
        "    staging_bucket=STAGING_BUCKET,\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "75881789-6436-4567-ab62-f6d2e310da66",
      "metadata": {
        "id": "7aeeb9e88bc4"
      },
      "source": [
        "## Set and load environment variables"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "900f5dc1-909d-4e47-9f0b-30c598ed756f",
      "metadata": {
        "id": "f3d99cee0b8d"
      },
      "outputs": [],
      "source": [
        "# environment variables\n",
        "\n",
        "ENV_SETTINGS = \"\"\"\n",
        "# Choose Model Backend: 0 -> API Key, 1 -> Vertex AI\n",
        "GOOGLE_GENAI_USE_VERTEXAI=1\n",
        "\n",
        "# --- API Key Configuration (if GOOGLE_GENAI_USE_VERTEXAI=0) ---\n",
        "# Obtain your API key from Google AI Studio or Google Cloud console\n",
        "GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY\n",
        "\n",
        "# --- Vertex AI Backend Configuration (if GOOGLE_GENAI_USE_VERTEXAI=1) ---\n",
        "# Your Google Cloud Project ID\n",
        "GOOGLE_CLOUD_PROJECT=[your-project-name]\n",
        "# The location (region) for Vertex AI services\n",
        "GOOGLE_CLOUD_LOCATION=[your-location]\n",
        "\"\"\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "1eabbccc-d10f-4c5a-a640-d9c2fc2d0897",
      "metadata": {
        "id": "e28f8b752601"
      },
      "outputs": [],
      "source": [
        "# Save and load environment variables\n",
        "\n",
        "with open(\".env\", \"w\") as f_handle:\n",
        "    f_handle.write(ENV_SETTINGS)\n",
        "\n",
        "load_dotenv()"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "a1d151cf-e30b-4561-b2f6-ecab61560b82",
      "metadata": {
        "id": "8cf87ececdd4"
      },
      "source": [
        "## Create agent and sub-agents"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "bf77bce0-608c-4ec4-8cfa-ede5e90e9993",
      "metadata": {
        "id": "059794ab594e"
      },
      "outputs": [],
      "source": [
        "# prompt to check if the user query is complete in\n",
        "\n",
        "QUERY_CHECK_PROMPT = \"\"\"\n",
        "You are an expert travel planner and can check a user query for completeness and correctness\n",
        "\n",
        "INSTRUCTIONS\n",
        "Given the user query check if \n",
        "1. the query is related to travel itinerary planning\n",
        "2. the query mandatorily contains both place and time of travel\n",
        "\n",
        "EXAMPLE\n",
        "travel is Aug --> incomplete query as no place of travel information\n",
        "travel to Karnataka --> incomplete query as no time of travel information\n",
        "travel to Karnataka in Aug --> correct query\n",
        "\n",
        "OUTPUT\n",
        "If the user query is complete: just say \"query is complete\"\n",
        "If the user query is not complete: question user to complete the query like \"Can you provide the month information ?\"\n",
        "\"\"\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "9ea216cd-ae30-453a-81e8-c817cd35add0",
      "metadata": {
        "id": "476202ab69dd"
      },
      "outputs": [],
      "source": [
        "travel_query_validator = Agent(\n",
        "    model=\"gemini-2.5-flash\",\n",
        "    name=\"travel_query_validator\",\n",
        "    description=\"This agent checks if the user query appropriate\",\n",
        "    instruction=QUERY_CHECK_PROMPT,\n",
        "    disallow_transfer_to_parent=False,\n",
        "    disallow_transfer_to_peers=True,\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "d005f456-3fe3-42f0-a881-91c6e4c8f2a2",
      "metadata": {
        "id": "6525470f6823"
      },
      "outputs": [],
      "source": [
        "ITINERARY_PROMPT = \"\"\"\n",
        "You are an expert travel planner and can provide a user itinerary\n",
        "\n",
        "INSTRUCTION\n",
        "Given the user query, provide a suitable itinerary\n",
        "\"\"\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "c3833926-426b-4f16-840b-76fc2045efc0",
      "metadata": {
        "id": "d0dd2872f4f6"
      },
      "outputs": [],
      "source": [
        "planner_agent = Agent(\n",
        "    model=\"gemini-2.5-flash\",\n",
        "    name=\"planner_agent\",\n",
        "    description=\"This agent provides a travel plan to user based on the query\",\n",
        "    instruction=ITINERARY_PROMPT,\n",
        "    disallow_transfer_to_parent=True,\n",
        "    disallow_transfer_to_peers=True,\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "46c491c1-b2b3-4b49-b1c8-b7e8bd343edf",
      "metadata": {
        "id": "ffe1b6d2d110"
      },
      "outputs": [],
      "source": [
        "root_agent = Agent(\n",
        "    name=\"root\",\n",
        "    model=\"gemini-2.5-flash\",\n",
        "    description=(\n",
        "        \"A travel agent that takes a user query and prepares a detailed itinerary with the help of sub-agents\"\n",
        "    ),\n",
        "    generate_content_config=types.GenerateContentConfig(temperature=0.01),\n",
        "    tools=[AgentTool(agent=travel_query_validator), AgentTool(agent=planner_agent)],\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "63769b50-f502-478d-8fe1-d2c606441991",
      "metadata": {
        "id": "d6775ab8dc85"
      },
      "source": [
        "## Test the agent locally"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "8d800dfd-1cf3-419b-a84a-5c3a655550cb",
      "metadata": {
        "id": "90be473ddf07"
      },
      "outputs": [],
      "source": [
        "# TODO for Developer: Update user_id\n",
        "\n",
        "import nest_asyncio\n",
        "\n",
        "nest_asyncio.apply()\n",
        "\n",
        "import asyncio\n",
        "\n",
        "# Create an agent engine instance\n",
        "agent_engine = agent_engines.create()\n",
        "app_name = agent_engine.name.split(\"/\")[-1]\n",
        "user_id = \"[session-user-id]\"\n",
        "\n",
        "# Create the ADK runner with VertexAiSessionService\n",
        "session_service = VertexAiSessionService(\n",
        "    project=PROJECT_ID, location=LOCATION, agent_engine_id=app_name\n",
        ")\n",
        "runner = adk.Runner(\n",
        "    agent=root_agent, app_name=app_name, session_service=session_service\n",
        ")\n",
        "\n",
        "\n",
        "# Helper method to send query to the runner\n",
        "async def call_agent_async(query, session_id, user_id):\n",
        "    content = types.Content(role=\"user\", parts=[types.Part(text=query)])\n",
        "    events = runner.run(user_id=user_id, session_id=session_id, new_message=content)\n",
        "    for event in events:\n",
        "        if event.is_final_response():\n",
        "            final_response = event.content.parts[0].text\n",
        "            print(\"Agent: \", final_response)\n",
        "\n",
        "\n",
        "async def main():\n",
        "    session = await session_service.create_session(app_name=app_name, user_id=user_id)\n",
        "    print(f\"Session created with ID: {session.id}\")\n",
        "    user_queries = [\n",
        "        \"trip to London\",\n",
        "        \"in Jan or Feb\",\n",
        "        \"suitable for aged people\",\n",
        "    ]\n",
        "    for user_query in user_queries:\n",
        "        print(f\"User Query: {user_query}\")\n",
        "        await call_agent_async(user_query, session.id, user_id)\n",
        "\n",
        "\n",
        "if __name__ == \"__main__\":\n",
        "    asyncio.run(main())"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "76ec3c5f-1c2e-401c-b389-5dfc3c8098df",
      "metadata": {
        "id": "8ad6030a1761"
      },
      "source": [
        "## Update the agent in agent engine"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "d6cb40dd-935f-4d42-8fca-99f82698b0e6",
      "metadata": {
        "id": "6cc73eaa5137"
      },
      "outputs": [],
      "source": [
        "# TODO for Developer: Update display_name (of agent)\n",
        "\n",
        "# create a callable session service builder that can use with AdkApp\n",
        "\n",
        "\n",
        "def session_service_builder():\n",
        "    return VertexAiSessionService(\n",
        "        project=PROJECT_ID, location=LOCATION, agent_engine_id=app_name\n",
        "    )\n",
        "\n",
        "\n",
        "# create the AdkApp with the session service\n",
        "adk_app = reasoning_engines.AdkApp(\n",
        "    agent=root_agent,\n",
        "    enable_tracing=True,\n",
        "    session_service_builder=session_service_builder,\n",
        ")\n",
        "\n",
        "# update the agent engine instance (created during local testing)\n",
        "remote_app = agent_engines.update(\n",
        "    display_name=\"[agent-display-name]\",\n",
        "    resource_name=agent_engine.name,\n",
        "    agent_engine=adk_app,\n",
        "    requirements=[\n",
        "        \"google-adk (==1.5.0)\",\n",
        "    ],\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "54f034af-c1fd-4365-8219-fbed0e16fba9",
      "metadata": {
        "id": "0108a0d59750"
      },
      "source": [
        "## Test the agent in agent engine"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "c2ab846f-baba-4657-b834-10cc09567475",
      "metadata": {
        "id": "f024562b934f"
      },
      "outputs": [],
      "source": [
        "# TODO for Developer: Update user_id\n",
        "\n",
        "user_queries = [\"trip to London\", \"in Jan or Feb\", \"suitable for aged people\"]\n",
        "user_id = \"[session-user-id]\"\n",
        "\n",
        "remote_session = remote_app.create_session(user_id=user_id)\n",
        "\n",
        "for user_query in user_queries:\n",
        "    print(f\"User Query: {user_query}\")\n",
        "    contents = types.Content(role=\"user\", parts=[types.Part.from_text(text=user_query)])\n",
        "    for event in remote_app.stream_query(\n",
        "        user_id=user_id, session_id=remote_session[\"id\"], message=contents.model_dump()\n",
        "    ):\n",
        "        if \"text\" in event[\"content\"][\"parts\"][0]:\n",
        "            print(f\"Agent: {event['content']['parts'][0]['text']}\")"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "f6be3a75-5cdd-4d1b-956a-211e1d8e4507",
      "metadata": {
        "id": "8adac8e3459c"
      },
      "source": [
        "## Register agent in Gemini Enterprise"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "245a96d4-cb28-4bde-b8a5-c2d8f5542092",
      "metadata": {
        "id": "3635a286d182"
      },
      "outputs": [],
      "source": [
        "%%bash\n",
        "\n",
        "curl -X POST \\\n",
        "-H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n",
        "-H \"Content-Type: application/json\" \\\n",
        "-H \"X-Goog-User-Project: [your-project-id]\" \\\n",
        "\"https://discoveryengine.googleapis.com/v1alpha/projects/[your-project-id]/locations/global/authorizations?authorizationId=travel\" \\\n",
        "-d '{\n",
        "\"name\": \"projects/[your-project-id]/locations/global/authorizations/travel\",\n",
        "\"serverSideOauth2\": {\n",
        "\"clientId\": \"[UPDATE-CLIENT-ID]\",\n",
        "\"clientSecret\": \"[UPDATE-CLIENT-SECRET]\",\n",
        "\"authorizationUri\": \"https://accounts.google.com/o/oauth2/v2/auth?client_id=[UPDATE-CLIENT-ID]&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&include_granted_scopes=true&response_type=code&access_type=offline&prompt=consent\",\n",
        "\"tokenUri\": \"https://oauth2.googleapis.com/token\"\n",
        "}\n",
        "}'"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "884de4d3-6f31-492c-9bc9-d4a65071126f",
      "metadata": {
        "id": "b33096f67166"
      },
      "outputs": [],
      "source": [
        "%%bash\n",
        "\n",
        "curl -X POST \\\n",
        "-H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n",
        "-H \"Content-Type: application/json\" \\\n",
        "-H \"X-Goog-User-Project: [your-project-id]\" \\\n",
        "\"https://discoveryengine.googleapis.com/v1alpha/projects/[your-project-id]/locations/global/collections/default_collection/engines/[your-app-id]/assistants/default_assistant/agents\" \\\n",
        "-d '{\n",
        "\"displayName\": \"DDL SQL Generator\",\n",
        "\"description\": \"SQL generation agent to help user with SQL queries for a give schema.\",\n",
        "\"adk_agent_definition\": {\n",
        "\"tool_settings\": {\n",
        "\"tool_description\": \"You are an expert SQL developer capable of understanding user queries and converting them to SQL\"\n",
        "},\n",
        "\"provisioned_reasoning_engine\": {\n",
        "\"reasoning_engine\": \"projects/[your-project-number]/locations/us-central1/reasoningEngines/[reasoning-engine-id]\"\n",
        "},\n",
        "\"authorizations\": [\"projects/[your-project-number]/locations/global/authorizations/travel\"]\n",
        "}\n",
        "}'"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "41f8a8fb-d1e5-426b-b824-959643a97b62",
      "metadata": {
        "id": "0a5c58d0b550"
      },
      "source": [
        "## Travel Agent in Gemini Enterprise\n",
        "\n",
        "![DDL based SQL query generator agent](https://services.google.com/fh/files/blogs/ss_travel_agent.png)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "name": "gemini_enterprise_session.ipynb",
      "toc_visible": true
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
