Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Observations
An observation is what the agent receives after a tool executes. Observations are the agent's window into the real world. They inform every subsequent decision.
What Is an Observation?
After the agent calls a tool, the tool returns a result. That result is called an observation.
Observations can be:
- Text: a search result, a document excerpt, a log message
- Structured data: a JSON object, a table of values, a list of records
- A status: 'success', 'error', 'pending', '404 not found'
- A confirmation: 'Email sent successfully', 'Record updated'
The agent reads the observation and adds it to its state. The next time the controller makes a decision, it considers this observation along with all previous observations.
Observation Handling
- Success observation: the tool ran correctly and returned useful data - the agent can continue with the next step
- Empty observation: the tool ran but returned no data - the agent may need to try a different approach
- Error observation: the tool failed - the agent should handle the error, retry, or escalate
- Partial observation: the tool returned some data but it is incomplete - the agent may need another call
- The agent should never ignore an observation. Every result, including errors, should inform the next decision.
Key Takeaways
- An observation is what the agent receives after a tool executes.
- Success observation: the tool ran correctly and returned useful data - the agent can continue with the next step
- Empty observation: the tool ran but returned no data - the agent may need to try a different approach
- Error observation: the tool failed - the agent should handle the error, retry, or escalate