The open-source discovery agent for Knowledge Catalog (formerly Dataplex Universal Catalog) lets you find relevant data assets with complex or lengthy natural language queries. By using the Agent Development Kit (ADK), you can run this AI-powered assistant as the root agent or integrate it as a tool in a custom agent. For more information, see the discovery agent on GitHub.
Use cases
The discovery agent provides a rich, conversational experience for scenarios such as the following:
- Complex or combined intents and constraints: handle search requests
with multiple criteria, such as finding datasets in
us-central1but excluding resources in BigQuery. - Business-oriented search: discover data assets based on intent and business context rather than matching exact technical terms.
- Multi-turn exploration: refine your search through a conversational dialogue to narrow down results.
The discovery agent is built on top of Knowledge Catalog semantic search, which provides out-of-the-box hybrid search. By optimizing query understanding and formulation, the agent provides more accurate results than the standard Knowledge Catalog Search API, especially for complex or lengthy queries. You can continue to use Knowledge Catalog semantic search directly for high-intent searches (when you know the specific resource or column), low-latency queries, or zero-setup hybrid search. For more information, see Search for data assets in Knowledge Catalog.
How it works
The discovery agent performs the following steps to respond to a search query:
- Analyzes input for intent to understand the query, generates multiple search variations, and maps terms to metadata filters.
- Searches for resources using the Knowledge Catalog semantic search.
- Ranks the merged results based on relevance.
The following diagram provides the details of the process:
The agent relies on the Knowledge Catalog Search API to fetch relevant Google Cloud resources. The following code snippet shows how the agent calls Knowledge Catalog semantic search:
# Configure the request parameters for the
# call to Knowledge Catalog Semantic Search API.
endpoint = "dataplex.googleapis.com"
client = dataplex_v1.CatalogServiceClient(
client_options={"api_endpoint": endpoint}
)
location = "global"
consumer_project_id = "my-gcp-project"
parent_name = f"projects/{consumer_project_id}/locations/{location}"
# Call Knowledge Catalog Semantic Search API.
response = client.search_entries(
request={
"name": parent_name,
"query": query,
"page_size": 50,
"semantic_search": True,
}
)
# Call Knowledge Catalog LookupContext for each search result
# to retrieve rich, LLM-ready metadata.
entries = []
for result in response.results:
entry_name = result.dataplex_entry.name
# Prepare the LookupContext request for the specific resource
lookup_request = {
"name": parent_name,
"resources": [entry_name]
}
# Call the LookupContext API
lookup_response = client.lookup_context(request=lookup_request)
# Extract the rich context YAML to share with the agent
entries.append({
"entry_name": entry_name,
"context": lookup_response.context
})
return {"results": entries}
Before you begin
To run the Knowledge Catalog discovery agent, ensure that you meet the following requirements:
Required roles
To get the permissions that you need to use the discovery agent, ask your administrator to grant you the following IAM roles on your Google Cloud project:
- Dataplex Catalog Viewer (
roles/dataplex.catalogViewer) - Vertex AI User (
roles/aiplatform.user) - Service Usage Consumer (
roles/serviceusage.serviceUsageConsumer)
For more information about granting roles, see Manage access to projects, folders, and organizations.
These predefined roles contain the permissions required to use the discovery agent. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to use the discovery agent:
-
dataplex.projects.search -
dataplex.entries.get -
aiplatform.endpoints.predict -
serviceusage.services.use
You might also be able to get these permissions with custom roles or other predefined roles.
In addition to these roles on the project where you run the agent, you must
have read permissions on the underlying source system resources (for example,
BigQuery Metadata Viewer
(roles/bigquery.metadataViewer) for BigQuery assets). The
search_entries and lookup_context methods return results only from assets
that you have permission to access.
Enable APIs
To use the Knowledge Catalog discovery agent, enable the following APIs in your project: Dataplex API, Vertex AI API, and Service Usage API.
Roles required to enable APIs
To enable APIs, you need the serviceusage.services.enable permission. If you
created the project, then you likely already have this permission through the
Owner role (roles/owner). Otherwise, you can get this permission through the
Service Usage Admin role (roles/serviceusage.serviceUsageAdmin).
Learn how to grant roles.
Set up the environment
To set up the development environment for the discovery agent, do the following:
Clone the
dataplex-labsrepository:git clone https://github.com/GoogleCloudPlatform/dataplex-labs.git ~/dataplex-labsChange to the agent directory:
cd ~/dataplex-labs/knowledge_catalog_discovery_agentCreate and activate a Python virtual environment, and then install the dependencies listed in the
requirements.txtfile:google-adk(Agent Development Kit)google-cloud-dataplex(Knowledge Catalog Python client)google-api-core
python3 -m venv /tmp/kcsearch source /tmp/kcsearch/bin/activate pip3 install -r requirements.txtAuthenticate with Google Cloud and set the environment variables:
gcloud auth application-default login export GOOGLE_CLOUD_PROJECT=PROJECT_ID export GOOGLE_GENAI_USE_VERTEXAI=TrueReplace the following:
PROJECT_ID: the ID of your project.
Run the discovery agent as the root agent
To run the discovery agent directly as the root agent, do the following:
- In the
agent.pyfile located in theknowledge_catalog_discovery_agentfolder, addroot_agent = discovery_agentto the end of the file so the ADK CLI can load the discovery agent as the root agent. Run the agent using the
adk runcommand:adk run PATH_TO_AGENT_FOLDERReplace the following:
PATH_TO_AGENT_FOLDER: the path to theknowledge_catalog_discovery_agentdirectory. For example, use~/dataplex-labs/knowledge_catalog_discovery_agentor.if you're already in theknowledge_catalog_discovery_agentdirectory.
If prompted to enable telemetry on your first run, enter
yornand pressEnter:Enable telemetry? [Y/n]: yTo opt out of telemetry later, run
adk telemetry disable.Verify that the agent initializes and displays the interactive
[user]:prompt:Running agent knowledge_catalog_discovery_agent, type exit to exit. [user]:At the
[user]:prompt, enter natural language queries to discover and explore your data assets. Replace the example dataset and table names in the following scenarios with resources in your project:- Data exploration:
Show me all datasets in the us region.What is the sales_orders_us dataset about?Is there a demographic dataset I can join with my sales data?
- Metadata and governance discovery:
Show me if any tables in sales_orders_us are missing schemas or descriptions.Find all BigQuery tables related to customer accounts and summarize their schemas.
- Data exploration:
To exit the interactive session and close background connections cleanly, enter
exitat the[user]:prompt:[user]: exit
Run the discovery agent as an agent tool
To integrate the discovery agent into a larger custom agent, such as
my_custom_agent, do the following:
Create the
my_custom_agentdirectory and copy theknowledge_catalog_discovery_agentfolder into it:mkdir -p ~/dataplex-labs/my_custom_agent touch ~/dataplex-labs/my_custom_agent/agent.py cp -r ~/dataplex-labs/knowledge_catalog_discovery_agent ~/dataplex-labs/my_custom_agent/Verify that your
my_custom_agentdirectory has the following structure:my_custom_agent/ ├── agent.py └── knowledge_catalog_discovery_agent/ ├── SKILL.md ├── agent.py ├── tools.py └── utils.pyIn
~/dataplex-labs/my_custom_agent/agent.py, importdiscovery_agentand wrap it inagent_tool.AgentTool:from google.adk.agents import LlmAgent from google.adk.tools import agent_tool from .knowledge_catalog_discovery_agent.agent import discovery_agent GEMINI_MODEL = "gemini-2.5-flash" root_agent = LlmAgent( name="my_custom_agent", model=GEMINI_MODEL, instruction=( "You are a Custom Agent. Your goal is to help users understand" " their data landscape, evaluate data assets, and derive insights" " from available resources. **IMPORTANT**: You should use the" " `knowledge_catalog_discovery_agent` to search for and discover" " data assets. For best results, pass in the natural language user" " query as is to the `knowledge_catalog_discovery_agent`. Once" " assets are found, analyze their metadata, compare them, and" " provide recommendations or summaries to help the user make" " decisions. Focus on general metadata summary and comparison." ), tools=[ agent_tool.AgentTool(discovery_agent), ], )Run the custom agent using the
adk runcommand:adk run ~/dataplex-labs/my_custom_agentAt the
[user]:prompt, test the integration by asking the custom agent to discover and summarize assets:[user]: Search for all datasets in us-central1 and give me a summary of their business context.To exit the interactive session, enter
exitat the[user]:prompt:[user]: exit
What's next
Search syntax for Knowledge Catalog
Construct queries by combining natural language, metadata filters, qualified predicates, and logical operators.
Get started with ADK
Build, test, and orchestrate Python agents and agent tools by using ADK.
Knowledge Catalog use cases
Walk through end-to-end scenarios for context enrichment, data lineage, and generative AI workflows.