Skip to content

feat(standard): send recorded model calls again under a spending cap, and compare them - #344

Open
pierreleca wants to merge 16 commits into
ThinkFlowLab:mainfrom
pierreleca:feat/replay-and-study
Open

pierreleca wants to merge 16 commits into
ThinkFlowLab:mainfrom
pierreleca:feat/replay-and-study

Conversation

@pierreleca

@pierreleca pierreleca commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #343

What

  • Testing a prompt change at one step meant running the whole task again.
  • nullius standard replay JOB TRIAL --call N --times K --max-usd USD rebuilds call N from the trial's exchange record, checks its sha256 and sends it K times.
  • Changes: system text, tools, a replaced text, messages dropped, a parameter, model, provider, pin, a command.
  • Its own relay, at the job's provider and price; nothing past the cap; --dry-run sends nothing.
  • Each answer's label, its first tool call or a command's output, is counted.
  • study: many calls, named arms, one cap, a sign test between two arms; run again, it sends only the unanswered; a changed plan is refused.
  • recount: a study or replay read again by another rule; no send, no key.
  • One folder outside the job; no page reads it.

Verified

  • Backend 177 modules, 3,059 tests; routes 72, 708: nothing fails that main passes.
  • Before this merge, scripted model, no key: call 1 of an OSWorld1 trial sent once under 0.01 USD and answered; its 153,799 bytes matched the recorded sha256.
  • Not checked: a real provider; study and recount outside the tests.

Risk

  • With a key it makes paid calls; --max-usd caps them, over all of a study's starts.
  • The key is never written; credentials echoed in an answer are cut out.
  • Undo: revert.

Agents

  • Claude Code, Opus 5.5: code, tests, review of the fixes
  • Codex, gpt-6-astra: review, fixes
  • Claude Code, Fable 5.2: design, plan

@pierreleca
pierreleca force-pushed the feat/replay-and-study branch from d80823d to 847db95 Compare November 24, 2026 11:21
aitianshi added a commit that referenced this pull request Nov 24, 2026
Closes #379

## What

Before a live feed exists, a run now opens on Logs. Launch stages and
log output live there; the first usable feed switches to Live within the
same document, without reloading. Explicit tab choices are respected.
Restarted stages drop stale timing/detail, terminal executions settle
stage state, and unknown unit totals use an indeterminate bar.

The full-run overview shows identity cards with Runner first, then
Benchmark/Dataset, Agent/Model, and Trials/Duration. Task and All
attempts pages keep their own status and metrics without repeating run
identity.

Task overview cards put timing and Tool calls on the left and Model
usage on the right, stacking on narrow screens. Model usage combines a
compact token bar with Prompt growth when multiple calls were recorded.
Its labels and segments are input, cache, output; input means uncached
input, as its tooltip explains. Cache hit is plain text. Saved trial
totals provide a fallback when trajectory accounting is absent, and
missing usage is stated explicitly.

## Touches

backend · routes · templates and static · tests · field guide

No equivalent open or closed issue/PR was found in the repository or
private fork. Related open work: #336 (run facts), #338 (trial details),
#340 (task step progress). These have shared-file overlap, but implement
separate behavior. After merging main, pairwise merge checks are clean
for #332, #336, #338, #340, #342 and #344. Unmerged #352 and #354 still
require coordination in app/templates/runs/job.html and app/web/runs.py;
their features are not included here.

## Before and after

Task overview: the earlier real-run capture and the approved final
layout from that same saved run. Run identity is now kept on the
full-run overview.

| Before | After |
| --- | --- |
| <img width="430" alt="Earlier task overview with separate growth and
tool sections"
src="https://raw.githubusercontent.com/ThinkFlowLab/nullius/feat/run-logs-tab/app/ui_tests/evidence/run-logs/task-after.png">
| <img width="430" alt="Timing and Tool calls on the left, combined
Model usage on the right"
src="https://raw.githubusercontent.com/ThinkFlowLab/nullius/feat/run-logs-tab/app/ui_tests/evidence/run-logs/model-usage-after.png">
|

Full-run identity cards and Live/Results/Logs:

<img width="860" alt="Full-run overview with Runner first and benchmark,
dataset, agent, model, count and duration cards"
src="https://raw.githubusercontent.com/ThinkFlowLab/nullius/feat/run-logs-tab/app/ui_tests/evidence/run-logs/run-overview-after.png">

## Verified

- Backend suite: 2,856 tests in 173 modules passed after merging current
main outside the socket-restricted sandbox.
- Route suite: 660 tests in 68 modules passed after merging current
main.
- Focused progress and execution tests: 83 passed.
- Browser checks: desktop light/dark and narrow layout; automatic Logs →
Live retains the document and `performance.timeOrigin`; tab selection
and task metrics checked.
- Real τ³-bench Airline task using `meta/muse-spark-1.3-contributor`:
reward 1.0, 55.54 seconds agent time, 22 steps. Recorded uninterrupted
from cold setup through Logs → Live, Results and the task page. The
simulator and judge used `openai/gpt-4.1` because the configured dated
default alias was unavailable. The earlier refused attempt was not
counted as this successful run.
- Field-guide checks: 2 passed. Usage regression cases cover one call,
multiple calls, final metrics, trial totals, unreadable trajectories,
missing usage and output-only records.
- `git diff --check` passed.

## Risk

Feed readiness and polling changes could leave a preparing page on the
wrong tab; explicit choices must not be overridden. A terminal execution
now settles a remaining stage even if its final stage event was absent,
but does not manufacture a duration or unit count. Runs without launch
records have no Logs tab. The overview derives the benchmark from the
catalogue or a single recorded task source. The token summary preserves
existing trajectory cache accounting; partial per-call records can still
describe only the recorded subset. Revert to undo; no storage migration.
…ting

A custom provider without a key is sent a placeholder word. The run
wrote that word itself, while the launcher and the judge read it from
settings.MODEL_KEY_PLACEHOLDER. Reading it from the setting here too
lets every reader of a run's requests know which word is no secret.
…elay's record

A trial's call record keeps the last two messages of each model call,
cut to 2,000 characters and without pictures: what the model was shown
at a step is lost. Each unit's relay now also keeps every call of its
agent whole under the trial's .work/relay/exchanges: the request as
sent and its sha256, each distinct part and picture written once, and
the reply as it arrived. Only the relay's key is cut out. A failure to
write never changes or stops the reply, and each file names its format
so that a later one is refused rather than guessed.

run --exchanges whole|text|off (whole by default) and
--exchanges-max-mb N (256 a unit by default) choose and bound it; the
job's config records both and a recipe takes them. The judge's and the
simulated user's calls keep their call record alone.
… model calls

A recipe could take the exchange record's mode, but the builder had no
way to set it. The Limits step now has three small cards under the
spending caps: Pictures and text (the default), Text alone and Nothing.
A choice other than the default goes into the recipe and onto the run's
command line; the default adds nothing. A run that calls no model shows
no cards.
The record of a trial's calls is only useful once something reads it.
traces/calls.py builds a trial's conversation by model call from it:
each call's time, tokens and cost, what it sent that the call before
had not (pictures by their sha256), its answer whole and the steps of
the trajectory under it. A store of a later format is refused with a
notice, and a trial without a store reads as before.

runs show ... --calls prints that view as JSON, redacted.
runs show ... --call N --request prints call N's request rebuilt to the
bytes sent and says on stderr whether its sha256 is the recorded one.
Both find an earlier try of a trial by its NAME.try-N.
…ures

The Conversation tab lists the steps of a trajectory, and the pictures
an agent sent its model show nowhere. A trial with an exchange record
now opens the tab on its model calls, twelve a page: the selected call
shows what it sent that the call before had not, its answer and the
steps under it. A picture is served from the trial's own store by its
sha256, only when that store lists it and only as an image type; a
click opens it in a dialog over the page, and a click with a key held
opens it in a tab of its own. The Artifacts tab counts the pictures and
their size, with a link to the tab.
Testing a change of prompt on a model call that went wrong means
running the whole task again. replay rebuilds call N of a trial from
its exchange record, checks it against its recorded sha256 and sends it
K times, as it was or with named changes: the system text, the tools, a
tool's description, a replaced text, the last messages dropped, a
parameter, the model, the serving providers, the provider, or a command
of the user's. It goes through a relay of its own, under the job's
provider, model and price, and stops at the required --max-usd. Each
answer is read by a rule and the distinct answers are counted.

--list lists a trial's calls and --dry-run sends nothing. Everything is
kept in one folder outside the job. The key is read from the
environment or the saved settings and never written, and credentials
echoed in an answer are cut out. A new page documents the command and
its use from Python.
…nt them again

One replay shows how a single call answers; whether a change helps
needs many calls of several trials, each sent as recorded and changed,
compared call by call. study sends each target (lines of a file, or the
calls of a job's trials: all, every Nth, or those whose recorded answer
matches) K times as recorded and under each --arm NAME=CHANGES, under
one cap for the whole study. One reading rule, kept before the first
send, labels the answers; the counts give a table by target and arm,
and two arms are compared with an exact sign test. The same command
again goes on after a stop, and a changed plan is refused.

recount reads a kept study or replay again by another rule, with no
send and no key. The replay page gains a section with one worked study,
and a test runs the page's own reading script.
@pierreleca
pierreleca force-pushed the feat/replay-and-study branch from 847db95 to 6739601 Compare November 24, 2026 13:55
The Artifacts tab lists the pictures sent to the model first, then
Nullius's records, then the benchmark's own under their heading row.

The trial's page imports main's evidence reader beside the calls, and the
builder's Limits row keeps main's words on attempts and retries, with
what each trial keeps of its model calls after the cap on them.
The calls branch now stands on main with the trial's detail and records,
the builder's new words and the job's identity cards. Nothing of this
branch's conflicted.
The rows this branch added on the exchange record retold the relay's
code: its file layout, its version line, its retries and its failures.
The record's section keeps two sentences and the rows a user chooses or
meets: the text mode, off, the bound, what is not kept and where the
result names it. The read-jobs rows and the builder's Limits row each
say what the command or the choice is.

Two clauses of the standard's Progress and Outcomes rows described the
live feed's steps and a scored cut, which this branch does not hold; one
linked a section it does not have. They go back to main's words.
The calls branch cut its section on the exchange record to the rows a
user chooses or meets. This branch's row on a request sent again stays,
before the result's row.
The page retold the code: the folder's files one by one, the calls from a
program and a worked study of the same commands. It keeps the two
synopses, a row of ten to fifteen words for each option or rule a user
meets, and the reading script its test runs. The run page's row on a
request sent again links to it.
The calls branch this one builds on is now on main, with the reviewer's
own edits to the builder and the run page: main's text wins in every
file of that branch. This branch keeps only the replay and the study.

AGENTS.md takes main's shorter form, which has no module list: the
replay and study entries in it go. The run page's row on a request sent
again stays, before the result's row.
…age does

The run page and the builder now say a run saves its model calls. The
replay page used the older word for the same choice.
…in the replay and study

The run's choice of what its relay holds of each model call is now
named "Model calls saved", and the run page says the relay saves each
call. The replay and the study used the older word in their help, their
messages, their docstrings and their page, and the recount's count of
answers missing from the record was named not_kept. They now say saved.
Main changed its instructions and templates alone: no file of this
branch is touched, and nothing conflicted.
@pierreleca
pierreleca marked this pull request as ready for review November 25, 2026 10:16
@github-actions github-actions Bot added the needs review Tests pass, no conflict, no verdict on its latest commit label Nov 25, 2026
@aitianshi

Copy link
Copy Markdown
Collaborator

@pierreleca Tried at 7f62584 on GSM8K with a scripted model (no real provider). Three things to fix, and one question.

  1. The cap can be passed. replay --times 1 --max-usd 0.001, booked at 0.000272, got a 5,000-token answer: spent 0.0102 USD of 0.001. The issue asks that no send go past the cap. Could it be enforced, or the promise reworded?
  2. A study that reaches its cap cannot go on. The same command is refused again (the ledger is closed), and a higher --max-usd is refused too (has a cap of 0.001 USD). Could the cap be raised?
  3. An answer cut by an error counts as an answer. HTTP 200 with a partial text and finish_reason: "error" in the choice: study with --read counts it as not yes, says done, and a restart does not send it again. A reply that is only an error is retried correctly.

Question: how is a replay meant to be used? Today it is the command line only, and nothing follows the new answer: the task is not re-done from that step. Is a button planned on the trial page's call (edit the prompt, send K times, see the counts)? Re-doing the whole task with the changed prompt? Or is it command line only? Please say which, and what is left for a later PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review Tests pass, no conflict, no verdict on its latest commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A recorded model call cannot be sent again to test a change

2 participants