sql-consensus

Generates SQL queries through a five-sub-agent consensus protocol with iterative disagreement resolution.

21|1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/ryanjanssen/metalayer --skill sql-consensus-ryanjanssen
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sql-consensus
Source: https://github.com/ryanjanssen/metalayer/tree/main/skills/sql-consensus
Command: npx skills add https://github.com/ryanjanssen/metalayer --skill sql-consensus-ryanjanssen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Single-pass text-to-SQL generation often produces inconsistent or incorrect queries when questions are ambiguous or the data model context is incomplete. This Skill runs every data question through a multi-agent consensus protocol so the final SQL is cross-validated before execution. ## Core Features & Use Cases - Five-Agent Quorum: Spawns 5 sub-agents with identical context blocks and compares their SQL outputs for semantic equivalence across tables, joins, aggregations, filters, and grouping. - Disagreement Diagnosis: Instead of voting, it identifies why agents disagree — ambiguous questions, missing context, conflicting vault definitions, or grain confusion — and resolves the root cause. - Iterative Refinement: Runs up to 3 full quorum rounds with refined context or user clarification, and reports unresolved disagreements instead of guessing. - Use Case: A user asks "What was revenue last quarter?" and agents split between gross and net revenue interpretations. The Skill detects the ambiguity, asks the user to clarify, and regenerates a consensus query. ## Quick Start Ask a data question and have the agent run the SQL consensus protocol to generate a validated query from the vault context.

Frequently Asked Questions about sql-consensus

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does multi-agent SQL consensus generation work?▼

Five sub-agents each receive an identical context block and the user's question, then independently produce SQL. Their outputs are compared for semantic equivalence — same tables, joins, aggregations, filters, and grouping — ignoring formatting differences.

How do I resolve ambiguous text-to-SQL questions?▼

The protocol diagnoses why agents disagree rather than voting. If the question is ambiguous, such as gross versus net revenue, it asks the user to clarify, incorporates the answer into the context block, and reruns the full quorum.

What happens when SQL agents disagree on joins or grain?▼

Disagreements are classified as ambiguous questions, missing context, conflicting context, or grain confusion. The context block is refined with additional vault files, explicit grain instructions from one_row_means and dedup_key fields, then a fresh quorum runs.

How many retry rounds does the consensus protocol allow?▼

A maximum of 3 full quorum rounds is allowed. If agents still produce meaningfully different SQL after three rounds, the protocol stops, reports the specific disagreement to the user, and logs it for data model improvement.

What are the limitations of consensus-based SQL generation?▼

Consensus cannot resolve questions where the data model fundamentally lacks the needed context, and it costs five times the generation calls per round. It also refuses to guess, returning an unresolved status rather than a best-effort query.