Send Autofix to your coding agent
Vuon Autofix finds why agents keep writing failing warehouse queries, plans the fix, and writes the change. When the fix belongs in your dbt project or semantic layer, you can hand it to your own coding agent: Vuon sends one signed webhook to your endpoint, and your bot takes it from there, in whatever environment and tracker your team uses.
How it works
- You add a webhook endpoint subscribed to
query_check.autofix.handoff_requested. - On a Query checks issue, the Autofix menus (Make a plan ▾, Write the changes ▾, Open a pull request ▾) offer Send to followed by your endpoint's description.
- An admin picks it on a completed stage and confirms. Vuon sends the event to that one endpoint, signed and retried like every webhook.
- The stage shows Sent to your endpoint, with the delivery's result: delivered, retrying, or not delivered.
- Your bot verifies the signature, then starts an agent session from the brief, or posts it where your team works.
Vuon does not hear back from your bot yet, so the pull request your agent opens does not show on the issue page.
What the payload contains
The handoff carries data from your warehouse. Vuon sends it only to the endpoint an admin picks, which is your own system. Subscribe only endpoints you trust with this data, and treat the payload as you would query results.
| Field | What it holds |
|---|---|
data.brief | Markdown ready to use as an agent's prompt: the issue, the root cause, the plan, the Vuon and upstream changes, and what to do. The same brief Vuon puts on a Linear issue. |
data.stages.rootCause | The cause's kind, explanation, the evidence the stage checked, and whether it reproduced the failure. |
data.stages.plan | Where the fix belongs (Vuon, upstream or both), why, and the steps. |
data.stages.changes | The Vuon documentation changes, each with what it says now and what it should say, and the upstream change. |
data.upstreamChange | The repository, file path and revision, the patch (a unified diff, or a snippet when Vuon could not read the file), and a pull request title and description. |
data.evidence.occurrences | Up to 5 recent failing queries, with their full SQL text (cut at 6,000 characters), the checker's message and the tables read. Only queries from chats the admin who sent it may open. |
data.evidence.stageQueries | Up to 20 warehouse queries the Autofix stages ran, with their SQL text and up to 10 sample rows each (long strings cut at 500 characters). |
data.issue, data.autofix.url | The issue and links back to it in Vuon. |
data.requestedByEmail | The admin who sent it. |
data.stages holds the stage that was sent and the stages before it; a later stage is null. A plan sent before the changes are written has no upstreamChange. See the event catalog for the full schema and a sample.
1. Subscribe an endpoint
- Go to Settings → Webhooks and choose Add endpoint. (Webhooks must be enabled for your workspace; ask your Vuon contact.)
- Enter your bot's https URL.
- Give it a description. It becomes the menu entry: "Lark coding bot" shows as Send to Lark coding bot. Without one, the menu uses the URL's host.
- Under Events, check
query_check.autofix.handoff_requested. Leaving every box unchecked subscribes to all events, the handoff included. - Copy the signing secret into your bot's environment as
VUON_WEBHOOK_SECRET.
Use Send test event to check your bot. An endpoint subscribed only to the handoff gets a sample handoff, so your bot sees the real shape.
2. Verify the signature
Verify every request before acting on it: the payload can start an agent with write access to your repository. Use verifyWebhook from Verifying signatures; it checks the HMAC over the raw body and rejects requests older than five minutes.
3. Start an agent session from the brief
This bridge acknowledges the webhook at once, then runs the agent in the background, in a checkout of the repository the fix names. It uses Claude Code's non-interactive mode; the Codex line is below it.
autofix-bridge.ts
import { spawn } from 'node:child_process';
import { existsSync } from 'node:fs';
import express from 'express';
const app = express();
// Where your repositories are checked out, by `owner/name`.
const CHECKOUTS = process.env.CHECKOUTS_DIR ?? '/srv/checkouts';
// Event ids already handled: delivery is at-least-once.
const seen = new Set<string>();
app.post('/vuon', express.raw({ type: 'application/json' }), (req, res) => {
const rawBody = req.body.toString('utf8');
const ok = verifyWebhook({
secret: process.env.VUON_WEBHOOK_SECRET!,
rawBody,
timestampHeader: req.header('vuon-webhook-timestamp') ?? '',
signatureHeader: req.header('vuon-webhook-signature') ?? '',
});
if (!ok) {
return res.status(401).send('invalid signature');
}
const event = JSON.parse(rawBody);
// Answer within 10 seconds; the agent runs after.
res.status(200).send('ok');
if (event.type !== 'query_check.autofix.handoff_requested' || seen.has(event.id)) {
return;
}
seen.add(event.id);
startAgent(event.data);
});
function startAgent(data: {
brief: string;
issue: { key: string; url: string };
upstreamChange: { repository: string | null } | null;
}) {
const repository = data.upstreamChange?.repository;
const cwd = repository ? `${CHECKOUTS}/${repository}` : undefined;
if (!cwd || !existsSync(cwd)) {
console.warn(`${data.issue.key}: no checkout for ${repository ?? 'an unnamed repository'}`);
return;
}
const prompt = `${data.brief}\nWork on a new branch and open a pull request with gh. Mention ${data.issue.key} (${data.issue.url}) in its description.`;
const agent = spawn(
'claude',
['-p', prompt, '--permission-mode', 'acceptEdits', '--allowedTools', 'Bash(git *) Bash(gh pr create *)'],
{ cwd, stdio: 'inherit' },
);
agent.on('exit', (code) => console.log(`${data.issue.key}: agent exited ${code}`));
}
app.listen(3000);
To run Codex instead, replace the spawn call:
Codex
const agent = spawn('codex', ['exec', '--sandbox', 'workspace-write', prompt], {
cwd,
stdio: 'inherit',
});
The brief already ends with what to do. Your own prompt around it is where to add your conventions: the base branch, how to name the branch, which checks to run before opening the pull request.
Hosted agent environments. If your agents run in a hosted environment rather than on the bridge's machine, start the session through that environment's API or CLI with the same prompt, and pass data.upstreamChange.repository as the repository to work in.
Lark bot variant
Teams that track work in Lark can have the bridge post the handoff to a group, so a person (or a bot listening in that group) picks it up there. This variant posts a card to a Lark custom bot with the issue, the plan and the pull request title, and attaches the full brief as text.
lark-handoff.ts
const LARK_BOT_URL = process.env.LARK_BOT_URL!;
async function postToLark(data: {
brief: string;
issue: { key: string; title: string; url: string };
stage: { name: string };
stages: { plan: { result: { summary: string } } | null };
upstreamChange: { repository: string | null; path: string | null; pullRequest: { title: string } } | null;
requestedByEmail: string | null;
}) {
const where = data.upstreamChange
? `${data.upstreamChange.repository ?? '?'} · ${data.upstreamChange.path ?? '?'}`
: 'No upstream change yet';
const card = {
msg_type: 'interactive',
card: {
header: { title: { tag: 'plain_text', content: `Autofix ${data.issue.key}: ${data.issue.title}` } },
elements: [
{
tag: 'div',
text: {
tag: 'lark_md',
content: [
`**Sent by** ${data.requestedByEmail ?? 'Vuon'} (${data.stage.name} stage)`,
`**Plan** ${data.stages.plan?.result.summary ?? 'Not planned yet'}`,
`**Where** ${where}`,
data.upstreamChange ? `**PR** ${data.upstreamChange.pullRequest.title}` : '',
]
.filter(Boolean)
.join('\n'),
},
},
{ tag: 'action', actions: [{ tag: 'button', text: { tag: 'plain_text', content: 'Open in Vuon' }, url: data.issue.url, type: 'default' }] },
],
},
};
await fetch(LARK_BOT_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(card) });
// The brief as its own message, ready to paste into an agent.
await fetch(LARK_BOT_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ msg_type: 'text', content: { text: data.brief } }),
});
}
Call postToLark(event.data) in place of startAgent(event.data), or call both. A Lark custom bot can only post to its group; to have Lark start the agent as well, run the bridge above alongside it, or give your Lark app an event subscription that calls your agent runner.
Tips
- Acknowledge first. Vuon waits 10 seconds for a 2xx, then retries for about 36 hours. Starting the agent before you answer makes a slow start look like a failure, and the retry starts a second agent.
- Deduplicate on the event id (
event.id, also thevuon-webhook-idheader). A retry or a replay from the delivery log sends the same id; sending the stage again from the menu sends a new one. - Keep the data where your other warehouse data goes. Log the event id and issue key, not the payload, unless your logs are cleared for query results.
- Check the patch. A
diffwas written against the file atupstreamChange.revision; the file may have moved on since. The brief asks the agent to check each change against the current file. - Changes in Vuon itself (dataset descriptions, semantic-layer definitions in Vuon) are applied by an admin from the issue page. The brief tells the agent to leave them out of the pull request.