Skip to main content

Prior. Memory for trading agents.

Your trading agent remembers every call, finds out how it went, and learns before the next one.

Time-honest by design. Prior can never hand your agent something it couldn't have known at the moment it decided.

Quickstart · How it works · Core ideas · Example · Status · FAQ · Spec


Contents


Why Prior

Trading agents make the same mistake twice.

  • They forget. Last week's rug looks brand new this week.
  • They never learn from what they skipped. If the agent passed on a token that went 5x, nobody tells it.
  • Their "lessons" can't be trusted. When an agent says it learned something, there's usually no way to prove the lesson didn't peek at the future. A backtest that sees tomorrow's price looks brilliant and means nothing.

Prior is a memory layer your agent calls before and after every decision. It records what happened, goes back later to see how it turned out, turns repeated mistakes into rules, and hands those rules back at the next decision. It does all of that only with what was actually known at the time.

Prior advises. It never signs a transaction, holds a key or places a trade. Your agent stays in control.


How it works

Four steps, on a loop.

Step What happens
1 Record Every bet, trade or skip becomes a Case: what the agent saw, what it decided, why, and what actually filled.
2 Check back Later (1h, 6h, 24h, 7d, or when a market resolves) Prior looks again and settles the Case: win, loss, dump avoided, runner missed and so on.
3 Learn Patterns across settled Cases become proposed Rules (from losses) and Playbooks (from wins). Each cites the Cases it came from. You promote it before it goes live.
4 Recall Before the next decision, the agent asks "what do I know, as of now?" and gets the matching rules, similar past Cases and a hint: skip or proceed.
   your agent
      │
      ├── 1. recall(facts, as_of=now) ──────►  rules + similar cases + hint
      │
      ├── decide and trade  (your code, your keys)
      │
      └── 2. record(case) ──────────────────►  Case
                                                 │
                          3. check back  1h · 6h · 24h · 7d · resolution
                                                 │
                                              Outcome   (scored vs a benchmark)
                                                 │
                                   4. consolidate ──►  proposed Rule / Playbook
                                                 │
                                         you promote ──►  live · versioned · revocable

Core ideas

Term Plain meaning
Agent One trading bot. It has its own memory and its own API keys, like a workspace.
Subject Who or what a decision was for, such as one user's wallet. Rules can apply to one subject or the whole agent.
Case One decision: the snapshot of facts the agent saw, the action (buy, skip, bet_yes …), the reasoning, what it recalled and the execution.
Check-back A scheduled look at the market after the decision.
Outcome What a check-back found, as a label plus numbers. A Case can get several outcome versions as more check-backs land.
Rule A learned "don't" or "be careful", e.g. skip when top-10 holders own over 30%. It has a condition, an effect and evidence.
Playbook A learned "this works", e.g. size up when the pool is over 6h old and volume is rising.
Version Rules never change in place. Every edit, promotion, pause or revoke is a new version with its own dates.
As of The moment you're asking from. Every read in Prior takes one.

Two clocks, no lookahead

This is the part that makes Prior different, so here it is slowly.

Every object carries two kinds of time:

Field Question it answers
seen_at, decided_at When did the agent see the data, and when did it act?
known_at When did this fact, outcome or rule version become knowable?
valid_from, valid_to When was this rule version in force?

Every read goes through one gate, visible_at(T). It only returns things with known_at <= T, and for rules also valid_from <= T and no valid_to yet. An outcome that wasn't settled at T comes back as pending, with no label.

Why it matters. Say the agent bought $WIF at 14:00 and it dumped at 18:00. A rule learned from that dump has known_at = 18:00 or later. If you replay a 15:00 decision, that rule simply isn't there, because it couldn't have been.

That gives you deterministic replay:

prior replay case_8f2c --audit

It rebuilds the decision with exactly the memory it had and checks every rule and outcome it touched. If anything has known_at after the decision, the audit fails and names it.

{
  "case_id": "case_8f2c",
  "cutoff": "2026-11-12T15:00:00Z",
  "replay_match": true,
  "objects_touched": 4,
  "max_known_at": "2026-11-12T14:58:10Z",
  "violations": [],
  "passed": true
}

A Case from start to finish

A memecoin spot agent looking at a new token on Jupiter.

1. Recall, before deciding. The agent sends what it sees:

mem = prior.recall(
    instrument={"mint": "<mint>", "symbol": "MOODENG", "venue": "jupiter"},
    facts={"top10_holders_pct": 41.2, "liquidity_usd": 412_000, "pool_age_min": 38},
)

Prior answers with what was knowable right now (example values):

{
  "decision_hint": "skip",
  "rules": [
    {
      "id": "R-14", "version": 3,
      "text": "Skip when top-10 holders own more than 30%.",
      "condition": {"all": [{"fact": "top10_holders_pct", "op": ">", "value": 30}]},
      "effect": {"type": "skip"},
      "evidence": ["case_41a0", "case_5b77", "case_7c19"]
    }
  ],
  "similar_cases": [],
  "max_known_at": "2026-11-29T09:12:00Z"
}

2. Record the decision, even a skip.

prior.record("skip", instrument=token, facts=facts, recall=mem,
             kind="spot", reasoning="R-14 fired: 41% in top 10")

3. Check back. Prior looks at the price at 1h, 6h, 24h and 7d. At 24h the token is down 63%, so the outcome is dump_avoided. If it had gone up 3x instead, it would be runner_missed, and that evidence would count against R-14.

4. Learn. If R-14 starts missing more runners than dumps it avoids, consolidation proposes a looser version (say, over 45% instead of over 30%) with the Cases that justify it. You review it and promote it or not.


Quickstart

Needs Python 3.11 or newer. pip install prior-sdk installs pydantic 2.14.4, fastapi 0.165.0, and uvicorn 0.55.0, pinned from PyPI on 3 Dec 2026.

python -m venv .venv && source .venv/bin/activate
pip install prior-sdk

To work on Prior itself, clone this repository and run pip install -e . instead.

Record and recall (local mode)

Local mode keeps everything in one SQLite file, so there's no server to run.

from prior.sdk import Prior

prior = Prior.local("./prior.db", agent_id="ag_demo")

token = {"mint": "<mint>", "symbol": "MOODENG", "venue": "jupiter"}
facts = {"top10_holders_pct": 41.2, "liquidity_usd": 412_000, "pool_age_min": 38}

# 1. Ask what you know, as of now
mem = prior.recall(instrument=token, facts=facts)

# 2. Decide with your own logic, then record it. Skips are recorded too.
action = "skip" if mem.decision_hint == "skip" else "buy"
prior.record(action, instrument=token, facts=facts, recall=mem,
             size_usd=50, kind="spot", reasoning="why the agent did this",
             synthetic=True)

prior.close()

See the audit catch a leak

python examples/prior_local.py

It records a Case, recalls it, then sneaks in a rule from the future. The replay audit catches it and names the rule.


SDK reference

Call What it does Guarantee
Prior.local(path, agent_id=...) Open a local SQLite memory One file, no server
prior.recall(instrument, facts, as_of=None, subject=None, k=5) Rules, playbooks, similar Cases and a hint, as of as_of (default now) Times out at 300 ms and returns an empty degraded result instead of raising
prior.record(action, instrument, facts, recall, reasoning, size_usd, kind, subject) Save a decision as a Case Returns in under 50 ms. If the store is down the Case is spilled to disk and retried. Never raises into your loop unless strict=True
prior.flush() Retry anything spilled
prior.replay(case_id) Deterministic replay and lookahead audit Same inputs, same answer, every time
prior.cases.list(...), prior.cases.get(id) Read Cases as of a time Goes through visible_at

kind is spot, prediction or perp. action is one of buy, sell, skip, bet_yes, bet_no, open_long, open_short or close.

A hosted client (Prior(api_key=...)) is in the SDK and will point at the /v1 API once that lands. The TypeScript client is prior-sdk on npm (npm install prior-sdk), sourced in sdk/. It wraps this API and does not open a second store.


CLI reference

export PRIOR_DB=./prior.db
export PRIOR_AGENT_ID=ag_demo

python -m prior.cli cases list --since 7d
python -m prior.cli cases list --outcome loss --as-of 2026-11-30
python -m prior.cli cases show <case_id>
python -m prior.cli recall --facts facts.json --as-of 2026-11-30
python -m prior.cli replay <case_id> --audit
python -m prior.cli leak-test
  • After pip install prior-sdk, replay also works as prior replay <case_id> --audit --db ./prior.db.
  • prior checkbacks run --db ./prior.db reads due check-backs and appends outcome versions. It needs COINGECKO_API_KEY, and a Pro key needs COINGECKO_TIER=pro: the default tier is demo, so a Pro key on the demo base returns a 400 (error_code 10010) and the read reports no price. CoinGecko onchain price is a live pool price, not a historical candle, and the command does not invent one. known_at is the time the read returns.
  • python -m prior.api --db ./prior.db serves the same SQLite file. Reads take as_of and go through visible_at. Lists return {items, next_cursor}. Keys use pr_live_ and pr_test_. Only the hash is stored. Postgres waits. There is no second database.
  • Add --json to any command for scripts.
  • leak-test runs the time-honesty checks against the Cases in your database and exits non-zero on failure. An empty database doesn't count as a pass.

Check-backs and outcomes

Check-backs are created the moment a Case is recorded, including skips.

Market Check-backs The one that settles it
Spot 1h · 6h · 24h · 7d 24h
Perp 1h · 6h · 24h · close close (or liquidation)
Prediction resolution, polled hourly for up to 30 days resolution

A failed read retries three times (60s, 5m, 15m), then stays failed until retried by hand. Every check-back writes a new outcome version. Old ones are never changed.

Label Meaning
win / loss / flat A trade that made, lost or roughly broke even
dump_avoided A skip, and the price fell more than 50% within 24h
runner_missed A skip, and the price more than doubled within 24h
rug Liquidity pulled or price went to zero
resolved_yes / resolved_no A prediction market settled

Scored fairly. Each outcome is compared with a benchmark over the same window (SOL for spot, the market's own price for prediction), giving excess_return_pct. A trade that lost 10% while the market lost 20% did better than the market, and Prior won't learn a "don't" from it. Prediction bets also get a Brier score, so you can see whether the agent's probabilities are honest.


How Prior learns

Consolidation reads settled Cases (only those whose outcome was known by the time it runs) and proposes new rule and playbook versions. It never promotes on its own.

  • Evidence or nothing. A proposal lists the Cases behind it, and its condition must actually match them. A draft whose text doesn't match its own condition is rejected.
  • No noise rules. Candidate rules go through a Benjamini-Hochberg false-discovery check, so random streaks don't become rules.
  • Not too cautious. If a skip rule has missed more runners than dumps it avoided over the last 30 days, Prior proposes a looser version.
  • Excess return, not raw PnL. Rules are learned from how a decision did against the benchmark.
  • Kill switch. Every rule carries pause_if: rolling_30d_edge < 0 or ci95.high < 0, so a rule that stops paying for itself gets paused. (The automatic pause is being wired in now.)
  • Missing facts never match. If the agent didn't have a fact, no rule that needs it can fire.

Evals

Does memory actually help? Prior answers that with a walk-forward eval over a frozen list of Cases. It uses one decision function, and the arms differ only in what memory they're allowed to see.

Arm Sees
no_memory Nothing. A fixed checklist only (mint and freeze authority, thin liquidity, token age)
prior Rule versions and settled outcomes with known_at <= decided_at
shuffled The same amount of memory, scrambled. A control: if this does as well as prior, the memory isn't the reason

The report lists every decision where the arms disagree, with the real outcome beside it. It doesn't name a winner for you.

Prior replay set, 542 cases, Sep to Nov 2026. 542 of them settled, read as of 2026-12-04T13:11:21.346415Z.

Agent Arm Cases Skips Mean excess when proceed (%)
ag_replay_prediction no_memory 36 0 33.2021
ag_replay_prediction raw_notes 36 0 33.2021
ag_replay_prediction rules_no_checkback 36 0 33.2021
ag_replay_prediction prior 36 0 33.2021
ag_replay_prediction shuffled 36 0 33.2021
ag_replay_spot no_memory 506 0 0.0788971
ag_replay_spot raw_notes 506 0 0.0788971
ag_replay_spot rules_no_checkback 506 0 0.0788971
ag_replay_spot prior 506 393 -0.325771
ag_replay_spot shuffled 506 0 0.0788971
Agent Metric prior - no_memory Dropped pairs 95% CI
ag_replay_prediction paired mean weighted excess, % per case both arms took, pairs either arm could not price dropped 0 0 [0, 0]
ag_replay_spot paired mean weighted excess, % per case both arms took, pairs either arm could not price dropped -0.151648 0 [-0.820938, 0.529609]

Replay audit over the full set: 542 cases, 0 lookahead violations, passed true. Leak sweep: 544 cutoffs, 0 violations, passed true.

The arms disagree on 393 decisions; evals/report.json lists each case id with its real outcome and excess beside it.

Every case names 1048 decision-time sources and 542 outcome sources by public url and timestamp in evals/dataset.json. Data by Coingecko API.

ag_replay_prediction: the five arms take the same decision on all 36 cases, so there is nothing to separate here. ag_replay_spot: prior is -0.151648 points per case against no_memory, interval [-0.820938, 0.529609], so the interval spans zero and this set does not separate the two arms. The arms disagree on 393 of 506 decisions.


Venues and adapters

Adapters wrap your function. They read quotes and results and attach the execution to the Case. They never sign.

Venue Market Status How outcomes are checked
Jupiter Spot swaps, Solana memecoins Built CoinGecko on-chain token price by mint
Jupiter Predict Prediction markets, YES / NO In progress Market resolution
Phoenix Perps Stretch goal Phoenix market data and funding
Custom Any function you wrap Built A price function you supply
from prior.adapters import jupiter

swap = jupiter.wrap(my_swap_fn)   # your function, your signer

The wrapper records quote, fill, slippage, fees and the transaction signature. A failed swap is stored as failed and the original error is re-raised.

A spot arm prices its token through CoinGecko onchain by mint, which needs COINGECKO_API_KEY, and a Pro key needs COINGECKO_TIER=pro because the default tier is demo. Without both, the arm records no spot case and says no_price_source instead of a price; it never fills the gap with a number it did not read.

Spot prices: Data by CoinGecko API.


Safety

  • No keys, ever. Adapters refuse to store anything that looks like a private key or keypair (KeypairRefusal).
  • Append-only. The database blocks UPDATE and DELETE on Cases, outcomes and rule versions.
  • Human in the loop. Rules are proposed, not promoted, until you say so.
  • Never in your way. A slow or broken Prior can't stall or crash your trading loop.

Status

Prior is being built in the open for the Solana Perps and Prediction hackathon. Submissions close Tue 8 Dec 2026, 22:00 WAT.

Piece What it does State
Store and replay audit Append-only SQLite, visible_at(T), lookahead audit, leak sweep ✅ Merged · #6
SDK and CLI Non-blocking record, safe recall, replay, leak-test ✅ Merged · #11
Adapters Jupiter and custom swap wrap, never signs 🟡 In review · #8
Check-back and settle Check-backs for every Case, outcome versions, CoinGecko price 🟡 In review · #9
Consolidation Proposes rules and playbooks, too-cautious loop, FDR 🟡 In review · #12
Walk-forward eval no_memory vs prior vs shuffled 🟡 In review · #10
Console client Typed reads for the dashboard 🟡 In review · #7
One shared model package Every service on prior.core 🔜 Next
REST API and keys /v1 server, scoped pr_live_ / pr_test_ keys 🔜 Next
Check-back runner Settles due Cases on a schedule 🔜 Next
Jupiter Predict adapter Markets, bets, resolution 🔜 Next
Console Cases, Memory, Replay, Evals, Keys 🎨 Designed, wiring next
MCP server /mcp for Claude, Cursor and Codex, ten tools incl. prior_check 🟡 In review · #31

The older checklist now imports as prior.checklist. It is frozen. New work goes in the rest of prior/.


Repo layout

prior/
  core/        models, the visible_at time gate, condition logic
  store/       SQLite store with append-only triggers
  services/    checkback, settle, consolidate, evals
  adapters/    jupiter, custom, prices/coingecko
  sdk/         Prior client: local and hosted, queue, disk spill
  cli/         python -m prior.cli
  recall.py    recall as of a cutoff
  replay.py    deterministic replay and lookahead audit
console/       typed client for the dashboard
examples/      prior_local.py: record, recall, then fail an audit on purpose
docs/          technical spec and brand assets
tests/         leak, append-only, replay, check-back, consolidation, eval
prior/checklist/  frozen checklist, formerly tracemind

Tests

pip install -e ".[dev]"
python -m unittest discover -s tests -q
python -m unittest discover -s prior -q

The dev extra carries httpx2, which fastapi.testclient needs at import time: prior.mcp.tests.test_api_parity fails at import on a clean pip install -e . without it.

What the important ones prove:

Test Proves
Leak sweep Across 50 random cutoffs, no read returns anything from after the cutoff
Replay 100 replays match their stored recall exactly, and a seeded future rule fails the audit
Append-only UPDATE and DELETE are refused, including replace
Skip check-back A skip gets check-backs and can settle as dump_avoided or runner_missed
Too-cautious A skip rule that misses runners gets a looser proposal
Missing facts A rule needing a fact the agent didn't have doesn't match, and nothing crashes
Non-blocking SDK With the store down, record returns in under 50 ms and the Case lands later

FAQ

Is this a trading bot? No. Prior is memory for a trading bot. Your agent makes the calls. Prior remembers them, checks how they went and tells the agent what it has learned.

Does it predict prices? No. It learns from your agent's own track record, not from forecasting.

Why record skips? Because most lessons hide there. A rule that skips everything looks safe until you count the runners it missed.

Why not just use raw PnL? Raw PnL punishes the agent for market-wide moves it couldn't control. Prior scores against a benchmark so it learns from the agent's choices, not the market's mood.

What does "time-honest" really mean? For any past decision you can prove which memory it used, and that all of it existed before the decision. Run prior replay <case> --audit and check.

Can a rule go live by itself? No. Consolidation only proposes. A person promotes, and any rule can be paused or revoked at any time.

What happens if Prior is down? Your agent keeps trading. record spills to disk and retries, and recall returns an empty degraded result.


Read the full technical spec

prior · the past is known, the future is open

Metadata

Release files for prior-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prior-sdk 0.1.0
File Size Uploaded Provenance Actions
prior_sdk-0.1.0.tar.gz 279.3 kB Without provenance Details for prior_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prior-sdk 0.1.0
File Interpreter ABI Platform Actions
prior_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for prior_sdk-0.1.0-py3-none-any.whl

Total release size: 444.6 kB

Release files / prior_sdk-0.1.0.tar.gz

Download URL prior_sdk-0.1.0.tar.gz
Size 279.3 kB
Tags Source
SHA-256 checksum
How to use checksums
12377ebea33c6bf7ce9371d71d498b8dc31a38125b0e82a8a8dec87f448508c0
BLAKE2b-256 checksum
How to use checksums
0c4a6258c95c70ecc2b60b1896f79e67a459fcd81fd22c1fb9bd3e83d5fae449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / prior_sdk-0.1.0-py3-none-any.whl

Download URL prior_sdk-0.1.0-py3-none-any.whl
Size 165.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ce86a204a8ce38e5be9c14719b3dd88798de5241b0192ce8445d453acfa1e2
BLAKE2b-256 checksum
How to use checksums
e8f2f92af15e836c5129c96fb58a1f5e1302687c3508f4d086ecdb6d9e119383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for prior-sdk 0.1.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.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page