# Skill: agent_tool_execution ## Trigger Conditions Any change involving Gemma-4-E2B agent tools, Exa search, Supabase RAG RPC, or MedGemma escalation. ## Rules ### 1. Tool catalog is authoritative - Only use: `exa_search`, `supabase_query`, `escalate_medgemma`. - Never invent tool names in prompts or handlers. - Bump `TOOL_CATALOG_VERSION` on breaking schema changes. ### 2. Secrets and egress - `EXA_API_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, MedGemma keys: **backend only**. - Browser calls BFF routes; never `https://api.exa.ai` directly from the client. - PHI-scrub queries before any network egress ([`secrets_and_phi_safety`](../secrets_and_phi_safety/SKILL.md)). ### 3. Exa defaults (Pattern 1 — raw retrieval) ```json { "type": "auto", "numResults": 10, "contents": { "highlights": true } } ``` - Canonical reference: https://docs.exa.ai/reference/search-api-guide-for-coding-agents - Do not use deprecated params (`useAutoprompt`, top-level `highlights`, `livecrawl: "always"`). - `outputSchema` synthesis is BFF-only enrichment; not the default agent-loop path. ### 4. Retrieval policy (NFR-18) - `supabase_query` first for in-corpus MOH guideline grounding. - `exa_search` for external/recency queries. - Final clinical answers must cite chunk IDs (Supabase) or URLs (Exa). ### 5. MedGemma escalation - Requires consent + audit (NFR-16a) before `escalate_medgemma`. - No direct Modal URLs from the browser. ### 6. MediaPipe agent output - Parse tool calls from the **answer channel** when CoT is enabled. - One block per turn: `` OR ``. ## Package location [`ml/implementation/nlp/agent_runtime/`](../ml/implementation/nlp/agent_runtime/)