Skip to content

vpeetla-ai/reflection-agent-pattern

Repository files navigation

Reflection Agent Pattern

Python 3.11 LangGraph pytest Vercel

Part 2 of 5 — critique-and-revise before delivery. Used in VAP Research + Architecture.

▶ Live demo · Architecture · Portfolio · VAP case study

What this is

Self-critique loops improve draft quality before ship — bounded reflection with trace viewer for teaching.

How we solve it

Critic agent revises generator output with stop conditions and structured traces — composable into VAP pipelines.

Case study & tradeoffs

venkat-ai.com/work · docs/ARCHITECTURE.md


Org skills: vpeetla-ai-skills. This repo includes .cursor/skills/, AGENTS.md, and CONTEXT.md.

git clone https://github.com/vpeetla-ai/vpeetla-ai-skills.git
./vpeetla-ai-skills/scripts/install.sh --cursor --codex --project .

Implementation status

Component Status Notes
Pattern demo + trace UI Live Vercel demo
Core agent loop Reference implementation
LangGraph production graph 🟡 Teaching scope — compose into VAP for fleet use
MCP tool bridge See LoopForge / VAP MCP docs
AegisAI gateway No side effects in pattern demo
Pytest regression pytest -q in repo

Live Demo Part of Production Agent Patterns License: MIT

Part 2 of 5 in the Production Agent Patterns series.

Production-grade reference implementation of the Reflection pattern for accuracy-critical generation, code review, content validation, and complex reasoning workflows.

# Pattern Repository Use when
1 ReAct react-agent-pattern Tool use + reasoning loops
2 Reflection this repo Self-critique and improve output
3 Plan-Execute plan-execute-agent-pattern Decompose goals into steps
4 Multi-Agent multi-agent-system-pattern Specialized role delegation
5 Swarm swarm-agent-pattern Parallel autonomous agents

▶ Live demo · 📖 Full series roadmap · 🚀 See in production — AI Content Factory


What you'll learn

  • Draft → critique → improve → finalize loop
  • Quality gates with score thresholds and retry limits
  • Independent generator and critic interfaces
  • Structured review findings for logging, UI, and evaluation

What this repo demonstrates

  • Draft, critique, improve, and finalize loop
  • Quality gates with score thresholds and retry limits
  • Independent generator and critic interfaces
  • Structured review findings that can be logged, displayed, or used for evaluation

Quick start

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
python -m reflection_agent_pattern
pytest

Runs without API keys using deterministic generator and critic stubs.

cp .env.example .env

See docs/LOCAL_DEVELOPMENT.md for production setup.

Repo layout

src/reflection_agent_pattern/
  __main__.py
  reflection.py
  models.py
  policy.py
docs/ARCHITECTURE.md
tests/test_reflection.py

Related

⭐ Star the repo if this pattern helps your work.

About

Reflection agent pattern — self-critique loop for higher-quality LLM output

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages