Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions guides/ai-agents/ai-writeback.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ Make the orders model better.

When the pull request is ready, the agent posts the URL in the thread. Open it, review the diff, and merge as you would any other pull request. After merging, refresh dbt in Lightdash (or let your CI/CD do it) so the change takes effect.

## Iterating on an existing pull request

If you've already opened a writeback pull request — either earlier in the same thread or by pasting a link to one — the agent commits follow-up changes onto that PR's branch instead of opening a new one. The PR's title and description are refreshed to reflect the latest change.

There are two ways this happens:

- **Same thread.** If the thread already has a writeback PR, any further writeback requests in that thread automatically resume it. You don't need to paste the link.
- **Paste a link.** In a new thread (or before a writeback PR exists for the current thread), paste the GitHub pull request URL alongside your request. The agent picks up the link, checks out that PR's branch, and commits your edits onto it.

```text
Update https://github.com/my-org/analytics/pull/482 so the `net_revenue`
metric is rounded to 2 decimal places.
```

The pasted pull request must:

- Live in the same GitHub repository as the project's dbt connection.
- Be **open** — merged or closed PRs are rejected.
- Have its branch in the same repository (PRs opened from forks are rejected).

If any of those checks fail, the agent stops and tells you why instead of silently opening a new pull request.

## What happens if it can't run

| Situation | Result |
Expand All @@ -90,6 +112,7 @@ When the pull request is ready, the agent posts the URL in the thread. Open it,
| Project's dbt connection isn't GitHub | The agent tells you the project must be connected to GitHub for writeback. |
| GitHub App isn't installed on the repo | The agent surfaces a setup error. Install the Lightdash GitHub App on the repository (from your project's dbt connection settings) and try again. |
| Writeback agent makes no file changes | No pull request is opened. The agent reports back that nothing needed to change. |
| Pasted PR link is in a different repo, merged, closed, or from a fork | The agent rejects the link with an explanation and does not open a new pull request. |

## Related

Expand Down
Loading