> ## Documentation Index
> Fetch the complete documentation index at: https://dev.writer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshoot common issues

This page provides troubleshooting suggestions for debugging and observing your agents as you build them.

* [Track an agent's progress through a blueprint](#view-progress-through-a-blueprint)
* [View error and info logs](#view-error-and-info-logs)
* [Add additional log messages](#add-additional-logs)
* [View traces from a block's execution](#view-traces)
* [Inspect an agent's state](#inspect-agent-state)
* [Observe agent usage and performance](#observe-agent-usage-and-performance)

## View progress through a blueprint

Some blocks such as PDF parsing and text generation can take a while to run. As an agent runs, you can view its progress through the blueprint by navigating to the **Blueprint** tab.

The color of a blueprint block's border describes the status of its execution.

* **Green**: The block completed successfully
* **Animated blue**: The block is currently running
* **Red**: The block failed
* **No border**: The block hasn't run yet

The following image shows a blueprint with a PDF parsing block that's currently running. The previous blocks have completed successfully and the following blocks haven't run yet.

<img src="https://mintcdn.com/writer/nTMyJEeQXE_UTdYX/images/agent-builder/parse-pdf-tutorial/blueprint-progress.png?fit=max&auto=format&n=nTMyJEeQXE_UTdYX&q=85&s=f4213ab4084c828a555723aa85a84a49" alt="Blueprint tab" width="3456" height="1796" data-path="images/agent-builder/parse-pdf-tutorial/blueprint-progress.png" />

You can also see the progress of the agent in the **Log** status bar. Learn more below.

## View error and info logs

If there are any errors or messages as your agent runs, you'll see an indication in the **Log** bar in the bottom right corner of the page.

You can click the **Log** bar to expand it and see more details.

<img src="https://mintcdn.com/writer/pM8WhgC5nDcujQ4i/images/agent-builder/log-bar.png?fit=max&auto=format&n=pM8WhgC5nDcujQ4i&q=85&s=c7d1e33a828f416ed50b75001d1b126b" alt="Log bar" width="470" height="138" data-path="images/agent-builder/log-bar.png" />

### Add additional logs with Log Message blocks

You can add additional custom [**Log message** blocks](/blueprints/logmessage) to the agent for debugging purposes. Log messages are helpful to understand the flow of the agent and the value of state and other variables at a given point in the execution.

To add a log message, add a **Log message** block to the canvas. In the block's configuration panel, update the following fields:

* **Type**: `info` or `error`
* **Message**: The message to log

Below is an example of a log message block during a file parsing process. It logs the file ID before beginning the parsing process, to help you debug if the file isn't found or isn't parsed correctly.

<img src="https://mintcdn.com/writer/nTMyJEeQXE_UTdYX/images/agent-builder/parse-pdf-tutorial/log-message-block.png?fit=max&auto=format&n=nTMyJEeQXE_UTdYX&q=85&s=50257a987c9ee9f644934ad7d23154b9" alt="Log message block" width="3456" height="1812" data-path="images/agent-builder/parse-pdf-tutorial/log-message-block.png" />

When the block runs, you'll see the log message in the **Logs** bar at the bottom of the page.

<img src="https://mintcdn.com/writer/nTMyJEeQXE_UTdYX/images/agent-builder/parse-pdf-tutorial/log-example.png?fit=max&auto=format&n=nTMyJEeQXE_UTdYX&q=85&s=d30358a416bcd1cd16f52048927c2b31" alt="Log message in logs" width="1206" height="214" data-path="images/agent-builder/parse-pdf-tutorial/log-example.png" />

### Add additional logs with Python code

You can use python `print` statements and the globally available [`logger` object](https://docs.python.org/3/library/logging.html) to add additional logs to the agent.

```python theme={null}
print("This is a log message that shows in logs as 'Captured stdout'")
logger.info("This is an info message that shows in logs under 'Captured logs'")
logger.warning("This is a warning message that shows in logs under 'Captured logs'")
logger.error("This is an error message that shows in logs under 'Captured logs'")
```

The following image shows an example of a Python block that logs messages via print statements and the `logger` object.

<img src="https://mintcdn.com/writer/nTMyJEeQXE_UTdYX/images/agent-builder/python-block-with-logs.png?fit=max&auto=format&n=nTMyJEeQXE_UTdYX&q=85&s=dc7322c27b3cafabe6f2d546e7e1322d" alt="Python block with logs" width="2126" height="750" data-path="images/agent-builder/python-block-with-logs.png" />

When the block runs, the log messages appear in the **Logs** bar at the bottom of the page.

<img src="https://mintcdn.com/writer/nTMyJEeQXE_UTdYX/images/agent-builder/python-messages-in-logs.png?fit=max&auto=format&n=nTMyJEeQXE_UTdYX&q=85&s=14589da590433e2a7fa892af2ebed900" alt="Log messages in logs" width="3450" height="840" data-path="images/agent-builder/python-messages-in-logs.png" />

## View traces

The log bar shows information about the agent's execution as it runs and after blocks complete. It includes the following:

* The block name
* The status of the block: success, error, or in progress
* A link to view a trace at that point in the execution
* How long the block took to run

<img src="https://mintcdn.com/writer/pM8WhgC5nDcujQ4i/images/agent-builder/log-bar-in-progress.png?fit=max&auto=format&n=pM8WhgC5nDcujQ4i&q=85&s=c92edcc12ef2a0dac28721b2a37fb51f" alt="Log bar with traces" width="3456" height="784" data-path="images/agent-builder/log-bar-in-progress.png" />

The trace link opens a new tab with a detailed view of the agent's execution at that point in time. It contains:

* The value resulting from the block's execution, which is then added to the execution environment of the following block
* The return value, if the block has one
* The full execution environment at that point in time
* The call stack

Below is an example of a trace after a **File upload** block has completed.

<img src="https://mintcdn.com/writer/Ph7gAl4exSh0IC1l/images/agent-builder/trace.png?fit=max&auto=format&n=Ph7gAl4exSh0IC1l&q=85&s=ba18ca959d92dac335e3922125de09ed" alt="Trace of a file upload block" width="2684" height="1420" data-path="images/agent-builder/trace.png" />

## Inspect agent state

You can use the **State explorer** to view an agent's state variables and their values. This is helpful when you're debugging an agent or need to check the state at a given point in the execution.

To access the state explorer, click the **State explorer** icon in the top right corner of the page.

<img src="https://mintcdn.com/writer/Ph7gAl4exSh0IC1l/images/agent-builder/state-explorer-icon.png?fit=max&auto=format&n=Ph7gAl4exSh0IC1l&q=85&s=dc9b3e4865094cbb8ab1c1b016b1393d" alt="State explorer" width="830" height="183" data-path="images/agent-builder/state-explorer-icon.png" />

## Observe agent usage and performance

You can view usage and performance metrics for your agent in the **Observability** tab. To get to this view, select the agent from the [AI Studio homepage](https://app.writer.com/ai-studio) and navigate to the **Observability** tab.

Here, you can view:

* Performance: Requests, errors, latency, and throughput
* Usage: Total requests, tokens, and cost, along with a geographic breakdown of requests
* Logs: Logs from individual requests

<feedback />
