adk-recipes / rag-vector-search
AGENTS.md10k starsChanged 2 months agoApache-2.0View on GitHub
A clone-and-study RAG agent grounded on Vertex AI Vector Search 2.0, with a Kubeflow Pipelines (KFP) pipeline that loads, chunks, and ingests documents into a Collection that auto-generates embeddings server-side. The hard/interesting parts are Terraform (Collection + auto-embedding config + IAM) and data handling (the ingestion pipeline); the agent itself is a thin ADK wrapper around a semantic-search tool. - The user wants explicit control over chunking/ingestion (a custom KFP pipeline) instead of a fully-managed connector. - The user needs…
- Reads credentials
Trending
More talk lately.thin dataabout the whole repository
Who's talking about google/adk-recipes
The biggest 1 of 1 mention linking to the repository that our crawl found. Each line is their own headline.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- contrib/kotlin/llm-auditor/AGENTS.mdAGENTS.md
- core/python/ambient-expense-agent/AGENTS.mdAGENTS.md
- core/python/cross-session-memory/AGENTS.mdAGENTS.md
- core/python/deep-search/AGENTS.mdAGENTS.md
- core/python/genmedia-for-commerce/AGENTS.mdAGENTS.md
- core/python/long-horizon-harness/AGENTS.mdAGENTS.md
- core/python/oauth-user-consent-flow/AGENTS.mdAGENTS.md
- core/python/rag-agent-search/AGENTS.mdAGENTS.md
- core/python/safety-plugins/AGENTS.mdAGENTS.md
- align-recipe-pyprojectSkill
- extract-python-environment-variablesSkill
- generate-manifestSkill
- generate-python-runnability-testSkill
- github-pr-reviewSkill
- make-python-recipe-deployableSkill
- prepare-python-recipeSkill
- repo-oracleSkill
- scaffold-python-recipeSkill
- blog-writerSkill
- content-research-writerSkill
- bootstrap-google-toolsSkill
- find-skillsSkill
- google-workspaceSkill
- policySkill
- routinesSkill
- retail-product-searchSkill
- retail-virtual-tryonSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Minimum Score: not enforced — custom_response_quality graded 1–5 (aim ≥ 4)
- Very specific: line 96
Embeddings: never computed in the pipeline.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
RAG Agent — Vector Search
Intent
A clone-and-study RAG agent grounded on Vertex AI Vector Search 2.0, with a Kubeflow Pipelines (KFP) pipeline that loads, chunks, and ingests documents into a Collection that auto-generates embeddings server-side. The hard/interesting parts are Terraform (Collection + auto-embedding config + IAM) and data handling (the ingestion pipeline); the agent itself is a thin ADK wrapper around a semantic-search tool.
When To Use
- The user wants explicit control over chunking/ingestion (a custom KFP pipeline) instead of a fully-managed connector.
- The user needs semantic/vector search over their own documents with server-side auto-embedding (Vector Search 2.0).
- The user wants a reproducible BigQuery-staged ingestion + Terraform example.
Eval
- Scenarios Path:
tests/eval/datasets/(config:tests/eval/eval_config.yaml) - Minimum Score: not enforced —
custom_response_qualitygraded 1–5 (aim ≥ 4)
End-to-end flow
- Terraform (
make setup-infra) enables APIs, creates a pipeline GCS bucket, a runner service account + IAM, and a VS 2.0 Collection whosetext_embeddingfield is configured to auto-embed withgemini-embedding-001. - Ingestion (
make data-ingestion) runs a KFP pipeline that fetches docs, converts HTML→markdown, chunks them, stages + dedups them in BigQuery, then batch-creates data objects in the Collection. Embeddings are generated by the Collection, not the pipeline (objects are sent with empty vectors). - Agent (
make playground) answers questions; itsretrieve_docstool runs semantic search over the Collection and feeds chunks back to Gemini.
Most interesting files to study (in order)
Data ingestion (the bulk of the logic)
data_ingestion/data_ingestion_pipeline/components/process_data.py— the core transform. A KFP@componentthat: fetches data (a synthetic Q&A CTE in BigQuery — the documented place to swap in your own source), converts HTML→ markdown (markdownify), chunks withRecursiveCharacterTextSplitter(chunk_size=1500,chunk_overlap=20), writes a time-partitioned incremental table, and builds a deduped table (latestcreation_timestampperquestion_id). Note the deterministicchunk_id=question_id__<index>that makes re-ingestion idempotent.data_ingestion/data_ingestion_pipeline/components/ingest_data.py— how data lands in VS 2.0: reads the deduped table and callsbatch_create_data_objectswith emptyvectors: {}(auto-embedding), capped at 250 objects/batch, swallowingAlreadyExistsso re-runs skip existing chunks.data_ingestion/data_ingestion_pipeline/pipeline.py— KFP wiring:process_data→ingest_datawithset_retry. Small but shows the DAG and parameters.data_ingestion/data_ingestion_pipeline/submit_pipeline.py— run modes:--local(KFPSubprocessRunner, whatmake data-ingestionuses) vs remote (aiplatform.PipelineJob.submit), plus--cron-schedule/--schedule-onlyforPipelineJobSchedule. Readparse_argsfor the env-var contract.data_ingestion/README.md— the ingestion runbook (local + remote).
Terraform (provisioning + the embedding config)
infra/terraform/scripts/setup_vector_search_collection.py— the most important infra file. Defines the Collection'sdata_schema(question_id,text_chunk,full_text_md) and thevector_schema.text_embeddingauto-embedding config:dense_vectordimensions=3072,vertex_embedding_configmodel_id=gemini-embedding-001,text_template="{text_chunk}",task_type=RETRIEVAL_DOCUMENT. Idempotent via aget_collectioncheck. (delete_vector_search_collection.pyis the teardown.)infra/terraform/vector_search.tf— the pipeline bucket plus anull_resourcethat runs the create script on apply and the delete script ondestroy(local-exec+triggers). Good example of wrapping an API not yet in the provider.infra/terraform/vector_search_iam.tf+vector_search_variables.tf— runner service account and itspipelines_roles(BigQuery, Storage, Vertex AI,vectorsearch.dataObjectWriter), assigned viasetproduct.infra/terraform/apis.tf— enabled services (notevectorsearch.googleapis.com) and the Vertex AI service identity.locals.tf,variables.tf,datastore_outputs.tf,vars/env.tfvarsare the supporting scaffolding.
Agent (thin layer — read last)
app/retrievers.py—search_collection():SemanticSearchwithsearch_field="text_embedding",task_type="RETRIEVAL_QUERY",top_k, andoutput_fields(question_id,text_chunk,full_text_md). These fields must match the schema set insetup_vector_search_collection.py— that symmetry between write-side and read-side is the key thing to notice.app/agent.py— ADKAgent(Geminigemini-flash-latest) exposing theretrieve_docstool (wrapssearch_collectionwith error handling); readsVECTOR_SEARCH_COLLECTIONfrom env.app/__init__.pyexportsapp.
Data handling
- Chunking: recursive character splitting (1500/20). Tune in
pipeline.pydefaults orprocess_dataargs. - BigQuery staging: an append-only incremental table feeds a replace-mode
deduped table (one row per chunk from the latest ingestion of each
question_id) — the deduped table is the ingestion source of truth. - Embeddings: never computed in the pipeline. Objects ship with empty vectors
and VS 2.0 embeds them server-side using the Collection's
text_embeddingconfig. The read path uses the same model implicitly viaRETRIEVAL_QUERY. - Idempotency: deterministic
chunk_id+AlreadyExistsskip means re-runs don't duplicate. Caveat: if a doc's chunk count shrinks, orphaned chunks from a prior run are not deleted.
Gotchas / things to know
- Order matters:
make setup-infra→make data-ingestion→ query. Querying before ingestion returns "No relevant documents found." google-cloud-vectorsearchis the v1beta preview API (vectorsearch_v1beta).- The integration test (
tests/integration/test_agent.py) makes a live Gemini call; it is skipped without ADC, and the retriever is mocked whenINTEGRATION_TEST=TRUE(set bymake test). app/agent.pyloads.envand resolves the project fromGOOGLE_CLOUD_PROJECT, falling back togoogle.auth.default()at import when it is unset — so credential-less imports fail unless that var is set (the test imports lazily to allow skipping).- The default dataset is synthetic Q&A generated inline in BigQuery; replace
the CTE in
process_data.fetch_sample_datato ingest real documents. tests/eval/eval_config.yamluses theagents-clieval format (LLM-judgecustom_response_quality+ a turn-count function); it is not wired intomake test.
Where to run things
Makefile targets: make setup-infra (provision), make install,
make data-ingestion (run the KFP pipeline locally), make playground
(local ADK web UI), make test, make lint.
Eval lives under tests/eval/ (eval_config.yaml + datasets/).
Reuse (copy as-is)
infra/terraform/(Collection + IAM) is self-contained — copy the whole directory (includingscripts/) and setproject_idinvars/env.tfvars. Requiresuvfor thelocal-execprovisioner scripts.data_ingestion/is an independent, self-contained KFP project (its ownpyproject.toml+uv.lock) — copy the directory and run it standalone. Point it at your Collection via--project/--region/--collection-id, and swap thefetch_sample_dataCTE inprocess_data.pyfor your own source.deployment/cloudbuild.yamlschedules the ingestion pipeline in CI viasubmit_pipeline.py(a recurring Vertex AIPipelineJobSchedule) — copy it and set the_*substitutions.- There is no code coupling to
app/: the agent reaches the Collection purely through theVECTOR_SEARCH_COLLECTIONenv var.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

