Skip to content

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

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

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

Conversation

@pierreleca

@pierreleca pierreleca commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #343
Depends on #342.

What

Testing a change of prompt on a model call that went wrong means running the whole task again. nullius standard replay JOB_DIR TRIAL --call N --times K --max-usd USD rebuilds call N from the trial's 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 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 cap. A rule reads each answer, and the distinct answers are counted. --dry-run sends nothing.

study does the same for many calls of several trials under named arms of changes, one cap for all, and compares two arms call by call 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. Everything is kept in one folder outside the job. A new page documents the three commands.

replay.py and study.py sit in standard/runner/ because they call provider_endpoint and Refused of runner/run.py; they would sit in standard/calls/, beside the relay and the ledger they use, if provider_endpoint moved there.

Touches

the standard · docs and site

Verified

  • Both suites, one module a process, beside main: nothing fails that main passes (backend 176 modules, 3,021 tests; routes 72 modules, 698 tests).
  • Against a scripted model with no key, on an OSWorld1 trial recorded by the pull request it depends on: --list showed its 2 calls whole, and call 1 sent once under a 0.01 USD cap was answered; the model received 153,799 bytes with the recorded sha256.
  • field_contract.py --write and catalogue_docs.py --write change nothing; git diff --check is clean; the judge's own checks pass offline.
  • Not verified: a send to a provider's model; study and recount beyond their tests' stand-in endpoint.

Risk

With a key it makes paid calls, never past the required --max-usd; a study's cap holds over all its starts. The key is read from the environment or the saved settings and never written, and credentials echoed in an answer are cut out. Nothing is sent unless one of these commands is typed. Revert the commits to undo.

@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.

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

None yet

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

1 participant