Skip to content

mrzasad/self-correcting-sql-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Self-Correcting SQL Agent

An intelligent agent that writes SQL from natural language, executes it, and self-corrects using reflection + schema-aware prompting.

This demo showcases agentic AI principles:

  • 🔄 Reflection Loop - Automatically retries with error context
  • 🧠 Error-Aware Reasoning - Learns from database error messages
  • 💡 Intelligent Correction - Not random retries, but thoughtful fixes
  • 📊 Interactive UI - Streamlit dashboard showing the correction process

Perfect for demonstrating:

  • LangGraph state machines
  • LLM function-calling patterns
  • Agentic workflows with error recovery
  • Production-ready AI systems

✅ Agentic AI Capabilities

  • State machines (LangGraph for workflow control)
  • Reflection architecture (error analysis + correction loop)
  • Tool use (database execution as a tool)
  • Multi-step reasoning (generate → execute → reflect → correct)

✅ Production Thinking

  • Thread-safe database handling (SQLite in Streamlit)
  • Environment variable management (.env + secrets)
  • Structured error handling (not just try/except)
  • Observability (execution traces + metrics)

✅ LLM Engineering Skills

  • Schema-aware prompting (dynamic context injection)
  • Few-shot correction (error patterns in prompts)
  • Rate limit awareness (max attempts configuration)
  • Model agnostic (works with GPT-4, 3.5, or local models)

✅ Portfolio Value

  • Complete working demo (not just a notebook)
  • Interactive UI (proves concept visually)
  • Self-contained (runs with streamlit run)
  • Well-documented (recruiters can understand in 5 minutes)

This is the kind of project that gets you hired for Gen AI roles.

About

A self-correcting SQL agent using LangGraph + Streamlit that learns from errors, reflects on mistakes, and automatically fixes SQL queries through multi-attempt reasoning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages