medication-companion
AGENTS.md1 starsChanged 5 months agoMITView on GitHub
This file follows the 2026 Kaggle AI Agents Intensive convention. It is the primary context file for coding agents (Cursor, Claude Code, Jules, etc.) working in this repository. Update it every time agent behaviour changes. Medication Companion is a multi-agent AI system (Google ADK + Gemini) that helps patients in India understand prescriptions and flag drug interactions across multiple visits. Stack: Python 3.11 · Google ADK · FastAPI · Flutter · GCP (Cloud Run, Vertex AI, Firebase) The drug lookup…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 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 repositoryOne other file it gives its agents.
- medication-companionCursor rule
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
17 rules. About 0 are common, 5 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 20
Never generate diagnostic language ("you have", "this indicates a condition")
- Distinctive: line 21
Every patient-facing string ends with "Please discuss this with your doctor or pharmacist."
- Distinctive: line 22
Never store prescription images or clinical notes in memory — only resolved generic drug names
- Very specific: line 23
Never call raw Gemini API — always use google.adk LlmAgent
- Very specific: line 24
Never use print() in production paths — use google.cloud.logging
- Very specific: line 25
Never deploy backend services with --allow-unauthenticated except the auth broker when fronted by Firebase Hosting rewrites (Google …
- Distinctive: line 119
Update this file first with the new rule or boundary
- Very specific: line 120
Update specs/ (scenario or schema) if behaviour changes
- Very specific: line 121
Update .cursor/rules/medication-companion.mdc if it affects agent/tool behaviour
- Very specific: line 122
Write the test in tests/unit/ or tests/integration/ before generating the implementation
- Very specific: line 124
Run uv run pytest tests/unit tests/integration — all tests must pass before committing
- Very specific: line 143
Do not add a new agent without updating the agent boundary table in .cursor/rules/
- Distinctive: line 144
Do not add a tool that calls another agent — tools are leaf nodes
- Very specific: line 145
Do not add GCP credentials to .env.example — that file is committed
- Very specific: line 146
Do not add new severity levels — only: HIGH, MODERATE, LOW, INFO, NONE
- Very specific: line 147
Do not add a new drug data source by hard-coding paths in tool files — add the source iterator to scripts/build_drug_index.py and rebuild …
- Very specific: line 149
Do not check raw Kaggle CSVs into git — only the curated india_brands.csv and the built drugs.db are committed
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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
AGENTS.md
This file follows the 2026 Kaggle AI Agents Intensive convention. It is the primary context file for coding agents (Cursor, Claude Code, Jules, etc.) working in this repository. Update it every time agent behaviour changes.
Project overview
Medication Companion is a multi-agent AI system (Google ADK + Gemini) that helps patients in India understand prescriptions and flag drug interactions across multiple visits.
Stack: Python 3.11 · Google ADK · FastAPI · Flutter · GCP (Cloud Run, Vertex AI, Firebase)
Hard rules (non-negotiable)
- Never generate diagnostic language ("you have", "this indicates a condition")
- Every patient-facing string ends with "Please discuss this with your doctor or pharmacist."
- Never store prescription images or clinical notes in memory — only resolved generic drug names
- Never call raw Gemini API — always use
google.adk LlmAgent - Never use
print()in production paths — usegoogle.cloud.logging - Never deploy backend services with
--allow-unauthenticatedexcept the auth broker when fronted by Firebase Hosting rewrites (Google requires public Cloud Run invoke;/upload-urland/prescriptionstill verify Firebase JWT). Agent Runtime stays private. patient_idcomes from verified Firebase JWT — never from client body
Workflow
backend/agents/ → agent logic (each agent is one file, one responsibility)
backend/tools/ → FunctionTools (one tool per file, fully typed, testable in isolation)
backend/memory/ → session + memory wrappers
backend/evaluation/→ LLM-as-Judge (async, non-blocking) + tool eval harnesses
frontend/lib/ → Flutter app
data/ → curated CSV (committed) + drugs.db SQLite index (committed)
deploy/ → deployment scripts
→ auth_broker/ (Cloud Run token broker)
→ legacy_cloud_run/ (archived FastAPI + A2A)
scripts/ → GCP setup/teardown + drug index builderDrug data sources
The drug lookup pipeline is backed by data/drugs.db, an SQLite index built
from three sources:
data/india_brands.csv(curated, ~300 rows, hand-maintained, highest priority)data/Extensive_A_Z_medicines_dataset_of_India.csv(Kaggle, ~250k brands)data/all_medicine databased.csv(Kaggle, fallback brand metadata)data/medicine_data.csv(Kaggle, primary drug-interaction source)
The Kaggle CSVs are NOT committed (see .gitignore). Drop them into data/
and run:
python scripts/build_drug_index.pyThis rebuilds data/drugs.db (~60 MB, committed). The build must be re-run
whenever a CSV is updated or a new source is added.
Lookup tiers in backend/tools/drug_lookup.py (first hit wins):
- curated CSV exact match (
source=csv, confidence=1.0) - SQLite exact match on normalized brand key (
sqlite_exact) - SQLite FTS5 prefix search (
sqlite_fts) - RapidFuzz Levenshtein fuzzy match with OCR-confusion folding (
fuzzy) - RxNav REST API (skipped when
ENVIRONMENT=local) - UNRESOLVED
Agent 3 (safety) calls interaction_lookup(generic_a, generic_b) on every
drug pair. The tool returns severity from the interactions table when
present; otherwise the LLM may fall back to pharmacological reasoning and
emit INFO.
Quality is gated by backend/tests/test_drug_lookup_eval.py, which exercises
the curated set, hand-crafted OCR-noise inputs, and negative cases.
Agent Runtime + auth broker
- Agent Runtime hosts the ADK pipeline (
backend/agent_runtime_app.py). Deploy withagents-cli deploy; do not expose it directly to clients. - Auth broker (
backend/auth_broker/) is the only client-facing HTTP API. It verifies Firebase JWTs, issues GCS signed upload URLs, and proxies to Agent Runtime using service-account credentials. patient_idis always derived from the verified Firebase UID in the broker.- Image transport: client uploads to GCS via signed URL, then sends
gs://URI to/prescription. Agent 1 reads the image viaPart.from_uri. - Local dev:
make local-auth-broker(HTTP token broker on :8080). SetUSE_LOCAL_RUNNER=trueto run the pipeline in-process without a deployed Agent Runtime (broker still uses real GCS for uploads). - Pub/Sub ambient-agent wiring (Day 4 follow-up) is a separate concern — do not conflate it with this HTTP auth broker.
- Operational deploy commands (Agent Runtime, auth broker, Firebase Hosting,
incremental updates) live in
docs/deployment_runbook.md.
Instruction hierarchy (Day 5)
Layered instructions — check the most specific layer first:
| Layer | Location | Purpose |
| Chat | Cursor / Jules session | Short-lived task orchestration |
| Specs | specs/ | Gherkin scenarios + flat YAML schemas (source of truth) |
| Agent skills | .agent/skills/ | Reusable feature workflows |
| Model overrides | backend/agents/GEMINI.md | Per-agent Gemini config |
| Global DNA | This file + .cursor/rules/medication-companion.mdc | Hard rules |
For evidence-driven debugging, use templates in docs/forensic_prompts.md.
Adding a new feature
- Update this file first with the new rule or boundary
- Update
specs/(scenario or schema) if behaviour changes - Update
.cursor/rules/medication-companion.mdcif it affects agent/tool behaviour - Write the test in
tests/unit/ortests/integration/before generating the implementation - Implement in the appropriate
agents/ortools/file - Run
uv run pytest tests/unit tests/integration— all tests must pass before committing - For production incidents, start from
docs/forensic_prompts.md
Environment setup
cd backend
cp ../.env.example .env.local
# Set MEMORY_BACKEND=local for development (no GCP credentials needed)
pip install -r requirements.txt
pytest tests/What not to do
- Do not add a new agent without updating the agent boundary table in
.cursor/rules/ - Do not add a tool that calls another agent — tools are leaf nodes
- Do not add GCP credentials to
.env.example— that file is committed - Do not add new severity levels — only:
HIGH,MODERATE,LOW,INFO,NONE - Do not add a new drug data source by hard-coding paths in tool files —
add the source iterator to
scripts/build_drug_index.pyand rebuilddata/drugs.db - Do not check raw Kaggle CSVs into git — only the curated
india_brands.csvand the builtdrugs.dbare committed
Known follow-ups (post-capstone)
Full product backlog: docs/BACKLOG.md.
- Bind GCS upload URI to authenticated patient.
/prescriptionmust not accept agcs_uriissued to a different Firebase UID. Required before public launch; not capstone-blocking. See BACKLOG for options. - Migrate
SequentialAgent→Workflow(graph DAG).google-adk2.3.0 deprecatesSequentialAgent; the new graph-basedWorkflowAPI (Node,Edge,JoinNode,START) is the long-term replacement but is a real refactor — callback model differs and the Agent RuntimeAdkAppwrapper must be re-validated. Deprecation warning is filtered inpyproject.tomluntil then.
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.

