Decision-learning infrastructure

Make your AI agents learn which actions work.

BanditDB is the decision layer for AI agents and adaptive applications. It learns from context, actions, and outcomes to select better models, tools, prompts, offers, and workflows over time.

โ˜… GitHub ยท Docker Hub ยท PyPI ยท npm ยท Apache-2.0
model-router.py โ— live
# Describe the situation as a feature vector or embedding
context = [
    0.91,  # complexity
    0.46,  # cost_sensitivity
    0.32,  # latency_sensitivity
]

# Ask BanditDB which model to use
arm, iid = db.predict("model_router", context)
selected: claude-sonnet
iid: 8f1a...c92

# Report the observed outcome
db.reward(iid, 0.87)
✓ policy updated in memory

Stop hard-coding decisions your application can learn.

Static rules cannot adapt to changing users, tasks, costs, or outcomes. BanditDB turns repeated decisions into a measurable learning loop.

Hard-coded router rules.py
-  # rules drift and exceptions multiply
-  if task == "coding":
-      model = "model_a"
-  elif customer == "enterprise":
-      model = "model_b"
-  elif cost_limit < 0.02:
-      model = "small_model"
-  else:
-      model = "model_c"

Every new condition is another branch you maintain by hand.

BanditDB decision loop router.py
+  # learn from every measurable outcome
+  arm, iid = db.predict(
+      "model_router",
+      request_features
+  )
+  
+  response = run(arm)
+  
+  db.reward(iid, quality_score(response))

One call. The policy updates itself from real outcomes.

Different databases answer different questions.

POSTGRES / OLTP

What is true?

Store facts and transactions

VECTOR DATABASE

What is similar?

Retrieve related information

BANDITDB

What should I do?

Learn from decisions and outcomes

stack.txt
  your app / agents
        โ”‚
        โ”œโ”€โ”€ SQL โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ  postgres       "what is true?"
        โ”œโ”€โ”€ embed + ANN โ”€โ”€โ”€โ”€โ”€โ–บ  vector store   "what is similar?"
        โ””โ”€โ”€ predict/reward โ”€โ”€โ–บ  banditdb       "what should I do?"

  swap any layer independently ยท plain HTTP ยท no coupling between stores

When to reach for it โ€” and when not to

Good fit: a finite set of actions, repeated often, with a measurable reward. Bad fit: one-off decisions, unbounded action spaces, unmeasurable outcomes.

domain context action reward
Insurance
claim complexity, prior history, policy tier route to fast-track, adjuster, or SIU review time to resolution
Ad tech
device, time of day, audience segment which creative variant to serve click or conversion
Logistics
order size, zone congestion, SKU mix pick path or packing station fulfillment time
LLM routing
prompt embedding, task type which model handles the request task success, cost-adjusted
Checkout
cart value, returning visitor, device discount, free shipping, or gift completed purchase
Banking
credit utilization, income, repayment history credit line offer to extend repaid without default
Healthcare
symptoms, vitals, treatment history which protocol to recommend patient outcome improved
Edtech
skill level, past attempts, learning pace which exercise or hint to serve next concept mastered
Constant memory

Matrices, not documents

Two objects hold the learning state: a matrix tracking evidence and uncertainty, and a vector linking observations to rewards. Together, they calculate the best action fresh on every requestโ€”not retrieve it from a log.

Choosing an Algorithm โ†’
.91
.12
.04
.08
.12
.74
.09
.03
.04
.09
.66
.14
.08
.03
.14
.81

Every decision keeps one matrix and one vector that update in place โ€” not a growing log โ€” so memory stays flat no matter how much traffic the DB has seen.

Monitoring ยท backup ยท restore

Observable over HTTP, durable through the Write-Ahead Log (WAL) and checkpoints, recoverable after a crash.

Observable

Prometheus metrics, per-campaign health diagnostics, and alerts if a campaign stops exploring properly.

GET /metrics
GET /campaign/:id/diagnostics
GET /campaign/:id/report
GET /health โ†’ ok | degraded

Durable

A reward returns only once it is fsynced to the Write-Ahead Log โ€” an acknowledged write survives a crash a millisecond later. Checkpoints snapshot state, export to Parquet, and rotate the log automatically.

POST /reward โ€” fsync before 200
POST /checkpoint
BANDITDB_CHECKPOINT_INTERVAL
BANDITDB_MAX_WAL_SIZE_MB

Recoverable

On restart, BanditDB loads the last checkpoint and replays everything written after it โ€” 100,000 events in about 0.6 seconds. If the process is killed outright, no acknowledged reward is lost.

recover() โ€” automatic on boot
POST /campaign/:id/archive
POST /campaign/:id/restore
Enterprise ready
RBAC โ€” admin ยท writer ยท reader
Constant-time key checks
Per-key rate limiting
Input validation
Audit log โ€” JSONL
Self-healing WAL โ€” auto-retry on I/O errors

Shared policy state for agent fleets

The MCP server exposes campaigns as tools, so every agent in the fleet reads and writes one shared, persistent policy.

register with claude
$ claude mcp add banditdb banditdb-mcp --env BANDITDB_URL=http://localhost:8080
create_campaign
Define a new decision
get_intuition
Ask which action to take
record_outcome
Report success or failure
campaign_diagnostics
Inspect learning state

Two commands and BanditDB is a native tool in Claude, Cursor, or any MCP-compatible host โ€” no config file editing required. Not a chat memory, not a vector store: every recorded outcome sharpens one shared policy the whole fleet reads from.

Six end-to-end walkthroughs

Ordered simplest โ†’ most advanced. Each ships runnable code and a reward-design discussion.

โ˜… Start here
๐ŸŒ™

Sleep Improvement

Temperature, light, or noise โ€” which adjustment works best for each person? A pure curl walkthrough, no SDK needed.

1
Measurable lift after ~300 rewarded outcomes โ€” assuming โ‰ฅ 70% next-morning reporting compliance.
curl 3 arms ยท 5 features Read walkthrough โ†’
๐Ÿ›’

E-Commerce Upsell

Discount, free shipping, or nothing โ€” learns which checkout offer closes each shopper without giving margin away.

2
Measurable lift after ~1,500 checkout interactions at 50% completion โ€” binary reward is noisiest of the four examples.
python 3 arms ยท 3 features Read walkthrough โ†’
โš–๏ธ

Law Firm Client Intake

Consult, intake form, refer, or decline โ€” learns which response maximises matter value for each enquiry profile, accounting for capacity and conflict risk.

3
Measurable lift after ~600 intake decisions at 50% outcome rate โ€” reward is multi-valued, not binary.
python 4 arms ยท 5 features Read walkthrough โ†’
๐Ÿ’ฐ

Dynamic Pricing

Hold margin or liquidate? Learns from sell-through rate, holiday proximity, and competitor pricing โ€” context describes the market, not the user.

4
Measurable lift after ~500 hourly cycles on common states โ€” rare holiday combinations require 2โ€“3 full seasons.
python 4 arms ยท 5 features Read walkthrough โ†’
๐Ÿค–

Prompt Optimisation

Learns which prompt strategy โ€” zero-shot, chain-of-thought, few-shot, structured โ€” produces the best response for each task type. Your evals run in production, not in a spreadsheet.

5
Measurable lift after ~400 requests โ€” LLM-as-judge gives near-100% reward observability.
python 4 arms ยท 5 features Read walkthrough โ†’
๐Ÿฅ

Adaptive Clinical Trials

Routes patients toward the most effective treatment arm in real time as evidence accumulates โ€” no waiting months for interim analysis.

6
Measurable lift after ~400 completed follow-ups โ€” enroll ~500 patients to account for 80% compliance.
python 3 arms ยท 4 features Read walkthrough โ†’
~11MB
Native binary for Linux, macOS, and Windows
ฮผs
Matrix updates via Sherman-Morrison rank-1 formula
~10K
Predictions per second on a single node
+16.7%
Lift over random on MovieLens 100K โ€” up to +24.6% with feature engineering
4
Algorithms: LinUCB ยท Thompson Sampling ยท NeuralLinUCB ยท Progressive Tournament

Install

No sign-up. No cloud account. No configuration required.

binary โ€” linux, macos, windows

$ curl -fsSL https://raw.githubusercontent.com/dynamicpricing-ai/banditdb/main/scripts/install.sh | sh

docker

$ docker run -d -p 8080:8080 simeonlukov/banditdb:latest

Join the community

Ask questions, share what you're building, get early updates. The BanditDB Discord is where the conversation happens.

Discord community

Get help, share projects, talk to the team. Free and open to everyone.

Join Discord
Talk to the founder

Questions about enterprise use, integrations, or just want to say hi โ€” book a 30-min call.