adk-recipes / genmedia-for-commerce
AGENTS.md10k starsChanged 2 months agoApache-2.0View on GitHub
A clone-and-study full-stack, multi-agent ADK app that generates retail media — Virtual Try-On (VTO) images/videos, 360° product spins (Reference-to-Video / R2V), product fitting on a virtual model, and background swaps — by orchestrating Gemini and Veo 3.1 through multi-stage media pipelines. The interesting part is not the router agent (a thin ADK wrapper around one MCP toolset); it's the MCP tool server + workflow pipelines (framing → parallel Veo generation → automated validation/retry), the in-memory catalogue vector search, and the…
- Reads credentials
- Installs packages
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/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/rag-vector-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
1 rule. About 0 are common, 0 are distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
Run with make eval (default basic.evalset.json) or make eval-all (loops every tests/eval/evalsets/*.evalset.json).
≈ “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
GenMedia for Commerce — Full-Stack Multi-Agent Retail Media
Intent
A clone-and-study full-stack, multi-agent ADK app that generates retail media — Virtual Try-On (VTO) images/videos, 360° product spins (Reference-to-Video / R2V), product fitting on a virtual model, and background swaps — by orchestrating Gemini and Veo 3.1 through multi-stage media pipelines. The interesting part is not the router agent (a thin ADK wrapper around one MCP toolset); it's the MCP tool server + workflow pipelines (framing → parallel Veo generation → automated validation/retry), the in-memory catalogue vector search, and the full app stack (FastAPI + React + Terraform + Agent Engine / Gemini Enterprise registration).
When To Use
- The user wants an orchestrator agent that drives multi-stage media-generation pipelines (framing → generation → validation/retry) instead of a single tool call.
- The user wants a reference for exposing generation workflows as MCP tools and wiring them into an ADK agent, a FastAPI REST surface, and a React frontend.
- The user needs a Veo/Gemini retail-media example with automated quality validation (rotation-consistency + glitch detection) and ADK eval sets.
Eval
- Scenarios Path:
tests/eval/evalsets/(config:tests/eval/eval_config.json) - Minimum Score: two weighted criteria, each
threshold: 0.5—tool_trajectory(weight 0.6,tool_name_match: flexible) +response_match_v2(weight 0.4);num_runs: 1. - Run with
make eval(defaultbasic.evalset.json) ormake eval-all(loops everytests/eval/evalsets/*.evalset.json). Both calladk eval. Cases mix tool-trajectory checks (e.g.route_product_fittingasserts aproduct_fittingcall withgender/ethnicityargs) with reference behavior checks (e.g.ask_for_missing_params).
End-to-end flow
user (React frontend / ADK web / Gemini Enterprise)
-> root_agent "genmedia_router" (genmedia4commerce/agent.py)
- before_model_callback: uploads described by Gemini, pushed to GCS,
inline bytes replaced with [user_upload | filename | description]
-> McpToolset -> GenMedia MCP server (mcp_server/server.py, 7 tools)
- before_tool_callback resolves filenames -> base64 from GCS
-> media workflow pipeline (workflows/<capability>/):
framing/canvas -> parallel Veo 3.1 / Gemini generation
-> automated eval + (spinning) rotation/glitch validation & retry
-> after_tool_callback: generated media saved as ADK artifacts + GCS,
LLM sees only a text summary (no base64 blobs in context)
-> frontend renders artifacts; history persisted to GCS per sessionMost interesting files to study (in order)
MCP tool server (the tool surface)
genmedia4commerce/mcp_server/server.py— aFastMCPserver (genmedia-retail) exposing 7 tools:product_fitting,image_vto,video_vto,background_changer,product_spinning,animate_model,catalog_search. Each@server.tool()is a thin async wrapper that JSON-encodes the result of arun_*workflow. Runs over stdio (for the ADK agent subprocess) or SSE (--transport sse, for external clients).
Media-generation workflows (the bulk of the logic)
genmedia4commerce/workflows/— the real pipelines, grouped by capability:video_vto/(clothes catwalk + glasses),image_vto/(static clothes/glasses VTO with evaluation ranking),spinning/(shoe & product 360° R2V + interpolation),product_enrichment/product_fitting/(front/back views on a model body),other/background_changer/, andshared/(Gemini/Veo/image/video/GCS utilities). Each*/pipeline.pyis the entry the matching*_mcp.pycalls.genmedia4commerce/workflows/spinning/r2v/shoes/pipeline.py— the richest pipeline: classify shoe angle/closure → select & stack images (Veo caps reference images at 3) → generate → validate. Study its two validators:video_validation_r2v.py(validate_and_fix_product_spin_consistency_r2v, rotation-direction + glitch checks with retry) andproduct_consistency_validation.py(validate_product_consistency).genmedia4commerce/workflows/shared/vector_search.py— the catalogue backend: an in-memory dot-product search over pre-computed embeddings (numpy) +metadata.parquet(pyarrow), Matryoshka-truncated to 128d, withaudience/season/etc. filters. No managed index — assets are pulled from GCS at import. Read side ofcatalog_search.genmedia4commerce/workflows/shared/—veo_utils.py(Veo R2V calls),image_utils.py(framing, canvas, background removal),video_utils.py,llm_utils.py,gcs_utils.py,person_eval.py— the reusable primitives every pipeline composes.
App stack & infrastructure
genmedia4commerce/fast_api_app.py(+chat_api.py) — the combined server:get_fast_api_app(ADK/run, sessions, optional web UI) plus everymcp_server/*/*_api.pyREST router, a/feedback+/health+/api/statusendpoint, an embedded MCP server on a daemon thread (SSE), and SPA/static mounts for the built React app. This is the Cloud Run entrypoint.genmedia4commerce/agent_engine_app.py(+genmedia4commerce/app_utils/deploy.py) — the Agent Engine path: wrapsagent.appin anAdkAppsubclass (AgentEngineApp) with telemetry, GCS artifacts, and aregister_feedbackop.make deploy-agent-engineexports requirements and callsgenmedia4commerce.app_utils.deploy.infra/terraform/— GCP provisioning:main.tf(APIs),storage.tf(media bucket${project_id}-genmedia-for-commerce-media-payloads),artifact_registry.tf,cloudrun.tf,iam.tf.infra/model_training/— optional Gemini LoRA shoe-side classifier fine-tune/eval (make train-shoe-model/make eval-set-shoe-model).
Agent + frontend (thin layer — read last)
genmedia4commerce/agent.py—root_agent(genmedia_router, Gemini) andapp. Thin on routing (oneMcpToolset), but carries the recipe's callback machinery:before_model(GE-stable session id, upload → describe → GCS),after_model(inject[session_id=...]),before_tool(filename → base64),after_tool(media → artifacts + GCS, summary to LLM).genmedia4commerce/agent_utils.py— the helpers behind those callbacks: GCS-backed conversation history (append_to_history/retrieve_from_history),upload_asset_to_gcs/copy_gcs_asset,resolve_filename_to_gcs_uri,extract_media/resolve_media, and parallel image description.genmedia4commerce/agents/style_advisor_agent/agent.py— a second, self-contained multi-agent app: astyle_advisorsearcher that delegates to astylish_agentcurator sub-agent (sub_agents=[...]). Its ownApp(...); not wired into the router. Read for the ADK sub-agent pattern.frontend/— the React + Vite UI (genmedia-studio-frontend), with per-capability views (image_vto/,video_vto/,spinning/,product_enrichment/). Talks to the FastAPI REST + ADK API; built and served byfast_api_app.pyin production.
Data handling
- Session state & history are GCS-backed, not in ADK memory. All media +
history.jsonlive undersessions/<global_session_id>/inMEDIA_BUCKET = ${project_id}-genmedia-for-commerce-media-payloads(user_uploads/,generated_assets/). A stable global session id is injected as[session_id=...]so the Gemini Enterprise playground (which rotates session ids each turn) keeps a consistent storage key. - Base64 never enters LLM context. Uploads are described by Gemini and
replaced with
[user_upload | filename | description]; tool outputs are saved as artifacts + GCS and reduced to a text summary. Filenames followTIMESTAMP_TYPE_INDEX.EXT(_u_upload,_c_catalog,_g_generated);before_toolresolves them back to bytes from GCS. - Catalogue = in-memory vector search.
workflows/shared/vector_search.pyloads pre-computed embeddings +metadata.parquetinto RAM and does dot-product similarity (128d Matryoshka slice) with metadata filters. Assets auto-download at import from a hash-named GCS bucket viaconfig.pull_assets()(make setup-infrarunspull-assetsfirst). - Model names are env-driven (
MODEL_NAME_GENERATED_*,EMBEDDING_MODEL,MULTIMODAL_EMBEDDING_MODEL); the router model isconfig.agent_model(MODEL_NAME_GENERATED_1).
Gotchas / things to know
config.envvs.env. The runtime loads the package-internalgenmedia4commerce/config.env(a gitignored build artifact). The rootconfig.envis the source of truth —make sync-configcopies it in, and most targets depend on it. Copyconfig.env.example→config.envfirst..env.examplemodel literals are deprecated.MODEL_NAME_GENERATED_*captures the original recipe (gemini-3.6-flash, …). Per the repoAGENTS.mdmodel policy, review/replace withgemini-3.6-flashbefore use.- The
evalextra is intentionally empty.google-adk[eval]/aiplatform[evaluation]capscikit-learn<=1.5.2, which conflicts with the image code'sscikit-learn>=1.7.2.make evalworks via the basegoogle-cloud-aiplatform[...,evaluation]dependency; installgoogle-adk[eval]separately only if you need those extras. - Heavy dependency set (OpenCV, moviepy, rembg, insightface, onnxruntime,
scikit-image).
uv syncis slow and pulls large ML wheels;make installalso installsg++/build tools. - Live GCP is required at runtime (Vertex AI / Veo / Gemini, GCS). Config
probes Vertex at import (
test_vertex_connection). The runnability test (tests/test_runnability.py) patchesgoogle.auth.defaultand only asserts thatroot_agent/appimport and are non-None. - MCP transport is dual. The ADK agent connects over SSE when
MCP_SERVER_URLis set, else spawns the server as a stdio subprocess. In Cloud Run the server also runs embedded on an SSE daemon thread insidefast_api_app.py. - Deployment is multi-step, two targets.
deploy-agent-engineships the agent only (no REST/VTO endpoints);deploy-cloudrunships the full stack. Both needmake setup-infrafirst.
Where to run things
Makefile targets:
- Setup:
make install,make sync-config,make setup-infra(Terraform +pull-assets),make tf-plan,make tf-destroy. - Local:
make playground(ADK web UI),make dev(backend + frontend),make run-backend,make run-frontend,make mcp-server(standalone SSE). - Quality:
make test(unit + integration),make eval/make eval-all,make lint(codespell + ruff + ty). - Deploy:
make deploy-agent-engine,make deploy-cloudrun,make register-gemini-enterprise. - Shoe classifier (optional):
make train-shoe-model,make eval-set-shoe-model.
Eval lives under tests/eval/ (eval_config.json + evalsets/).
Reuse (copy as-is)
genmedia4commerce/mcp_server/is a self-contained FastMCP server — run it standalone (python -m mcp_server.server/make mcp-server) and connect any MCP client. It importsgenmedia4commerce/workflows/, so copy the two together (the workflows are the actual generation logic).infra/terraform/is self-contained GCP provisioning (media bucket, AR repo, Cloud Run service, IAM, APIs).make setup-infraderivesTF_VAR_*fromconfig.env; setPROJECT_ID(and Cloud Run knobs) there.frontend/is a standalone React + Vite app with its ownpackage.json—npm install && npm run buildand point it at the backend's REST + ADK API.- There is no hard coupling from the agent to the workflows:
agent.pyreaches every capability purely through the MCP toolset (stdio subprocess or SSE viaMCP_SERVER_URL).
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.

