Lesson 16 — Observations back into the conversation
The model only knows what you tell it
An observation is the result of a tool call, written back into the message list. The model has no other way to learn it: if you run the tool but forget to add the result, the next call looks exactly like the last one — and the model asks for the same tool again.
So each step adds two messages:
- the model's tool call, as an
"assistant"message; - the tool's result, as a
"tool"message (with the tool's name).
Real APIs do the same with small differences: OpenAI uses "role": "tool"; Anthropic puts a tool_result block inside a "user" message.
Why it matters: "the agent keeps repeating itself" is one of the most common agent bugs, and a missing observation is usually the cause.
Run it: the agent calls get_time three times. Append the observation so the model sees the result and answers on step 2.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based AI Agents Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for AI Agents Foundations books — check the publication year so the examples match current versions.
Search Amazon →