# Context, speed and user experience evaluation

This report records the prototype measurements. See
[IMPLEMENTATION.md](IMPLEMENTATION.md) for the production prompt/profile repair,
fresh measurements and completed release gates.

2026-10-23. Recommendation: immediate implicit continuation for ordinary work,
explicit event-driven waits for known dependencies, optional pacing/limits for
users who choose them. This evaluation supports that tradeoff; it does not prove
a universally optimal scheduler or eliminate the default idle-loop risk.

## Measured scope

- Apple M2, macOS arm64, Node 26.10.0, Pi SDK 1.0.0.
- Original `64c5ace`, current branch policy `3551bcc`, and the isolated default-off
  prototype generated by `experiments/continuation/prepare.mjs`.
- 72 offline captures: the same 24 context fixtures against all three copies.
- 19 actual-SDK scenarios with a localhost scripted provider, starting through
  `/goal` and normal draft/auditor confirmation choices. These are additional to
  the earlier 20 SDK probes, three real-model goals and three terminal journeys.
- Cached-settings scheduler-entry microbenchmarks: 100 warm-up operations, then
  100 samples of 10 logical-run entries plus 20 work events each.

No new paid model calls were made. [Full structured evidence](evidence/efficiency-results.json)
includes environment, source-policy labels, request counts, bytes, prefix changes,
latencies, outcomes and per-case percentiles.

## Context: no added default payload; idle loops still cost context

All **24 parent composed requests were byte-for-byte identical across the three
source copies at equal fixture state**; child auditor/Oracle size breakdowns also
matched. No baseline was regenerated. The existing `npm run context:gate`
also passed all 24 fixtures. This establishes no added default state/schema bytes
in these fixtures; it does not establish live cache hit rates.

In the candidate's actual idle sequence, provider-visible message sizes grew:

| Executor request | Message JSON bytes | Cumulative message JSON bytes sent |
| --- | --- | --- |
| 1 | 9,488 | 9,488 |
| 4 | 10,379 | 39,734 |
| 8 | 11,567 | 84,220 |
| 16 | 13,943 | 187,448 |
| 32 | 15,037 | 447,270 |

The tool-schema payload was another 6,978 bytes per request in this fixture. These
are UTF-8 JSON/framing bytes, not provider token counts or billed charges. The
32-request ceiling was imposed by the harness, not the product. History retention
has bounded state-tail behavior, so size does not grow by a fixed amount forever;
neither that bound nor prefix caching makes repeated model requests free.

### A real prefix issue remains a release gate

Execution tool schemas stayed identical within every scenario. The live leading
system prompt did **not** always stay identical: after the first work tool, its
serialized leading-message size dropped by 82 characters in both original and
candidate runs. In the custom-tool case this occurred at executor request 2; in
the distinct-reasoning case it occurred at request 14, after the first write.
Both policies exhibited the same transition. Different case-directory lengths
also account for small absolute prefix-size differences between cases.

This is a measured prefix rewrite, not a demonstrated paid cache miss. It could
invalidate prefix reuse on an exact-prefix provider. The subsequent
[minimal reproduction](../../experiments/continuation/profile-boundary.mjs)
does not import pi-goal-x: after a terminating profile switch, the custom turn
advertises the work tool but retains draft-only prompt guidance until that tool
returns. A fresh custom trigger has no leading system message until the tool
returns. Both cases produced the expected artifact, demonstrating that artifact
correctness alone would miss the mismatch. [Host-only results](evidence/profile-boundary-results.json).

Installed Pi 1.0 starts a custom trigger through `_runAgentPrompt` without the
normal `prompt()` loadout preparation; its next-response refresh applies the new
profile after a tool. Production planning requires a supported host/API resolution
and correct guidance from the first executor request. No private host state was
patched and no upstream report was sent. A fixed-state context gate alone would
have missed this. Do not claim the prototype is perfectly cache-stable.

The first probe used fresh `/goal-direct` SDK entry and observed no leading system
message until after its first work tool. The main measurement was therefore
rerun through the confirmed standard `/goal` workflow, where a system message was
present from execution start. The direct-start observation remains part of the
compatibility gate; changing the benchmark entry did not resolve it.

## Speed: small local costs, no classification round trip

| Candidate scenario | Executor / draft / auditor requests | Outcome | Local continuation p95 |
| --- | --- | --- | --- |
| Twelve distinct reasoning replies, then artifact | 15 / 1 / 1 | Correct result, audited completion | 4.51 ms |
| Three productive custom-tool sections, then artifact | 9 / 1 / 1 | Correct result, audited completion | 5.27 ms |
| Repeated idle text, default | 32 / 1 / 0 | Harness stopped it | 5.24 ms |
| Same idle text, option enabled | 2 / 1 / 0 | Pending ~30s pacing | One immediate sample, 4.28 ms |
| Same idle text, configured allowance of four | 4 / 1 / 0 | Product paused at allowance | 4.78 ms |
| Explicit supported wait | 4 / 1 / 1 | Quiet wait, one wake, correct result | Wake to next request: 17.93 ms |

Local continuation time is measured from the harness's settlement observer to the
next loopback provider request. It includes host dispatch and local I/O after that
observer, not the whole settlement handler, remote networking or inference. The
wait case intentionally includes a 250ms wait; report its wake latency separately.
Duplicate producer events caused one wake, with no request during the observed
wait. Timers remained armed throughout quiet-window sampling.

Original and candidate used the same number of executor calls in the completed
reasoning/custom-tool scenarios. The current unconditional policy instead paced
after two reasoning responses or two custom-tool executions. No additional model
classification, readiness declaration or audit-after-every-turn was introduced.

### Local bookkeeping is small; do not overstate the optimization

| Logical-run entry + 20 work events | 10 tasks p50 / p95 | 50 tasks p50 / p95 | Goal snapshots per 1,000 entries |
| --- | --- | --- | --- |
| Current unconditional pacing | 0.00156 / 0.00235 ms | 0.00264 / 0.00346 ms | 1,000 |
| Candidate, default off | 0.00343 / 0.00727 ms | 0.00322 / 0.00370 ms | 0 |
| Candidate, enabled | 0.00382 / 0.00485 ms | 0.00541 / 0.00833 ms | 1,000 |

The option lookup adds a small constant cost at ordinary task sizes; the candidate
is not faster in every microbenchmark. Its disabled path performs zero optional
goal serializations. A deliberately oversized 1,000-task synthetic stress fixture
measured candidate-off p95 0.00413ms versus current 0.05696ms; this is outside the
supported 50-task input limit and is not a product-capacity claim. JIT effects,
cached settings and sub-microsecond original timings preclude ratio claims.
With settings explicitly invalidated before each of 100 separate 50-task entries,
candidate-off p50/p95 was 0.03813/0.05583ms; enabled was 0.04013/0.05179ms. This
isolates cold settings lookup from steady-state bookkeeping, rather than hiding
disk reads inside a warm result. Neither benchmark measures a whole execution.

This is sufficient to reject extra caching layers or bespoke settings fast paths
without evidence. Avoiding artificial 30-second delays and unnecessary inference
calls matters far more than saving a few microseconds here.

## Guard tradeoff, modeled rather than copied

Two harness policies allowed one initial execution plus either one or eight more
consecutive tool-free executions. Both stopped repeated idle text; both also
stopped the twelve-step distinct reasoning sequence before it wrote its result.
The existing configured four-run allowance stopped through the actual product,
with visible paused lifecycle state. The policy-model stops are harness actions,
not runs of Codex/Claude and not implemented Pi lifecycle behavior.

The original/current/candidate repeated `ls` fixture all made 64 executor requests
over 32 executions before the harness ceiling. Tool activity can bypass pacing;
any-tool guards also have that limitation. No tested heuristic proves useful work.
Keep optional limits honest and easy to select. See [RESEARCH.md](RESEARCH.md) for
the official product policies and the reason they are not adopted as hidden defaults.

## User experience and actual model usage

The earlier terminal journeys remain the UI evidence: normal start/confirmation,
Escape pause, readable status, resume, audited completion, settings scope and
inheritance, and disabling a live delay. Opting out resumed dispatch about 16ms
after the preference changed, without another resume command. No settings action
made a model request. These are agent-operated walks, not representative user
research. [Terminal evidence](VALIDATION.md#actual-keyboard-walkthrough).

The ordinary-wording real-model run reported 23,811 input, 3,507 output and 29,184
cache-read tokens, with zero reported cache writes. Those are separate SDK counters,
not a percentage savings claim. The other successful runs had different actions,
auditor workloads and counts. Their 66.9–74.1 second elapsed times cannot rank the
policies. [Original usage records](evidence/real-model-results.json).

UI refinements required before release:

- Preserve the existing creation/confirmation flow and completion auditor.
- Keep cost controls in advanced settings; show scope, effective value and source.
- Explain hard allowance versus pacing versus waiting in brief advanced help.
- Use relative delay/local time and a clear next action; the current raw UTC
  timestamp and "paced" wording are not the final user-facing copy.
- Check keyboard movement, cancel/back, reopen, 72-column layout and actual paused
  recovery. Verify that disabling pacing preserves consumed allowance.

## Release budgets and reproduction

| Gate | Required outcome | Current evidence |
| --- | --- | --- |
| Equal-state default context | 0 added schema/policy bytes, no rewritten baselines | Passed, 24 fixtures × 3 policies |
| Default scheduling | No artificial pacing timer; no classification inference | Passed controlled scenarios |
| Pacing disabled | 0 optional goal snapshots | Passed, all measured task sizes |
| Local entry budget | p95 below 0.1ms at 10/50 tasks in this cached-settings harness | Passed; not a whole-turn SLA |
| Dependency wait | 0 requests before signal/deadline; duplicate wake admitted once | Passed sampled SDK windows |
| Live prefix/profile | Correct profile at executor start; diagnose/remove avoidable rewrites | **Open production gate** |
| Human controls | No extra creation decision; pause/resume, scope and opt-out work | Earlier terminal walkthroughs passed; final copy/layout recheck needed |
| Full production regression | Supported SDK matrix, cache/compaction/large history, all test suites | Pending production implementation |

Run from the repository:

```sh
node --experimental-strip-types experiments/continuation/efficiency.mjs
node --experimental-strip-types experiments/continuation/profile-boundary.mjs
npm run context:gate
npm run check
npm run lint
node_modules/.bin/eslint --no-ignore experiments/continuation/*.mjs
```

The campaign recreates only isolated evaluation cases and uses no credentials.
`profile-worker.mjs` measures one source copy per child process to avoid module and
settings-cache contamination. Context captures run sequentially because their
existing harness shares a temporary path. No production source or README changed.

Failed probe assumptions were corrected, not counted as successful measurements:
the initial prefix-invariance assertion exposed the transition above; a temporary
UI stub omitted SDK defaults and timed out before starting a goal, then was fixed
to use `createContext().ui`. The final campaign reports the observed prefix variants
instead of erasing the transition or claiming it passed an invariance test.
