This document describes how to create a data agent in Spanner Studio using an agent context file. A data agent is associated with a single agent context file.
To learn about data agents, see Data agents overview.Before you begin
Complete the following prerequisites before creating an agent.
Enable required services
Enable the following services for your project:
Prepare a Spanner instance
- Make sure that a Spanner instance is available. For more information, see Create an instance.
- Populate the database with the data and schema that the end user wants to access.
Required roles and permissions
- Add an IAM user or service account to the cluster. For more information, see Apply IAM roles.
- Grant the
spanner.databaseReaderroles to the IAM user at the project level. For more information, see Add IAM policy binding for a project. - Grant roles and permissions to the IAM user at the project-level for the required databases.
Create a data agent
To create a data agent, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select a database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Data Agents, click View actions.
Click Create agent.
In Agent name, provide a unique agent name. The agent name is case-sensitive and can contain letters, numbers, hyphens, and underscores.
Optional. In Agent description, add a description for your agent.
Optional. Click Show Advanced Options and in Select a location, select a region for storing agent context.
Click Create.
Build agent context
After creating an agent, follow the steps in Build contexts using Gemini CLI to create an agent context file. You can then edit your agent to upload the context file.
Edit an agent
To edit a data agent, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select a database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Data Agents, click View actions.
Click Edit agent.
Optional: Edit Agent description.
Click Browse in the Upload agent context file section, and select the agent context file.
Click Save.
Delete a data agent
To delete a data agent, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select a database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Data Agents, click View actions.
Click Delete agent.
In the Delete agent confirmation dialog, enter the name of the agent.
Click Confirm to delete the agent.
What's next
- Learn more about data agents.
- Learn how to inspect and call a data agent.