Diagnoses AQVEN validation errors, failed mock tests, aborted or slow runs, schema rejections, and Golden regressions using CLI and MCP trace tools (aqven_probe_validate, aqven_run_conclude, aqven_run_trace, aqven_step_get, aqven_step_query, aqven_step_content). Use first whenever any check, validation, or run fails, stalls, or diverges.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Aqven Debug?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/lastonoga-aqven-debug)
---
name: aqven-debug
description: Diagnoses AQVEN validation errors, failed mock tests, aborted or slow runs, schema rejections, and Golden regressions using CLI and MCP trace tools (aqven_probe_validate, aqven_run_conclude, aqven_run_trace, aqven_step_get, aqven_step_query, aqven_step_content). Use first whenever any check, validation, or run fails, stalls, or diverges.
---
# Validation Diagnostics & Trace Investigation (`aqven-debug`)
## MUST
1. **Never edit a prompt or workflow before reading the failing trace:** Eyeballing final JSON or guessing from `status=done` / `status=failed` leads to blind edits. Read the exact rendered `prompt` + `raw` model output + `errorDetails` first.
2. **Use bounded MCP / CLI trace tools — never read `.aqven/` SQLite files directly** and never spawn subagents to run 100 individual `run_get` calls.
3. **Separate dataset/test bugs from probe bugs:** When a check fails on every model or contradicts clear raw text, audit the dataset item, `prepareInput`, and Golden label before blaming the LLM.
4. **Never kill shared Studio/API processes with `pkill`:** Use the project's managed dev scripts or MCP read tools.
---
## Fast 3-Step Investigation Protocol (MCP & CLI)
Diagnose any run in **at most 3 calls**:
### 1. One-call run conclusion & tree overview — find what failed first
- **MCP (start here):** `aqven_run_conclude({ runId })` — returns checks (failed-first), metrics, delta vs previous run, persisted Golden summary + bounded `missing`/`runOnly`/`partitionMoved`, attempt/runaway stats, per-step rollup, and notes in **1 call**.
- **MCP (execution tree):** `aqven_run_trace({ runId, includeAttempts: true })`
- **CLI:** `npm run aqven -- conclude <runId>` / `npm run aqven -- run <runId> --trace`
- *What to look for:* First red/repaired step in the hierarchy (`parentStepId`, loop `iteration`), `modelObserved` vs requested model, `providerObserved`, `error.code`, `retryTrace`, `llm_fallback`, and token/latency outliers.
### 2. Inspect the failing step or query payloads across steps/runs
- **MCP (single step):** `aqven_step_get({ runId, step: "<stepId>#<iter>", includeAttempts: true })`
- **MCP (cross-step / cross-matrix JSON search):** `aqven_step_query({ runId | matrixId, stepId?, part: "output" | "input", jsonPath?, match?, fields?, limit?, offset? })` — traces where a specific entity or field value appeared, changed, or dropped across workflow stages or matrix repeats without writing ad-hoc scripts.
- **CLI:** `npm run aqven -- step <runId>:<stepId>[#<N>] --input --output --attempts`
- *Note:* Append `#1`, `#2`, … for cyclic `andCriticLoop` iterations so you inspect the full progression across writer/critic turns rather than only the last turn.
### 3. Read exact `prompt`, `raw`, or `errorDetails` slices on the failing attempt
- **MCP:** `aqven_attempt_content({ attemptId, field: "prompt" | "raw" | "parsed" | "errorDetails", encoding: "utf8", jsonPath?, offset: 0, limit: 16384 })` (same `encoding: "utf8"` + optional `jsonPath` works on `aqven_step_content`, `aqven_artifact_get`, and `aqven_matrix_content`).
- **Golden diff, run A/B comparison & stability matrix (all via MCP):**
- `aqven_run_get({ runId, selectors: ["golden"], goldenSlice: "summary" | "missing" | "runOnly" | "matched" | "fields" | "partition" | "confusion", limit?, offset? })` — multi-dimensional slices of the persisted Run-vs-Golden report (or CLI `aqven run <runId> --golden --json`; add `--recompute` if `state === "stale"`).
- `aqven_run_compare({ runA, runB })` — side-by-side comparability checks, `metricsAB`, `checkFlips`, `stepDiffs`, and `goldenDiff` (`newlyMatched`, `newlyMissing`, `partitionDelta`).
- `aqven_matrix_get({ matrixId, selectors: ["summary", "metrics", "flaky", "intraRunSplits"], match?, minPresent?, maxPresent?, limit?, offset? })` — compact multi-dimensional stability slices that stay safely under the 128 KiB cap (probe metric stats, check pass rates across repeats, filtered flaky items, intra-run splits; run `aqven stability recompute <matrixId>` if `reportState === "stale"`). For raw streaming, use `aqven_matrix_content({ matrixId, part, encoding?: "utf8" | "base64", jsonPath?, byteOffset, maxBytes })`.
- `aqven_history({ probeId })` & `aqven_note_add({ runId, text })` — inspect the probe iteration chain and record falsifiable hypotheses without spawning CLI shells.
---
## Symptom -> Root Cause -> Exact Fix Matrix
| Observed Symptom | Root Cause Class | Exact Action |
|---|---|---|
| Item text is missing or empty inside `attempt.prompt` | **Wiring bug** | Fix `prepareInput`, `definePrompt` `vars`, or `andAgent({ input })` selector. Do **not** touch prompt instructions. |
| `attempt.raw` is cut off mid-JSON (`finish_reason: length`) | **Token / Reasoning truncation** | Check `usage`: if hidden reasoning ate `max_tokens`, lower reasoning effort or raise `maxOutputTokens` (`aqven-models`), configure bounded clean retry `retry: { truncated: 1 }`, and guard regressions with `check.attempts({ maxRunaway: 0 })`. |
| `OUTPUT_SCHEMA_REJECTED` ("too many states" / grammar error) | **Schema state-space** | Shrink enum list to consumer's real needs, flatten deeply nested objects, batch items via `andForEach`, or pin an upstream with full `structured_outputs` support (`aqven-models`). |
| `allowed-set` or `exact-cover` repair loop exhausted | **ID / Coverage failure** | Inspect `raw`: if model invented IDs, ensure source IDs are clearly rendered in `prompt`; if tail items were dropped on a huge list, split into smaller batches (`andForEach`). |
| Cyclic `mergeIntoId`, self-merge, or merge into `"drop"` node | **Broken merge graph** | Wire `validate: ({ output }) => validateMergeGraph(output.decisions, spec)` on `defineInference` so structural graph errors trigger bounded LLM auto-repair before `resolveMergeGraph`. |
| `check.attempts` fails (`failedAttempts > 0` or `runawayAttempts > 0`) | **Hidden retry / truncation debt** | Inspect `aqven_run_trace` for repaired/retried attempts or `finish_reason: "length"` runaways — fix schema/token budget so runs pass cleanly on attempt 1. |
| `modelObserved` or `providerObserved` differs from agent config | **Unpinned routing** | Pin the upstream provider/snapshot explicitly in your project's agent config (`aqven-models`). |
| Run aborted mid-pipeline on `429`, `502`, or provider timeout | **Transient infra abort** | Tune rate-limit lane in `aqven.config.ts` if needed, then **resume from the failed step** (`--resume`) instead of restarting from step 1. |
| `andCriticLoop` hits `stalled` or `exhausted` repeating same critique | **Critic overloop** | Inspect `#1`, `#2`, `#3` steps: either critic asks for something the schema/input forbids (fix spec) or `shouldStop` needs repeat-critique detection. |
| Output is valid and reasonable on real text, but `golden_match` failed | **Matcher or Stale Golden** | Check whether wording is an acceptable synonym (relax `stability.fields` matcher) or Golden label is wrong (`golden fork` with owner sign-off). |
| Valid schema & clean prompt, but 3–4 items flip answers across 10 runs | **Boundary ambiguity or `int4` drift** | Add 1 crisp boundary rule with 1–2 examples to `promptedEnum` / `prompt.ts`, or test `fp8`/`bf16` vs `int4` (`aqven-models`). |
---
## Pre-Flight `$0` Validation Codes (`aqven_probe_validate` / `probe validate`)
Always run `aqven_probe_validate({ probeId })` after every code edit before spending tokens:
| Diagnostic Code | Fix |
|---|---|
| `prompt-missing-var` / `prompt-unused-var` / `prompt-malformed-braces` | Align `{{var}}` placeholders (exact double braces, no spaces) with `definePrompt({ vars })`. |
| `allowed-set-mismatch` / `universe-ref-missing` | Align `allowedField("x")`, `allowedSets.x`, and `withCompleteness({ universe: "x" })`. |
| `bare-enum-in-output` / `output-object-not-strict` / `prompted-enum-duplicated` | Use `promptedEnum`, add `.strict()` to every output `z.object(...)`, and delete hand-copied enum lists from `prompt.ts`. |
| `schema-json-unrepresentable` / `non-durable-workflow-schema` | Replace `z.date()`, `z.map()`, `z.set()`, `z.bigint()`, `z.transform()` with pure JSON Zod types. |
| `missing-embedder-resource` | Configure `resources.embedder` (`AiSdkEmbeddingAdapter`) in `aqven.config.ts`. |
| `critic-loop-unbounded` / `critic-same-as-writer` / `divergent-writers-check` | Add `shouldStop` / iteration bound to `andCriticLoop`, give critic distinct instructions, and use >=2 distinct writers in `andDivergent`. |
| `matcher-threshold-range` / `stability-fields` | Keep thresholds in `[0, 1]` (e.g. `0.85`, never `85`) and align `stability.fields` keys with `stability.items` return shape. |