Error Diagnosis Agent
Takes a failed query and its engine error, returns root cause, a category, and corrected SQL where derivable.
Inputs
- SQL, the failing statement
- Error message, the engine's raw output
- Connection (optional), grounds on the live schema to catch bad column references and type mismatches
Categories
Classified as one of: syntax, permission, reference (missing table/column), type (mismatch), constraint (FK / NOT NULL / unique), connectivity, unknown.
Output
{
rootCause: 'concise explanation',
category: 'syntax' | 'permission' | 'reference' | 'type' | 'constraint' | 'connectivity' | 'unknown',
correctedSql: 'fixed SQL or undefined',
steps: ['actionable fix step'...]
}