## TL;DR

Nested macro tracebacks read inside-out: the innermost frame is where it actually broke, the outer frames are just the call chain. The agent should rerun with `--debug` for full frames, find the innermost macro frame, reproduce it with `dbt run-operation`, and fix that macro.

## Error

```text
agent couldn't parse the jinja error traceback: nested macro frames
```

## Steps

1. Rerun the failing command with `--debug` to get the complete traceback with all frames. Expected: the full call chain, not a truncated summary.
2. Read from the bottom up: the last (innermost) macro frame is the failure point. Expected: one file and line to focus on.
3. Open that macro at that line. Expected: the offending expression is visible.
4. Reproduce minimally: `dbt run-operation [MACRO] --args '{...}'` with args matching the real call. Expected: the same failure in isolation.
5. Fix the macro, verify with the repro, then recompile. Expected: the whole chain renders.

## When to use

- A dbt error traceback shows multiple nested macro frames.
- The agent cannot tell which macro actually failed.

## When not to use

- The traceback has a single frame (the failure point is obvious).
- The error is in model SQL rather than a macro.

## Tool compatibility

- dbt Core 1.0 and later, all adapters.

## Variant phrasings

### Traceback shows the same macro 20 times

That is recursion, not nesting; look for the repeating frame and add a base case.

### Error at the top frame misleads the fix

Top frames are callers; fixing them treats the symptom.

## Why it happens

Macros call macros, and dbt reports the whole stack. Agents read top-down (the natural way) and fix callers, but the defect lives at the bottom of the stack where the actual bad expression ran.

## Edge cases

- Adapter macros (dispatch) add frames from package code; the innermost project frame is usually the actionable one.
- Truncated tracebacks (without `--debug`) hide the innermost frames; always rerun with `--debug`.
- If the innermost frame is in Jinja internals, the real cause is the argument passed one frame up.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_bOQPBBI7qlOvBEKDBwwC2A
