> ## 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.

# Debug

> **Potpie's bug investigation interface**

<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" />

When a reported issue is received, it traverses the [knowledge graph](/concepts/knowledge-graph) across every affected component to determine the true origin of the problem.

It isolates the root cause to a specific file and line of code, and then returns a precise targeted fix, grounded in the actual implementation.

If you intend to trace an issue to its origin across the knowledge graph and get a fix at the source rather than a symptom patch, follow the [Trace and Fix Bugs tutorial](/tutorials/trace-and-fix).

## How It Investigates

User-reported symptoms and suggested fixes are treated as starting points for investigation, not conclusions. The goal is to find the real issue, which could often be upstream of where the problem surfaces.

It reads files directly by path with optional line ranges, reads multiple files simultaneously when tracing across modules, and searches file contents by pattern to follow state through code paths to their origin.

Once the origin is found, Debug evaluates where the fix should live. A fix at the source prevents the problem for every downstream caller automatically. A fix at the symptom only handles one path. Debug always identifies which type of fix it's applying and why.

For straightforward issues it runs end to end within a single agent, but delegates specialized subagents for problems spanning multiple services .

## Eight-step methodology

Potpie applies an **eight step methodology** to every issue:

<Steps>
  <Step title="Understand and validate">
    Confirms the reported behavior against the codebase, identifies every component involved, and establishes what the correct behavior should be at the point of failure.
  </Step>

  <Step title="Explore and hypothesize">
    Traverses the relevant code paths in the [knowledge graph](/concepts/knowledge-graph) and generates candidate explanations for the failure.
  </Step>

  <Step title="Identify the root cause">
    Pins the failure to a specific file and line, identifying the exact instruction that introduces the faulty state.
  </Step>

  <Step title="Generalize the issue">
    Checks whether the same defect pattern appears elsewhere in the codebase.
  </Step>

  <Step title="Design a solution">
    Generates a targeted fix scoped to the **root cause**.
  </Step>

  <Step title="Scrutinize and refine">
    Evaluates the fix against edge cases and traces potential side effects through the [dependency graph](/concepts/knowledge-graph).
  </Step>

  <Step title="Implement">
    Produces the corrected code with exact file paths and line references.
  </Step>

  <Step title="Final verification">
    Validates the fix against the original failure and checks for regressions.
  </Step>
</Steps>

## What It Returns

The result is a root cause traced to its true origin, a clearly mapped path from origin to symptom, and a fix that resolves the underlying generalized issue rather than only the specific reported instance.

## Using the API

The [Create Conversation and Message](/api-reference/endpoint/create-conversation-and-message) endpoint opens a debug session against a `ready` project and returns the first investigation response in a single call.

## Example uses

<CardGroup cols={2}>
  <Card title="Null Pointer" href="/examples/null-pointer">
    Tracing a null pointer exception to its origin across service and data layers.
  </Card>

  <Card title="Memory Leak" href="/examples/memory-leak">
    Tracing a memory leak in a long-running service to its source across object lifecycle and dependency chains.
  </Card>
</CardGroup>
