Skip to content

bench: deterministic agent-loop harness benchmark (bench/agentloop, pure FPC) - #413

Merged
FMXExpress merged 1 commit into
claude/progress-ledgerfrom
claude/agent-bench
Jul 2, 2026
Merged

FMXExpress merged 1 commit into
claude/progress-ledgerfrom
claude/agent-bench

Conversation

@FMXExpress

@FMXExpress FMXExpress commented Jul 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #412 (its scenarios assert the progress-ledger behavior) — GitHub will retarget this to main automatically when #412 merges.

What

Codifies the relay-worker methodology that found the MALFORMED_FUNCTION_CALL death spiral (#406), the workspace/CWD split (#408), and the goal-drift failure (#412) — as a repeatable benchmark. The bench spawns a real pasclaw 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 request envelope inspectable.

This measures harness quality; bench/swe measures 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: TProcess spawns the built binary, a 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. (An earlier revision used Node; rewritten per review discussion — no third runtime in bench/.)

Scenarios (16 assertions, all green)

scenario asserts metric
build-site ledger folds into iteration 2's system prompt (goal + written file + todo checklist); iteration 1 stays pristine (prefix-cache); deliverable exists on disk provider_calls = 3
malformed-recovery Gemini-shaped malformed empty turn auto-retried with the corrective nudge naming a registered tool; turn still delivers recovered in 1 retry
resume-after-cap 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 "continue" max_request_body_bytes = 24 KB — the context-growth baseline the future context-diet work gets measured against

Run

make bench-agentloop     # compiles the bench + runs it against build/pasclaw

Needs a free port 8140. Deliberately not part of make test (binds a port, spawns a server); run it when touching PasClaw.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

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

Comment thread bench/agentloop/run.js Outdated
}));

const gw = spawn(BIN, ['gateway'], {
env: Object.assign({}, process.env, { PASCLAW_HOME: homeDir, NO_COLOR: '1' }),

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 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 👍 / 👎.

@FMXExpress
FMXExpress force-pushed the claude/agent-bench branch from cd65da2 to 35bb26d Compare July 2, 2026 06:16
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
@FMXExpress
FMXExpress force-pushed the claude/agent-bench branch from 35bb26d to c7e4fb3 Compare July 2, 2026 06:21
@FMXExpress FMXExpress changed the title bench: deterministic agent-loop harness benchmark (bench/agentloop) bench: deterministic agent-loop harness benchmark (bench/agentloop, pure FPC) Jul 2, 2026
@FMXExpress
FMXExpress merged commit 8e78a79 into claude/progress-ledger Jul 2, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
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
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