Official Python client for the Pomerene deterministic trajectory cache (api.pomerene.io)
Project description
Pomerene Python client
Official Python client for the Pomerene Cloud API — a deterministic trajectory cache for agentic systems. No LLM runs on the cache hit path; on a miss your live agent runs and the trajectory is recorded for next time.
Mirrors the contract in
packages/cloud/openapi.yaml.
Install
pip install pomerene
Quick start
from pomerene import PomereneClient, with_cache
client = PomereneClient("atc_live_…") # defaults to https://api.pomerene.io
cached = with_cache(
my_agent, # your existing (input) -> output
cache=client,
extract_goal=lambda q: q["question"], # what clusters as "the same task"
extract_context=lambda q: {"userId": q["userId"]}, # what gates a hit
to_output=lambda traj, q: traj.outcome, # rebuild output from cache
)
answer = cached({"question": "How do I reset my password?", "userId": "u1"})
Call cached exactly like your original agent. First time a task is seen → your agent runs and the result is recorded. A later semantically similar task → instant cached answer, no LLM call.
Direct API
res = client.lookup(goal, {"userId": "u1"})
if res.hit:
use(res.trajectory.outcome)
# R10 cascade (specific path, then abstract fallback):
res = client.lookup_with_fallback(goal, ctx, abstract_goal)
# Record a trajectory; pass raw context and the server classifies it:
client.store(entry, context={"userId": "u1"})
stats = client.stats() # usage + quota dict
Resilience (defaults)
- lookup fails open — returns a synthetic miss on transport failure (your agent runs live; a cloud outage can't break it).
lookup_fail_open=Falseto disable. - store fails closed — a dropped write raises
PomereneError.store_fail_open=Trueto disable. - retries — 3 attempts with backoff (0.1/0.5/2s) on 5xx/408/429/network.
max_retries=n. - circuit breaker — opens for 30s after 5 consecutive failures.
reset_circuit().
PomereneClient is a context manager (with PomereneClient(...) as c:) and accepts a custom http_client=httpx.Client(...).
Test
pip install -e ".[dev]"
pytest # runs against an httpx.MockTransport — no network
python example.py # needs POMERENE_API_KEY
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pomerene-0.1.0.tar.gz.
File metadata
- Download URL: pomerene-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c746d05b04dd981f6bb048a69d6c8ce2eac4a5697a377ceded8386179c1844d
|
|
| MD5 |
27dcbed67ea8b5f83ed7475d57354209
|
|
| BLAKE2b-256 |
2dec4d719c8e82f58f4c3a23179045a9826ce0048af6fa03e9c21935b045f575
|
File details
Details for the file pomerene-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pomerene-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032f42b41e19aea8eceb537bb05446ebd6ef28a4aae99f20607e8fb7b8001fb9
|
|
| MD5 |
7f47465a695eb8175c9a1330213d7adc
|
|
| BLAKE2b-256 |
a4b92535ca820b4e97c13128ef4b9598166c8e0c8613a9b403a34b993cd46769
|