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

# Trace and Fix Bugs

In this tutorial, you'll learn how to use Debug in Potpie to trace a reported issue to its origin in the knowledge graph and get a fix at the source, not a symptom patch.

To understand how Debug works, see the [Debug mode page](/build-flow/debug-an-issue).

<Steps>
  <Step title="Describe the issue">
    Paste an error message, stack trace, or describe the unexpected behavior. Include any context about when it occurs.

    <img src="https://mintcdn.com/potpieai/gJ4EwDE1Ctkm-zsd/images/agent-debug.png?fit=max&auto=format&n=gJ4EwDE1Ctkm-zsd&q=85&s=5c5e1fc5fdad142d2bdfaefd0ab6feb7" alt="Describing the issue" width="1438" height="815" data-path="images/agent-debug.png" />

    <Tip>
      Follow up messages within the same session retain full context. Start with a high-level symptom and narrow to the root cause across subsequent turns.
    </Tip>
  </Step>

  <Step title="Bug analysis">
    The **Debug Agent** applies its **eight step methodology** automatically: validating the behavior, traversing code paths, pinning the **root cause**, and generating a targeted fix.

    <img src="https://mintcdn.com/potpieai/x9vESOd-31L9lpce/images/debug-chat.png?fit=max&auto=format&n=x9vESOd-31L9lpce&q=85&s=277c3448eb51219f00352309d3f7d615" alt="Bug analysis and targeted fix" width="2936" height="1664" data-path="images/debug-chat.png" />
  </Step>
</Steps>
