Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4a7e927
refactor(standard): name a keyless custom provider's key from its set…
pierreleca Nov 23, 2026
eee7947
feat(standard): keep each model call of a unit's agent whole in its r…
pierreleca Nov 23, 2026
8226592
feat(builder): choose on the Limits step what each trial keeps of its…
pierreleca Nov 23, 2026
3e3a7a0
feat(runs): read a trial's model calls from its relay's record
pierreleca Nov 23, 2026
eee9f14
feat(traces): show a trial's conversation call by call, with its pict…
pierreleca Nov 23, 2026
80dd971
feat(standard): send a recorded model call again under a spending cap
pierreleca Nov 23, 2026
6739601
feat(standard): compare many recorded calls under named arms, and cou…
pierreleca Nov 23, 2026
af38d41
Merge remote-tracking branch 'origin/main' into feat/model-calls-record
pierreleca Nov 24, 2026
ca88140
Merge branch 'feat/model-calls-record' into feat/replay-and-study
pierreleca Nov 24, 2026
aed6f26
docs(standard): say the exchange record in a row or a sentence each
pierreleca Nov 24, 2026
74fca01
Merge branch 'feat/model-calls-record' into feat/replay-and-study
pierreleca Nov 24, 2026
f619eda
docs(standard): cut the replay page to its commands and one row a rule
pierreleca Nov 24, 2026
a2d10e5
Merge remote-tracking branch 'origin/main' into feat/replay-and-study
pierreleca Nov 25, 2026
4bf5b9f
docs(standard): say the trial saved its exchange record, as the run p…
pierreleca Nov 25, 2026
25dbd7a
docs(standard): say saved for what a run's relay holds of its calls, …
pierreleca Nov 25, 2026
7f62584
Merge remote-tracking branch 'origin/main' into feat/replay-and-study
pierreleca Nov 25, 2026
028c6fc
fix(standard): book each replayed call at the most it can cost
pierreleca Nov 25, 2026
a2afe16
fix(standard): let a study go on under a new cap above its spend
pierreleca Nov 25, 2026
6ee2b10
fix(standard): count a reply that ends on an error as a failure
pierreleca Nov 25, 2026
5a009a0
Merge remote-tracking branch 'origin/main' into feat/replay-and-study
pierreleca Nov 25, 2026
20076e1
docs(standard): say the replay's cap, dry run and going on in one sho…
pierreleca Nov 25, 2026
16ac058
fix(standard): retain the largest study booking per request
pierreleca Nov 25, 2026
93437d2
fix(standard): book prompts at the highest input rate
pierreleca Nov 25, 2026
985790c
fix(standard): recognize the previous built-in study reader
pierreleca Nov 25, 2026
e62e9bf
fix(standard): reject streams with only empty choices
pierreleca Nov 25, 2026
9cd0102
fix(standard): classify saved replies before resuming studies
pierreleca Nov 25, 2026
46f789d
docs(standard): keep the replay page to the rules a user acts on
pierreleca Nov 25, 2026
ce726e5
Merge remote-tracking branch 'origin/main' into feat/replay-and-study
pierreleca Nov 26, 2026
07bb5aa
fix(standard): write a replay's and a study's records through the sha…
pierreleca Nov 26, 2026
e8d746b
Merge remote-tracking branch 'origin/main' into feat/replay-and-study
pierreleca Nov 27, 2026
ddd696a
refactor(standard): give the study's parser a name of its own
pierreleca Nov 27, 2026
1b14b34
refactor(standard): name replay's request-parameter option --param
pierreleca Nov 27, 2026
72807a5
test(standard): check that the study's usage errors come from its own…
pierreleca Nov 27, 2026
ab69984
Merge origin/main into feat/replay-and-study
pierreleca Nov 27, 2026
c1ee523
Merge origin/main into feat/replay-and-study
pierreleca Nov 27, 2026
f34b9c4
Merge origin/main into feat/replay-and-study
pierreleca Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/nullius/standard/calls/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ def release(self, booking: str) -> None:
if doc["held"].pop(booking, None) is not None:
self._write(doc)

def reopen(self, max_usd: float) -> None:
"""A new start of what the ledger caps (a study that goes on), under
``max_usd``: open again, what was spent kept; a cap it replaces is
kept in ``caps``, with what had been spent under it."""
with self._locked() as doc:
if doc["max_usd"] != float(max_usd):
doc.setdefault("caps", []).append({"max_usd": doc["max_usd"], "spent_usd": doc["spent_usd"]})
doc["max_usd"], doc["closed"] = float(max_usd), False
self._write(doc)

def unit_left(self, unit: str) -> Optional[float]:
"""What ``unit`` may still spend under its own cap, every try of it
counted (``forget`` drops the count once no try follows); None
Expand Down
18 changes: 13 additions & 5 deletions app/nullius/standard/calls/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import time
import urllib.parse
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import Dict, List, Optional
from typing import Callable, Dict, List, Optional

from nullius.redact import redact
from nullius.standard.calls import exchanges as exchange_store, ledger as ledgers
Expand Down Expand Up @@ -764,7 +764,8 @@ def __init__(self, base: str, key: str, record_dir: str, prices: Optional[Dict[s
ledger: Optional[str] = None, unit_caps: bool = True, serving: Optional[Dict[str, List[str]]] = None,
facts: Optional[bool] = None, timeout: float = TIMEOUT, max_calls: Optional[int] = None,
exchanges: str = "off", exchanges_max_mb: int = exchange_store.MAX_MB,
reasoning: Optional[Dict[str, str]] = None, routed: Optional[bool] = None):
reasoning: Optional[Dict[str, str]] = None, routed: Optional[bool] = None,
booking: Optional[Callable[[bytes], Optional[float]]] = None):
"""``base``: the provider's endpoint (``https://api.openai.com/v1``).
``model``: when given, every call is sent as this model, whatever the
caller named - the run's model is the recipe's, not the agent's. A
Expand Down Expand Up @@ -793,8 +794,12 @@ def __init__(self, base: str, key: str, record_dir: str, prices: Optional[Dict[s
``exchanges_max_mb``, and numbers its calls in the record (``n``);
``off``, the default, keeps the call record alone. ``reasoning``: by
model, the level put on every request sent as that model (:func:`think`);
``routed``: ``base`` routes a model to several serving providers, by default when it is OpenRouter's."""
``routed``: ``base`` routes a model to several serving providers, by default when it is OpenRouter's.
``booking``: what a capped call is booked at, by the bytes it sends, in
place of the ledger's estimate (:func:`ledgers.bound`): the most it can
cost, held whole until its reply; None, a call it cannot bound, refused unsent."""
self.fields = fields
self.booking = booking
self.max_calls = max_calls
if exchanges not in exchange_store.MODES:
raise ValueError(f"exchanges {exchanges!r}: one of {', '.join(exchange_store.MODES)}")
Expand Down Expand Up @@ -1120,11 +1125,14 @@ def _book(self, req: dict, raw: bytes, rest: str, tag: str = "", h: Optional[Bas
row = self.prices.get(req.get("model"))
if not row:
return None, None, f"no price for the model {req.get('model')!r}: a run with a spending cap sends no call it cannot price", "price"
most = self.booking(raw) if self.booking is not None else None
if self.booking is not None and most is None:
return None, None, "nothing bounds what this call can cost: a capped call is booked at its most", "price"
try:
deadline = time.time() + ledgers.WAIT
least = ledgers.bound(req, raw, row, rest, output=False)
least = None if most is not None else ledgers.bound(req, raw, row, rest, output=False)
while True:
booking, seen = self.ledger.reserve(lambda usual: ledgers.bound(req, raw, row, rest, usual),
booking, seen = self.ledger.reserve(most if most is not None else lambda usual: ledgers.bound(req, raw, row, rest, usual),
ledgers.unit_of(tag) if self.unit_caps and tag else None, req.get("model"),
wait=time.time() < deadline, least=least)
if booking or seen["by"] != "wait":
Expand Down
Loading
Loading