LlmAgent, give it Python functions as tools, and run it locally with adk web or deploy it as a container. ADK talks to Gemini natively and reaches every other model through LiteLLM.
Mesh plugs into that second path. Because Mesh speaks the OpenAI chat-completions dialect, a single LiteLlm connector points your ADK agents at Mesh — and from there at every model in the catalog, with your existing spend caps, rate limits, and usage logging. No Mesh-specific code goes into your agent.
Set the model to
auto and Mesh’s auto-router picks the model per request. Your ADK agent gets routing, fallback, and cost control without choosing a model at all.How it connects
openai/ prefix selects LiteLLM’s OpenAI-dialect transport. LiteLLM strips the prefix before sending, so Mesh receives the bare model name — auto, or any catalog id — and routes it like any other API call.
Install
ADK needs Python 3.10 or newer. Install ADK, LiteLLM, and themcp package together:
requirements.txt
Quickstart
ADK discovers agents by package layout. Create a directory whose__init__.py imports the agent module, and export a root_agent:
mesh_agent/__init__.py
mesh_agent/agent.py
.env
rsk_ key from Dashboard → API Keys. See Authentication for how rsk_ keys differ from mak_ admin keys.
Choosing the model
The string afteropenai/ is whatever Mesh should route. Both forms are valid:
- Auto-router (recommended)
- Pinned model
Tool calling
ADK generates the JSON schema for each tool from your function’s signature and docstring, and emits it in the standardtools format that Mesh already accepts — so tool calling works with no extra configuration. Write a real docstring with an Args: section: it becomes the tool description the model reasons over.
Keep tool functions returning a dict with an explicit status field. ADK passes the return value straight back to the model, and a model handles {"status": "error", "error_message": "..."} far better than a raised exception.
Streaming
Pass aRunConfig with SSE streaming to get incremental output:
Deploy
ADK ships a FastAPI app factory, so the agent runs anywhere that runs a container — Cloud Run, GKE, Agent Runtime, or plain Docker.main.py
Dockerfile
Known limitation: thought signatures
Mesh returns athought_signature on tool calls from Gemini thinking models, which the provider requires echoed back verbatim on the following turn to keep its reasoning chain intact.
LiteLLM’s OpenAI-dialect transport does not carry that field, so on a multi-turn tool call it is dropped and the model loses its thinking after the first turn. The agent still works and tools still run — the reasoning quality degrades quietly rather than failing.
Until this is resolved, pin ADK agents to a non-thinking model rather than relying on auto if your workload depends on multi-turn tool reasoning:
Troubleshooting
Related
- Auto-routing — how Mesh picks a model for
auto - Tool calling — the tool format ADK emits
- MCP Server — connect an MCP-compatible agent instead
- Authentication —
rsk_keys versusmak_admin keys