Skip to main content

A single agent that answers from your compiled corpus — every claim cited.

Project description

reigner

A single agent that answers from your compiled corpus — every claim cited.

PyPI Python CI License: MIT

📚 Documentation: https://construct-lab.github.io/reigner/

Reigner is a toolkit for building citation-faithful question-answering agents over a knowledge corpus. First you ingest your sources — a one-time compile step that reads your raw documents (PDF, text, HTML) and extracts the facts you care about into a structured store, its artifacts. A single retrieval agent then answers questions over that store — never touching your raw files at query time — with every factual claim traced back to its source. It is a library first: not a chat app, not a coding-agent harness, not a multi-agent orchestrator.

Reach for Reigner when you want a Q&A agent shaped to your corpus and use case — not a fixed product. It's a library you tune end to end: the instructions, the tools, the schema, the model are all yours to change. Within that flexibility it keeps two things hard — citation-faithfulness is a testable property (the eval fails uncited claims), and a cheap model handles the routine work so cost stays bounded.

One core, three surfaces

Reigner is a library: you write one agent and reach it three ways as it grows from an idea to a running service. The agent is a small project folder — a REIGNER.md of instructions, a schema, and your tools — and it stays the same folder at every step.

  • Build — Write your agent as code. reigner init scaffolds the project folder for you: the REIGNER.md instructions, a schema and extractor (how your documents become searchable), plus any @tools or plugins you add. This folder is your agent.
  • Test — Run it from your terminal. ingest compiles your documents, chat asks questions, and session fork / replay / eval let you A/B/C different instructions, tools, or models — so you tune without starting over.
  • Ship — Serve it over HTTP. serve exposes that same folder through a FastAPI endpoint that streams over Server-Sent Events (SSE), so your apps consume it with no rewrite. (MCP — Model Context Protocol — export is planned; see status below.)

Features

  • Compiled artifacts — ingestion compiles raw documents into a bounded, schema-aware store. The agent queries the compiled graph, never your raw files.
  • Bounded, self-describing tools — every tool result reports has_more, truncated, and available_keys, so a finite-context model always knows whether it got everything.
  • Citations are first-class — numeric and factual claims register a CitationEvent with provenance; the eval suite fails answers that make uncited claims.
  • Oracle escalation — a cheap default model runs the loop and calls escalate_to_oracle only when a question needs deeper reasoning; that single turn is served by a stronger model, then it reverts. You pay frontier prices for the hard steps, not the routine ones.
  • Context stays bounded under pressure — a legible agent loop with numbered guardrails: pressure-driven history compaction, per-tool result truncation, and a scratchpad whose notes survive compaction — so long runs don't blow the context budget.
  • Parallel, cached reads — read-only tool calls in a turn run concurrently and hit a per-session cache, cutting both latency and duplicate model-driven calls.
  • An eval battery — score your agent against your own compiled corpus for faithfulness, coverage, and repeated-call efficiency; iterate on REIGNER.md, tools, or model with numbers.
  • Forkable sessions — durable JSONL sessions on disk that you can fork and replay to compare variants without re-running from scratch.
  • Write your UI once — the CLI, HTTP server, and MCP all emit the same typed events (tool calls, citations, status), so an interface, logger, or integration you build against one surface works unchanged against the others.
  • Provider-agnostic — Anthropic, OpenAI, and Gemini adapters behind one interface.

Quickstart

uv add 'reigner[anthropic,ingestion]'      # model adapter + PDF/URL loaders

reigner init mydocs --recipe document_qa   # scaffold a project
# drop your PDFs/text into mydocs/, then:
cd mydocs
reigner ingest                             # compile documents into artifacts
reigner chat                               # ask questions, get cited answers

reigner chat answering a question with per-claim citations

The full walkthrough — every command with real output and a per-feature status flag — is in the usage guide.

Install

uv add reigner

Reigner ships a thin core; each capability is an opt-in extra:

Extra Purpose
reigner[anthropic] Anthropic model adapter
reigner[openai] OpenAI model adapter
reigner[gemini] Gemini model adapter
reigner[server] FastAPI HTTP server with SSE
reigner[mcp] MCP server export (planned — not wired yet)
reigner[ingestion] PDF/URL loaders for the ingestion pipeline
reigner[otel] OpenTelemetry metrics plugin
reigner[all] Everything above

License note

Reigner itself is MIT-licensed. The [ingestion] extra pulls in PyMuPDF, which is AGPL-3.0. Downstream projects that distribute or network-serve a closed-source product on top of reigner[ingestion] must comply with AGPL or obtain a PyMuPDF Pro commercial license. To avoid the AGPL entirely, override LLMExtractor.raw_to_text with a permissive-licensed loader of your choice.

Learn more

  • Usage guide — hands-on, install → scaffold → ingest → chat.
  • Architecture — the harness: agent loop, oracle escalation, and the G1–G11 context guardrails.
  • Observability — OpenTelemetry spans for the agent loop.
  • Principles — why Reigner exists and the rationale behind each design decision.
  • API reference — the typed public API.

Development

uv sync --all-extras --group dev
uv run pre-commit install
uv run pytest

CI runs ruff check, ruff format --check, mypy, and pytest on every PR.

License

MIT — see LICENSE.

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

reigner-0.10.0.tar.gz (192.6 kB view details)

Uploaded Source

Built Distribution

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

reigner-0.10.0-py3-none-any.whl (261.0 kB view details)

Uploaded Python 3

File details

Details for the file reigner-0.10.0.tar.gz.

File metadata

  • Download URL: reigner-0.10.0.tar.gz
  • Upload date:
  • Size: 192.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for reigner-0.10.0.tar.gz
Algorithm Hash digest
SHA256 34619264689fdae73aac0af39853b6afeb0f948f36abb82057247356bbfe0f6e
MD5 6812bc183f2d69de829bcd4a78811ec9
BLAKE2b-256 d6093c93f3977543aa15c5febb5d935f863e8ea9ca6e0492ce3e2f374e911169

See more details on using hashes here.

File details

Details for the file reigner-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: reigner-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 261.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for reigner-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67b97d617377f40ff0111be9eb907a60138ce169f9313a3f314621b1185c9870
MD5 ff1a229fac2d6f3542268a10a761bb56
BLAKE2b-256 1197dbadb43257c201d2acf01a626621dd06bbba8e7fbe73c5181339eea122b3

See more details on using hashes here.

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