BeginnerCoder

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:

  1. the model's tool call, as an "assistant" message;
  2. 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.

Want it another way?
Task

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.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with AI Agents Foundations

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.