Skip to content

docs: plan for benchmarking the agent in-repo, as CI gates - #544

Merged
FMXExpress merged 2 commits into
mainfrom
claude/agent-bench-plan
Aug 14, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/agent-bench-plan

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Plan for improving the agent's effectiveness by benchmarking it inside the sandbox it develops in — no external services, results as CI gates that fail rather than print.

Why now

The week's optimization work (batch rule #537, SerialOnly #538, MCP compact results, disclosure, turn clock #543) all shipped on mechanistic arguments. None of it has a measured effect. This plan makes "this makes the agent better" claims arrive with a number — mostly by wiring together what already exists rather than building from scratch.

Census the plan is grounded in

  • A scripted ILLMProvider already drives RunToolLoop — TScripted in the progress-ledger tests (AddToolRound / AddStop / AddTruncated). The in-process bench substrate exists.
  • The metric taps already exist — TToolLoopResult carries iterations, usage incl. cache read/created tokens, truncations, dispatched calls.
  • Context hygiene already exists, untested for effect — per-turn hash-aware read dedup (C3) and stale-read stubbing after writes. This corrects my earlier Bullet-eval claim that PasClaw has no re-read guard.
  • PR bench/swe: empirical bench harness for tuning PasClaw agent settings #313 holds a real 13-fixture SWE-shaped bench (oracles, ablation grid, Pareto report) on a branch with no merge base with main — it can never merge. The plan mines bench/swe/ onto main and closes the PR; bench: LOCOMO-shaped memory-retrieval harness for memory_search #308 (bench/locomo/) gets the same treatment.

Phases

  • P0 — bench record: opt-in NDJSON per turn from the existing taps, plus per-iteration request bytes and prefix byte-stability (the ledger's "NO counters, no timestamps" constraint, turned from a comment into a measured invariant).
  • P1 — make bench-loop: in-process scenario bench with committed budgets — parallel batch wall-time ≈ max not sum, 50-iteration prompt byte-stability, C3 dedup fires, stale-read stubbing fires, cap bounds history growth, SerialOnly writer splits. Regression = red target.
  • P2 — extract bench/swe/ from the orphaned branch, land the fixture tier, close bench/swe: empirical bench harness for tuning PasClaw agent settings #313/bench: LOCOMO-shaped memory-retrieval harness for memory_search #308.
  • P3 — opt-in live-model A/B of the shipped levers (rule 7 on/off = the unmeasured Bullet number; disclosure; compact results; autorouter presets). Needs an API key; prints a cost estimate and refuses without explicit --spend.
  • P4 — the backlog the bench adjudicates: cross-turn dedup, attachment eviction, condense tuning, tool-description budget. Each lands only with its bench delta attached.

Honest boundary

Harness-level properties are fully measurable in-sandbox with the scripted provider (the model is held constant by being a script). Model-dependent effects need the live tier — it runs here through the HTTPS proxy, but only once a key is configured, and it's an opt-in tier, not a prerequisite.

Plan only — no code changes. Say "go" per phase, same as the previous plan docs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6


Generated by Claude Code

The week's agent-optimization work (batch rule #537, SerialOnly #538,
compact results, disclosure, turn clock #543) all shipped on mechanistic
arguments with no measured effect. The plan closes that by wiring together
what already exists rather than building a bench from scratch.

Census findings the plan is grounded in:
- a scripted ILLMProvider (TScripted) already drives RunToolLoop in the
  progress-ledger tests -- the in-process bench substrate exists
- TToolLoopResult already carries the metrics (iterations, usage with
  cache read/created tokens, truncations, dispatched calls)
- context hygiene already exists and is untested for effect: per-turn
  hash-aware read dedup (C3) and stale-read stubbing after writes --
  which corrects the earlier Bullet-eval claim that PasClaw has no
  re-read guard
- PR #313 holds a real 13-fixture SWE-shaped bench with oracles and an
  ablation grid, but its branch has NO merge base with main -- the plan
  mines it onto main and closes the PR, same treatment for #308

Phases: P0 bench record (NDJSON per turn incl. prefix byte-stability),
P1 in-process scenario bench with committed budgets as a failing CI gate,
P2 extract bench/swe from the orphaned branch, P3 opt-in live-model A/B of
the shipped levers (needs a key; refuses without --spend), P4 the backlog
each item lands only with its bench delta attached.

Honest boundary stated up front: harness properties are fully measurable
in-sandbox with the scripted provider; model-dependent effects (does rule
7 change batching) need the live tier.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86d0873017

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/agent-bench-plan.md Outdated
| 3 sleeping read-only tools in one scripted response | wall time ≈ max(tool), not sum — parallel dispatch works end-to-end, not just in `PartitionToolBatches` |
| 50-iteration scripted turn | system prompt byte-identical across iterations 2..50 (prefix-cache proxy) |
| repeat read of an unchanged file | second result is the C3 dedup stub |
| write then re-read of the same path | `StubSupersededReads` fired |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reverse the supersession scenario

This scenario cannot exercise StubSupersededReads: the function is invoked after a successful write and only replaces earlier read_file results already present in history. A write followed by a read therefore leaves the new, current read untouched, as it should. Script a read followed by a write and assert that the pre-write body was replaced; otherwise the proposed CI gate will either fail permanently or test the wrong behavior.

Useful? React with 👍 / 👎.

Comment thread docs/agent-bench-plan.md Outdated
| scenario | budget it pins |
|---|---|
| 3 sleeping read-only tools in one scripted response | wall time ≈ max(tool), not sum — parallel dispatch works end-to-end, not just in `PartitionToolBatches` |
| 50-iteration scripted turn | system prompt byte-identical across iterations 2..50 (prefix-cache proxy) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Account for the ledger transition in the stability budget

For a 50-iteration read-only script, this budget fails even when the cache-stability behavior is correct: FormatLedgerBlock deliberately adds the sticky progress-check text once TotalCalls reaches LedgerNudgeAfter (8), so a later system prompt differs from iteration 2. The scenario must either arrange for no ledger-state transitions or compare prompts only while the folded ledger state is unchanged, rather than requiring iterations 2–50 to be universally identical.

Useful? React with 👍 / 👎.

Comment thread docs/agent-bench-plan.md Outdated
Comment on lines +60 to +63
### P1 — in-process loop bench as a CI gate (`make bench-loop`)
Promote `TScripted` out of the ledger test into a shared unit and drive
`RunToolLoop` through scenario scripts, each with a committed budget the
run must meet — a benchmark that *fails*, not one that prints:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Build on the existing agent-loop benchmark

The repository already has a deterministic scripted loop harness exposed as make bench-agentloop (Makefile:997-1005, with scenarios documented in bench/agentloop/README.md), but the plan proposes a second benchmark target and harness without mentioning it in the census. Implementing this literally would create overlapping suites and target names; the plan should explain whether P1 extends/replaces that harness or why an additional in-process suite is required.

Useful? React with 👍 / 👎.

Comment thread docs/agent-bench-plan.md Outdated
| Scripted in-process provider (`TScripted: ILLMProvider`, AddToolRound / AddStop / AddTruncated) | `src/tests/progress_ledger_tests.pas` | working, test-local |
| Per-turn metric taps: `Iterations`, `TotalUsage` (incl. **CacheRead/CacheCreated tokens**), `Truncations`, `TruncatedBytesSaved`, `ToolCallsDispatched`, `HitMaxIterations` | `TToolLoopResult` | populated every turn; surfaced in TUI `/stats` + gateway usage |
| Context hygiene: per-turn hash-aware read dedup (`DedupRepeatRead`, C3), stale-read stubbing after writes (`StubSupersededReads`), output caps (`OutputCache`), compaction | `PasClaw.Tools.ToolLoop` | shipped, untested for *effect* |
| Loop seams exported for tests | `PartitionToolBatches`, `HistWithTurnClock` | unit-benchable today |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the nonexistent exported loop seam

A repo-wide search at this commit finds no HistWithTurnClock declaration or implementation, so it is not an exported seam that is unit-benchable today. Anyone following the census will be unable to use it; either identify the actual symbol or make exporting/implementing this seam an explicit prerequisite.

Useful? React with 👍 / 👎.

#544)

All four findings are legit, and the first one is a census failure on my
part -- the whole premise of the doc was "survey first", and I missed
bench/agentloop entirely.

1. bench/agentloop already exists with `make bench-agentloop` and NINE
   scenarios. It plays a scripted model over the relay provider, asserts
   on what the loop did, and already emits request-byte metrics. Its
   repeatread scenario benches the C3 dedup, fatread the output cap,
   histelide compaction, build-site the ledger fold plus iteration-1
   pristine. Roughly 60% of the P1 I proposed was already implemented,
   and a second `make bench-loop` target would have collided with it. P1
   is now "extend bench/agentloop", with only the genuinely-new
   scenarios listed, and "a second harness or target name" is an
   explicit non-goal.

2. The prefix-stability budget was wrong by design: FormatLedgerBlock
   adds sticky nudge text once TotalCalls reaches LedgerNudgeAfter (8),
   so "iterations 2..50 byte-identical" fails even when caching behaves
   correctly. The budget now models the transition -- identical WITHIN a
   ledger-state-stable window, with the one permitted change occurring
   exactly at 8 calls and nowhere else.

3. The supersession scenario was backwards. StubSupersededReads rewrites
   reads that came BEFORE a write; my script was write -> read, which
   leaves the new read untouched and would have tested nothing. Now
   read -> write, asserting the earlier body was stubbed.

4. HistWithTurnClock is not on main -- it lives on the open PR #543. It
   was listed as an exported seam benchable today; it is now marked a
   prerequisite, and the turn-clock scenario is explicitly blocked on
   that merge.

Also recorded while verifying: bench/agentloop/README.md links ../swe,
which is on the orphaned #313 branch, so main ships a dangling reference
-- extra evidence for the P2 mining step.

The revision note is kept in the document on purpose. "We already had
one" is the most useful thing this plan can tell the next person.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
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.

2 participants