1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
28 small wins to finish your pathNext lesson →
A function, before any of this
Before ADK does anything for you, it is worth seeing the piece it works with. It is a Python function, and you already know how to write one.
Here is the whole of what a support agent needs on day one: something that looks an order up.
def lookup_order(order_id):
return f"Order {order_id} shipped on 3 March."
print(lookup_order("A17"))No agent, no model, no toolkit. You call it, it answers. Everything the rest of this course does is arranged around functions exactly like this one.
Two small additions
Two things turn an ordinary function into one an agent can use well. A type hint, so it is clear what the argument is, and a docstring, so it is clear what the function is for.
def lookup_order(order_id: str) -> str:
"""Look up the status of an order by its id."""
return f"Order {order_id} shipped on 3 March."
print(lookup_order("A17"))Same output. The hint and the docstring changed nothing about how it runs, and they are the two things ADK reads in the next lesson.
Why this matters later
- The docstring is not a comment. It becomes the description a model reads when deciding whether to call this.
- The type hint is not decoration. It becomes the argument the model is allowed to send.
- The name matters. It becomes the name of the tool.
Write it for a reader
If you are used to writing code nobody reads, this is the habit to change first. Everything you would have written for a colleague is now read by the model as well.
Try it yourself
- Add a second parameter with a type hint and call the function again.
- Write the docstring twice: once vaguely, once precisely. Keep the precise one.
You understood something today that you didn't yesterday.