Repository navigation
First public release of LangValidator — a LangGraph pipeline where every agent output passes through a checkpoint node that scores it and decides whether to pass, retry with feedback, or halt.
What's included
Graph
AgentStateTypedDict with query, conversation history, score, retry counter, halt stateretrieval_agentandreasoning_agentnodes (Claude Haiku)checkpoint_nodethat scores each output and writes validation feedbackhalt_nodeandfinalize_nodeas terminal statesStateGraphwith conditional edges and retry loops (pass ≥ 0.75, retry 0.45–0.75, halt < 0.45)
Validators
- Rule-based — deterministic scoring across length, keyword overlap, placeholders, and toxic language patterns
- LLM-as-judge — Claude Haiku rates output 0–10 with a rubric, normalized to 0.0–1.0
- Semantic — cosine similarity helper that takes any embedding function
MCP-style tools
- Fact-check — checks output statements against a knowledge base
- Schema-check — validates output as JSON with required keys, types, non-empty constraints
Examples
examples/run_rule_based.py— full pipeline with rule-based scorerexamples/run_llm_judge.py— full pipeline with LLM-as-judge scorerexamples/standalone_validators.py— validators and tools standalone, no API key needed
Tests
- 18 unit tests covering all validators and tools
- All tests pass without an API key
Quickstart
pip install -r requirements.txt
export ANTHROPIC_API_KEY=sk-ant-...
python main.py --query "What is LangGraph?" --strategy llm_judgeFeedback welcome
This is my first open-source agent and I am actively looking for feedback and collaborators. Open an issue or discussion with suggestions, critiques, or ideas for what to build next.