Repository navigation
bench: deterministic agent-loop harness benchmark (bench/agentloop, pure FPC) - #413
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd65da237d
ℹ️ 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".
| })); | ||
|
|
||
| const gw = spawn(BIN, ['gateway'], { | ||
| env: Object.assign({}, process.env, { PASCLAW_HOME: homeDir, NO_COLOR: '1' }), |
There was a problem hiding this comment.
Scrub inherited PasClaw env for the benchmark
When a developer runs this with their normal PasClaw environment loaded, the child gateway inherits variables that override the throwaway config: PASCLAW_CONFIG makes LoadConfig ignore homeDir/config.json, and PASCLAW_GATEWAY_TOKEN/OPENCLAW_GATEWAY_TOKEN make /v1/chat/completions and /v1/relay/* require auth. The bench HTTP helpers never send Authorization, so those environments either exercise the wrong gateway config or get 401s instead of the deterministic relay run. Build a sanitized env here, or explicitly set PASCLAW_CONFIG to the generated config and clear the gateway-token vars.
Useful? React with 👍 / 👎.
cd65da2 to
35bb26d
Compare
Codifies the relay-worker methodology that found the
MALFORMED_FUNCTION_CALL death spiral, the workspace/CWD split, and the
goal-drift failure: the bench spawns a real gateway against a throwaway
PASCLAW_HOME, connects as the relay worker, plays a scripted "model", and
asserts on what the LOOP did -- the system prompts it built, what landed
on disk, how big the request bodies grew. Fully reproducible, zero API
tokens, every envelope inspectable.
Pure FPC, no external runtime: TProcess spawns the built binary, the
worker thread holds the SSE poll with the same TIdHTTP + custom-TStream
frame parser shape as PasClaw.Cmd.Relay, and PasClaw.JSON +
PostJSON/GetJSONURL cover the wire. The shipping binary is what gets
exercised.
Three scenarios (16 assertions):
* build-site -- ledger folds into iteration 2 (goal + written
file + checklist), iteration 1 pristine
(prefix-cache), deliverable exists on disk.
* malformed-recovery -- a Gemini-shaped malformed empty turn is retried
with the corrective nudge naming a REGISTERED
tool, and the turn still delivers.
* resume-after-cap -- the 25-iteration notice carries the resume
ledger (do-NOT-redo, file names, read counts);
a "continue" turn anchors its ledger goal to the
original task, not to the word "continue".
Metrics print either way -- provider calls to deliverable and max
request-body bytes across 25 iterations (24 KB baseline: the number the
future context-diet work gets measured against). Harness changes land
with before/after numbers, not vibes.
`make bench-agentloop` (compiles + runs; needs the built binary;
deliberately not part of `make test` since it binds a port).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
35bb26d to
c7e4fb3
Compare
An uncapped tool result rides verbatim in history for the rest of the
turn: one fat read_file / grep_files inflated EVERY subsequent request --
the top context-growth driver behind the 125 KB request bodies seen on
real runs (slower turns, higher cost, and outsized histories are what
push Gemini-class models into the malformed-call behaviour in the first
place). ToolOutputCap existed but defaulted to 0.
* TConfig default 0 -> DefaultToolOutputCap (24576 ~ 6K tokens):
generous enough that normal reads pass verbatim, tight enough that a
runaway result can't dominate the turn. tool_output_get always
recovers the full text, and every surface already registers it when
the cap is on (the gates key off Cfg.ToolOutputCap > 0).
* ToJSON now emits tool_output_cap when it differs from the default --
including an explicit 0 opt-out, which must round-trip or the next
LoadConfig would silently re-enable the cap.
* stock profile mirrors the new default; baseline keeps its explicit 0
(the "everything off" A/B floor); low-token 8192 / max-build 16384
stay as their own explicit choices.
* Onboarding: Enter keeps the default, y customises, n disables.
Harness-verified (bench/agentloop, new fat-read scenario: a 100 KB read
at iteration 1, then further iterations):
before (main): fatread.max_request_body_bytes = 129256
after (this): fatread.max_request_body_bytes = 21502 (6x)
plus asserts the capped result carries the tool_output_get handle.
Also: fixes the stale test-session-stats assertion that has been failing
on main ("default is False" -- StatsCollectionEnabled defaulted to True
in FMXExpress#314's six-free-toggles change; the round-trip test now exercises the
explicit-off direction). Includes FMXExpress#413's bench commit: that PR merged
into its stacked base branch (claude/progress-ledger) instead of main --
GitHub only retargets when the base branch is deleted -- so the bench
never actually landed on main; carried here verbatim.
Known follow-up: the TUI's inner loop config doesn't wire ToolOutputCap
(pre-existing; its loop caps at 6 iterations and has its own condensers).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
Stacked on #412 (its scenarios assert the progress-ledger behavior) — GitHub will retarget this to
mainautomatically when #412 merges.What
Codifies the relay-worker methodology that found the
MALFORMED_FUNCTION_CALLdeath spiral (#406), the workspace/CWD split (#408), and the goal-drift failure (#412) — as a repeatable benchmark. The bench spawns a realpasclaw gatewayagainst a throwawayPASCLAW_HOME, connects as the relay worker, plays a scripted "model", and asserts on what the loop did: the system prompts it built, what landed on disk, how big the request bodies grew. Fully reproducible, zero API tokens, every request envelope inspectable.This measures harness quality;
bench/swemeasures model quality. The point: harness changes land with before/after numbers, not vibes.Pure FPC — no external runtime
One Pascal program (
bench/agentloop/agentloop_bench.pas) built with the repo's own pieces:TProcessspawns the built binary, a worker thread holds the SSE poll with the same TIdHTTP + custom-TStreamframe-parser shape asPasClaw.Cmd.Relay, andPasClaw.JSON+PostJSON/GetJSONURLcover the wire. The shipping binary is what gets exercised. (An earlier revision used Node; rewritten per review discussion — no third runtime inbench/.)Scenarios (16 assertions, all green)
build-siteprovider_calls = 3malformed-recoveryresume-after-capmax_request_body_bytes = 24 KB— the context-growth baseline the future context-diet work gets measured againstRun
make bench-agentloop # compiles the bench + runs it against build/pasclawNeeds a free port 8140. Deliberately not part of
make test(binds a port, spawns a server); run it when touchingPasClaw.Tools.ToolLoop,PasClaw.Stream.Reliability, or the gateway loop paths. FPC-only (TProcess). README documents how to add scenarios.🤖 Generated with Claude Code
https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6