
- Conceptually, a tool is a function or method: it accepts structured inputs, performs an operation, and returns structured outputs.
- ADK exposes tool signatures to the LLM so the model can decide whether to call them. This is similar to LLM function-calling, but ADK adds richer typing and integration with your Python runtime.
- Tools use typed/structured inputs and return structured outputs (commonly small JSON-like dicts).
- ADK registers tool definitions and exposes them to the model; the LLM inspects signatures and decides whether to call a tool.
- When a tool is invoked, ADK runs the Python function and passes the structured result back to the model; the model formats a human-friendly response for the user.
| Resource type | When to use it | Notes / examples |
|---|---|---|
| Built-in tools | Common utilities and managed integrations provided by ADK/GCP | Examples: Google Search, code execution, BigQuery, Vertex AI RAG. These appear in IDE auto-complete and are available out of the box. |
| Custom function tools | Business logic, internal APIs, or system calls you implement in Python | Wrap directory lookups, ticket systems, service checks, or password reset flows. ADK can auto-wrap simple functions to expose them as tools. |
| Third-party tools | External services with OpenAPI or other standardized descriptors | Connectors for SaaS, monitoring systems, or vendor APIs using OpenAPI/MCP descriptions. |
ADK can auto-wrap simple Python functions and register them as tools when included in an agent’s tools list. The LLM will see the function signature and may call it when relevant.
- Goal: create an agent that can check whether a user exists in a directory. The custom function returns a small, typed dictionary the model can consume and present to the user.
- In production, replace the fake directory with your organization’s user directory, handle authentication, and return well-typed responses.
- User: “My email is broken; can you check my account? My address is alice@example.com.”
- The LLM reads the agent instruction and inspects available tool signatures.
- If useful, the model decides to call a tool (e.g.,
lookup_user). - ADK executes the Python function:
lookup_user("alice@example.com"). - ADK returns the structured result to the LLM.
- The LLM uses the tool output to generate a concise, human-facing reply.
- Type and validate outputs: return small, well-structured dicts (status codes, named fields) so the model can unambiguously interpret results.
- Handle errors explicitly: include clear
statusorerrorfields instead of free-form text. - Implement authentication and access control for tools that touch sensitive systems.
- Add rate limiting and retry policies where appropriate.
- Log tool calls and model decisions for auditing and debugging.
- In development, use IDE auto-complete to discover built-in ADK tools — but treat IDE hints as convenience, not authoritative runtime state.
- If the model seems unaware of a tool, confirm the function was registered in the agent’s tools list and that ADK had access to the function at agent creation time.
- Inspect structured tool outputs in logs to confirm the function returned the expected schema.
- Use concise, deterministic tool outputs to reduce hallucination risk (the model is less likely to invent results when the tool provides explicit status fields).
- Open agent.py and implement a real
lookup_userthat calls your directory service or database. - Add additional tools (service checks, ticket lookups, password reset helpers) and iteratively test how the agent chooses and composes tool calls end-to-end.