# ADK 2.x Cheatsheet Comandos, schemas YAML, gotchas. **Versión pineada del template: `ibm-watsonx-orchestrate==2.1.0`**. > `./scripts/check-adk-version.sh` te avisa si hay versión nueva en PyPI. ## Setup del ADK ```bash python3.12 -m venv .venv-wxo source .venv-wxo/bin/activate pip install --upgrade "ibm-watsonx-orchestrate==2.1.0" orchestrate --version # debe imprimir 2.1.x ``` ## Environments ```bash # Registrar tenant orchestrate env add -n mi-tenant \ --iam-url https://iam.cloud.ibm.com/identity/token \ -u "$ORCHESTRATE_API_URL" # Activar (pide API key, lo guarda en keyring) orchestrate env activate mi-tenant # Listar orchestrate env list # Borrar orchestrate env remove -n mi-tenant ``` ## Modelos disponibles ```bash orchestrate models list # todos orchestrate models list | grep gpt-oss # filtro ``` **Preferred para tool-calling:** `groq/openai/gpt-oss-120b` **Fallback:** `meta-llama/llama-3-3-70b-instruct` (con caveat — ver `known-issues.md`) ## Conexiones ```bash # Crear orchestrate connections add -a mi_app # Configurar tipo (key_value | api_key | bearer | oauth2) # IMPORTANTE: hacerlo en draft Y live orchestrate connections configure -a mi_app --env draft --type team --kind key_value orchestrate connections configure -a mi_app --env live --type team --kind key_value # Credenciales orchestrate connections set-credentials -a mi_app --env draft -e "BASE_URL=https://..." orchestrate connections set-credentials -a mi_app --env live -e "BASE_URL=https://..." # Para API key con header custom (estilo Dun): orchestrate connections set-credentials -a mi_app --env draft \ -e "X_API_KEY=secreto" -e "API_KEY_HEADER=X-Orchestrate-Token" # Listar orchestrate connections list ``` ## Tools ### Python `@tool` ```bash orchestrate tools import -k python \ -f wxo/tools/python/mi_tool.py \ -r wxo/tools/python/requirements.txt \ --app-id mi_app ``` Cada función decorada con `@tool(...)` se descubre y registra. Si tu archivo tiene 6 funciones decoradas → 6 tools. ### OpenAPI ```bash orchestrate tools import -k openapi \ -f wxo/tools/openapi/mi_spec.yaml \ --app-id mi_app ``` Pre-requisitos del spec: - OpenAPI 3.0 o 3.1 - `description` per-operation (no solo `summary`) - `security` per-operation (no global) - `servers[0].url` apuntando al host correcto (patch en deploy time) ### MCP ```bash orchestrate connections add -a mi_mcp_app orchestrate connections configure -a mi_mcp_app --env draft --type team --kind mcp orchestrate connections set-credentials -a mi_mcp_app --env draft \ -e "MCP_SERVER_URL=https://mi-mcp-server.example.com" ``` ADK descubre las tools del MCP server automáticamente. ## Knowledge bases ```bash orchestrate knowledge-bases import -f wxo/knowledge_base/mi_kb.kb.yaml orchestrate knowledge-bases list ``` Schema YAML mínimo: ```yaml spec_version: v1 kind: knowledge_base name: mi_kb description: "..." documents: - "runbooks/runbook-01.txt" - "runbooks/runbook-02.txt" embeddings: model: ibm/slate-125m-english-rtrvr ``` Los paths de `documents` son relativos al directorio del YAML. ## Agentes ```bash # Import (al draft env) orchestrate agents import -f wxo/agents/mi_agente.agent.yaml # Deploy a live orchestrate agents deploy --name mi_agente --env live # Listar orchestrate agents list # Test con fixture orchestrate agents test mi_agente --input-file evals/scenarios/test1.json ``` Schema YAML mínimo de un agente: ```yaml spec_version: v1 kind: native name: mi_agente display_name: "Mi Agente" description: "..." style: react llm: groq/openai/gpt-oss-120b instructions: | Eres ... collaborators: [] tools: [] knowledge_base: [] starter_prompts: is_default_prompts: true prompts: [] ``` ## Canales ```bash # Web chat orchestrate channels create webchat \ --agent mi_agente \ --name "Mi Agente - Web" # Listar orchestrate channels list ``` El comando imprime el snippet `