An ADK agent gains real abilities from tools, and the simplest tool is an ordinary Python function: the model never runs your code, it sends a structured request naming the tool and arguments it wants, your application executes the function, and the model reasons over the real result. Convert the function with the framework’s tool helper, add it to the agent’s tool list, and describe it plainly so the model knows when to call it.
What you need
- A Google ADK agent already running in the dev web interface
- A small Python function that fetches real data, such as a calculation
- A test question only the function can answer
Step 1: Write the function as a plain Python function
Write a small function with typed arguments and a clear docstring, doing one job such as calculating a value or looking up a record. Keep it to the one job the agent needs.
Step 2: Convert it to a tool and add it to the agent
Convert the function to a tool with the framework’s helper and add it to the agent’s tool list. The name and description are what the model reads to decide when to call it.
Step 3: Ask the test question and check the tool ran
Ask the test question in the web interface and confirm the tool call appears in the event trace and the answer uses the function’s result. If the agent answers without calling it, the description is too vague.
Worked example: synthetic function tool
The table below is a synthetic example. It shows the expected result of a function tool; no code was run.
| Check | Expected | Result |
|---|---|---|
| Tool call in the trace | Yes | Pass |
| Answer uses the result | Yes | Pass |
| No invented numbers | 0 invented | Pass |
Expected result (UNTESTED). the agent calls the function, the trace shows the call, and the answer uses the real result. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- The model never runs your code; your application executes the function and returns the result.
- Every tool you add is a permission you grant, so keep the function to the one job the agent needs.
- A function without a clear description will not be called, or will be called for the wrong questions.
