Skip to main content

A pluggable, self-correcting agentic RAG framework with MCP-native retrieval.

Project description

ragloop

PyPI CI Python License

A pluggable, self-correcting agentic RAG framework. Point it at your documents, your vector store, and your LLM, and it answers questions with inline citations — checking its own work and retrying when an answer isn't grounded.

ragloop live demo

The scripted demo (examples/demo.py): a cited, grounded answer for an in-corpus question — and an honest decline instead of an invented answer when the corpus doesn't cover the question.

It's built so that the things companies actually differ on are swappable without touching the engine:

  • Your vector store — Chroma ships as the reference backend; swap in pgvector, Pinecone, or Elasticsearch by subclassing one interface.
  • Your LLM — Anthropic (Claude) ships as the reference provider; add OpenAI, Bedrock, or a local model the same way.
  • Your corpus, models, and retry budget — all config-driven.

How it works

plan -> retrieve -> fuse -> generate -> critique --(grounded?)--> done
            ^------------------------------------------(retry)----'

A LangGraph state machine decomposes the question, lets the agent choose its retrieval strategy (lexical vs. semantic vs. full-chunk read), fuses and ranks the evidence, generates a cited answer, then grades whether that answer is fully supported. If not, it feeds the critique back into retrieval and tries again — bounded by a retry budget. The single back-edge from the critic is what distinguishes this from a one-shot RAG pipeline.

Retrieval is also exposed over MCP, so any MCP-capable client can query your corpus directly with access control enforced server-side.

Install

pip install "ragloop-agentic[all]"            # engine + Anthropic + Chroma + MCP
# or pick pieces: pip install "ragloop-agentic[anthropic,chroma]"
# from source:    pip install -e ".[all]"
export ANTHROPIC_API_KEY=sk-ant-...

The distribution is published as ragloop-agentic; the import name stays ragloop (from ragloop import build_from_config).

Quick start

cp examples/config.example.yaml config.yaml
ragloop ingest ./your-docs --config config.yaml
ragloop ask "What is our refund window?" --config config.yaml

Or from Python:

from ragloop import build_from_config
loop = build_from_config("config.yaml")
result = loop.ask("What is our refund policy?")
print(result["answer"], result["sources"], result["grounded"])

Run the dependency-free demo to see the loop without any API keys:

python examples/quickstart.py
pytest        # the same fakes power the test suite

Live demo

Clone the repo, install the full stack, set your API key, and run the scripted demo against a small fictional policy corpus (examples/corpus/):

pip install -e ".[all]"
export ANTHROPIC_API_KEY=sk-ant-...
python examples/demo.py

The script ingests five policy documents into Chroma (persisted under .chroma_demo/), then asks two questions:

  1. In-corpus"What is the refund window?" — expects a cited answer grounded in the refund policy (e.g. a 30-day window) with grounded=True.
  2. Out-of-corpus"Do you offer financing?" — expects the model to say the sources do not cover financing rather than inventing terms, typically with grounded=True on a decline-style answer.

Each question prints the answer plus metadata:

============================================================
In-corpus: What is the refund window?
============================================================

Answer:
Customers may request a refund within 30 days of delivery [source:refunds:0].

grounded=True  attempts=1  sources=['refunds:0', ...]

============================================================
Out-of-corpus: Do you offer financing?
============================================================

Answer:
The provided sources do not mention financing or payment plans.

grounded=True  attempts=1  sources=[...]

Exact wording varies by model run; the important part is grounded, cited answers for in-corpus questions and an honest decline for out-of-corpus ones.

Serve retrieval over MCP

ragloop serve --config config.yaml

Exposes three tools — keyword_search, semantic_search, chunk_read — to any MCP client.

Extending it

Add a backend by implementing one interface and registering it:

  • New vector store: subclass ragloop.Retriever (add, semantic_search, keyword_search, get_chunk), then add a branch in config._build_retriever.
  • New LLM: subclass ragloop.LLMProvider (complete), then add a branch in config._build_llm.

Nothing in the engine changes. See examples/quickstart.py for a complete custom retriever and provider in ~30 lines.

Project layout

ragloop/
  llm/          LLMProvider interface + Anthropic reference
  retrieval/    Retriever interface + Chroma reference
  engine/       state, nodes (plan/retrieve/fuse/generate/critique), graph
  mcp/          MCP server exposing the retrieval tools
  config.py     YAML + env wiring
  cli.py        ingest / ask / serve

Roadmap

  • Reranker hook in the fusion step (cross-encoder)
  • Persistent agent memory across sessions (LangGraph checkpointer)
  • Reference backends for pgvector and OpenAI
  • Streaming answers

License

Apache-2.0. Contributions welcome — see issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragloop_agentic-0.1.0.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragloop_agentic-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file ragloop_agentic-0.1.0.tar.gz.

File metadata

  • Download URL: ragloop_agentic-0.1.0.tar.gz
  • Upload date:
  • Size: 69.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ragloop_agentic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bcdf8d53406a67a8b8740c9503c476ad33c052e293f9922552b7b01476a1b957
MD5 fac4947a198cd616de190ded5ca91ed9
BLAKE2b-256 558440760847210b01550e7b708c275917b7ddb833092071c71facb7ebeb4e7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragloop_agentic-0.1.0.tar.gz:

Publisher: publish.yml on jaesungl33/ragloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragloop_agentic-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ragloop_agentic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f5e9df50e96a09a5ab695c20c6590377e1c509355bc2ed487957c50038a585
MD5 1f94f56bb7891399b57bcaaaca1460ee
BLAKE2b-256 408c2c95cbb1b3bc6d591ecb1e71867238ae859118addae2e69d4559ad939d78

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragloop_agentic-0.1.0-py3-none-any.whl:

Publisher: publish.yml on jaesungl33/ragloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page