r3con
Context representation for large-scale reasoning.
Ask a question whose evidence is scattered across many documents. r3con builds a
task-specific representation of that context, then reasons over it to produce an answer.
Install
pip install r3context
Set the API key(s) for the provider(s) you use:
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
You can also put them in a .env file in your working directory.
Usage
Command line
Pass a directory, glob, or list of files:
r3con run "Which supplier missed the most delivery windows?" ./reports \
--model openai/gpt-6-luna
--model accepts any LiteLLM model string, for
example:
anthropic/claude-sonnet-5-5
gemini/gemini-3.8-flash
hosted_vllm/Qwen/Qwen3.5-35B-A3B
The default is openai/gpt-6-luna.
Directories are searched recursively. You can also use glob patterns or pass files directly:
r3con run "Who approved the Q3 overspend?" "./reports/*.pdf"
r3con run "Who approved the Q3 overspend?" "./reports/**/*.pdf"
r3con run "Who approved the Q3 overspend?" q1.md q2.md q3.md
Quote glob patterns so your shell passes them to r3con unchanged.
Python
Load documents from a directory, glob, or list of files:
from r3con import r3con
docs = r3con.read_documents("./reports")
result = r3con.run(
"Which supplier missed the most delivery windows?",
docs,
)
print(result)
read_documents supports .txt, .md, .csv, .json, .html, .xml, .pdf, and
other common text formats.
If you already have the documents in memory, pass them directly:
result = r3con.run(
"Which supplier missed the most delivery windows?",
[doc_a, doc_b, doc_c],
)
documents is simply a list of strings, one per document.
Notebooks
The examples use five short memos arranged so that no single document contains the full answer:
examples/quickstart.ipynb— an end-to-end example.examples/options.ipynb— models, relevance rounds, generation parameters, run configuration, custom connections, and artifact paths.examples/vllm.ipynb— using a self-hosted vLLM endpoint.
Output
r3con.run(...) returns a result object containing the final answer and the representation
built during the run:
result.answer # str — final answer
result.relevant_context # list[str] — final relevance snippets
result.structured_context # dict — structured representation
result.run_dir # Path — directory containing run artifacts
str(result) returns the same value as result.answer.
Run artifacts
Every run writes its intermediate artifacts to a directory under ./logs. This includes the
relevance snippet produced for each document at every round, the generated schema, parsed
records, model calls, and the final reasoning transcript.
logs/<timestamp>_<hex>/ <- result.run_dir
├── splits.json <- only when a document was read in parts
├── relevance/
│ ├── result.json
│ └── calls.json
├── structuring/
│ ├── schema/
│ │ ├── result.json
│ │ ├── calls.json
│ │ └── transcript.yaml
│ └── parsing/
│ ├── result.json
│ └── calls.json
└── reasoning/
├── result.json
├── calls.json
└── transcript.yaml
Evaluation
For benchmark results, baselines, and evaluation code, see r3con-evaluation.
License
MIT — see LICENSE.
src/r3con/runtime/python_executor.py contains a modified version of the sandboxed
interpreter from smolagents, licensed under
Apache-2.0 and © HuggingFace Inc. See NOTICE and
LICENSE-APACHE-2.0.
Metadata
Release files for r3context 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| r3context-0.3.0.tar.gz | 90.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| r3context-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 200.5 kB
Release files / r3context-0.3.0.tar.gz
| Download URL | r3context-0.3.0.tar.gz |
|---|---|
| Size | 90.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2f2f195cc3c3f1c00b58bcb961e93ba0a65534dad7ebddc00f6a350587bec0b
|
|
BLAKE2b-256 checksum How to use checksums |
37dd6a17ee8bd528cdf242dcfafb238daa5566b23a580401cedeb85af579276c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / r3context-0.3.0-py3-none-any.whl
| Download URL | r3context-0.3.0-py3-none-any.whl |
|---|---|
| Size | 110.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e7ef659db7e8812c9d2b64e776aba5a8ee7926745a300ef233ecd17365e18cd
|
|
BLAKE2b-256 checksum How to use checksums |
52e43a2afc4a4359f34683f2eb453fb31e81aa1e860ab40b4251ea37ae481863
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logSecurity for r3context 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for r3context-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.