Adding Logs to the Agent › Seeing Logs in Action

Michael BrenndoerferAugust 6, 20252 min read
AI Agent HandbookAll chapters
Part 12 of 15Observability and Debugging - Peering Inside the Agent
Chapter 33Adding Logs to the Agent › Seeing Logs in Action
Reading section 7 of 10 · Seeing Logs in Action · 2 minSection 7 of 10 · 2 min

Book contents

Section 7 of 10 · 2 min read

Adding Logs to the Agent › Seeing Logs in ActionOne section · Sections in this chapter7 / 10 ↓

Let's look at what logs from our assistant might look like during a typical interaction. This gives you a sense of how logs help you understand what's happening.

The user asks: "What's 234 times 567?"

2025-11-10 14:32:15 - assistant - INFO - User query: What's 234 times 567?
2025-11-10 14:32:15 - assistant - INFO - Tool required: True
2025-11-10 14:32:15 - assistant - INFO - Selected tool: calculator
2025-11-10 14:32:15 - assistant - INFO - Calling calculator with: 234 * 567
2025-11-10 14:32:15 - assistant - INFO - Calculator returned: 132678
2025-11-10 14:32:16 - assistant - INFO - Assistant response: The answer is 132,678.

These logs tell a clear story. The agent received a math question, recognized it needed the calculator tool, called the calculator with the correct expression, got the result, and sent the answer to the user. Everything worked as expected.

Now imagine the user asks: "What's the weather like?"

2025-11-10 14:35:22 - assistant - INFO - User query: What's the weather like?
2025-11-10 14:35:22 - assistant - INFO - Tool required: True
2025-11-10 14:35:22 - assistant - INFO - Selected tool: weather_api
2025-11-10 14:35:22 - assistant - WARNING - No location specified, using default
2025-11-10 14:35:23 - assistant - INFO - Weather API returned: Sunny, 72°F
2025-11-10 14:35:23 - assistant - INFO - Assistant response: It's sunny and 72°F.

Here the logs reveal something interesting. The agent correctly identified the need for the weather tool, but it had to use a default location because the user didn't specify one. The WARNING level log highlights this, and it explains why the response might not match what the user expected if they're in a different location.

These examples show how logs turn your agent's internal process into something visible and understandable.