This release is a pre-release and may not be stable for production use.
Harpe
Choose what goes into each model call, under a token budget. Harpe picks which context items go into each call: pinned items always, then the rest by priority or recency while they fit. It reports exactly what it kept and what it dropped, and the same input gives the same result.
Harpe is one of the three Telarch libraries from Perseus Computing LLC. Kibisis keeps the agent's memory, and Argus keeps a tamper-evident record of what it did. Each one works on its own.
Why
Agents collect instructions, memory, documents and tool output faster than a model can read them. Sending everything costs money and eventually fails. Trimming by hand drops the wrong things, and nobody notices. Harpe makes the cut explicit, repeatable and visible in a report.
What you get
- Pinned items stay. Pinned and priority-0 items are always included. If they alone exceed the budget, nothing else is added and the report shows the overrun.
- Room reserved first. The Rust
TokenBudgetsets aside tokens for the answer, for tool calls and for a safety margin before anything is selected. - A report. You get the kept items, the dropped items, the tokens used and the tokens left.
- The same answer every time. With the default policy there is no randomness and no clock, so the same items and budget give the same selection.
- Your tokenizer. Plug in your model's tokenizer through
TokenCounter. Without one, Harpe uses an estimate. - Confidential items stay home (Python). With the default
destination="remote", items marked confidential are dropped before budgeting. - Whole when it fits (Python).
route_by_fit(history, threshold_tokens)says whether a history fits under a token threshold whole, so it can go to the model as it is, or needs retrieval and a budget. It is off unless you give a threshold. - Small. The Rust crate has no dependencies, and Harpe contains no network code.
Install
This README describes 0.1.0-alpha.5 (0.1.0a5 on PyPI). It is a pre-release, so name the version.
# Rust: Cargo.toml
[dependencies]
harpe = "0.1.0-alpha.5"
# Python
pip install harpe==0.1.0a5
Quickstart
Rust
use harpe::{ContextBudgetEngine, ContextItem, ContextSynthesizer, PrunePolicy, TokenBudget};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let budget = TokenBudget::new(2048);
let items = [
ContextItem::new("sys", "You are an autonomous engineering agent.", 0),
ContextItem::new("obs", "Memory trace step 42: state normal.", 10),
];
let report = ContextBudgetEngine::default().synthesize(&items, &budget, PrunePolicy::LowestPriority)?;
println!("Tokens: {} / {} (pruned: {})", report.consumed_tokens, budget.available_context(), report.pruned_items.len());
Ok(())
}
Python
from harpe import ContextBudgetEngine, ContextItem, TokenBudget, PrunePolicy
budget = TokenBudget(total_budget=2048)
items = [
ContextItem(id="sys", content="You are an autonomous engineering agent.", priority=0, pinned=True),
ContextItem(id="obs", content="Memory trace step 42: state normal.", priority=10),
]
report = ContextBudgetEngine().synthesize(items, budget, PrunePolicy.LOWEST_PRIORITY)
print(f"Tokens: {report.consumed_tokens} / {budget.available_context} (pruned: {len(report.pruned_items)})")
Try it without installing anything: telarch.ai/harpe runs the crate in your browser, compiled to WebAssembly.
Measured
Medians of five runs of telarch-benchmarks at the v0.1.0-alpha.3 release, with synthetic data on one shared server. Every run, its range and the command that reproduces it are on telarch.ai/evidence.
| Measurement | Result |
|---|---|
| Fewer tokens sent over 100,000 simulated agent turns, 1,200-token budget per turn | 78.3% |
| Turns that went over the budget | 0 |
| Median call time, 10 items | 1.72 µs |
| Median call time, 200 items | 36.32 µs |
| Tokens removed to fit the budget, 200 items against 1,500 tokens | 69.5% |
How it works
- Pinned items stay. Items that are pinned or at priority 0 (and, in Python, items of the invariant dimension) are always included. If they alone exceed the budget, nothing else is added and the report shows the overrun (
synthesizeinsrc/harpe/engine.pyandsrc/lib.rs). - Greedy by priority by default.
PrunePolicy.LOWEST_PRIORITYsorts the other items by priority (lower number first; in Python, newer first among equals) and adds each one that still fits. Other policies order items by age, input order or a relevance score; the Python engine also has a dynamic-programming selection over a per-item utility score (KNAPSACK_DP). - Confidential items withheld. With the default
destination="remote", the Python engine drops every item marked confidential before budgeting, so it never takes a slot or reaches the output (src/harpe/engine.py). - Token counts. The default counter estimates a count from word count and character length; pass your own
TokenCounterfor exact counts.
Limits
- Alpha release: APIs and structures are subject to change before 1.0.
- Greedy is not best-fit: The default policy can leave room that a different combination of items would fill.
- Pinned overrun: Pinned items are kept even when they exceed the budget.
- Time-dependent policies:
KNAPSACK_DPandDUO_ATTENTIONscore items by age against the current time, so their selection can change as time passes. - Allocations: Harpe allocates context items and report structures during synthesis.
- Local token heuristic: The default counter estimates token counts from whitespace and character length. When exact counts matter for a downstream provider, pass your own
TokenCounter. - Not independently assessed: No security review or certification has been completed. Designed for local and disconnected use.
Security
Report a vulnerability to contact@perseuscomputing.com with [SECURITY] in the subject; please do not open a public issue. See the security policy for response times.
Links
- telarch.ai/harpe: overview and a live demo
- Documentation (docs.rs)
- Changelog
License
Released under the MIT License © 2026 Perseus Computing LLC.
Metadata
Release files for harpe 0.1.0a5
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 | |
|---|---|---|---|---|
| harpe-0.1.0a5.tar.gz | 58.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harpe-0.1.0a5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 105.9 kB
Release files / harpe-0.1.0a5.tar.gz
| Download URL | harpe-0.1.0a5.tar.gz |
|---|---|
| Size | 58.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bf43f8e3f8863ec2ab7868fc9ed3c1223f9e5d4854f22d8884ef711dbf0b9c6
|
|
BLAKE2b-256 checksum How to use checksums |
15c09cd0c71c1322702663f9a29ab22923f59ce7bfa88ed7406ea928235ffc77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / harpe-0.1.0a5-py3-none-any.whl
| Download URL | harpe-0.1.0a5-py3-none-any.whl |
|---|---|
| Size | 47.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b63364a1989546bdf34673d0a18cadbbd68f042ff7301f661648ae5c9b58f31
|
|
BLAKE2b-256 checksum How to use checksums |
840d90e58a9dcf880b7cdd0aa5e0a88d64795cca41a0e362c769faeed23bcf40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for harpe 0.1.0a5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.