Skip to content

config: pasclaw profile diff + bench (finish profile-system plan) - #292

Merged
FMXExpress merged 2 commits into
mainfrom
claude/profile-diff-bench
Jun 16, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/profile-diff-bench

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

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 disagree
  • pasclaw profile bench --task "..." --profiles a,b,c [--runs N] — run the same task against each profile and print a comparison table

profile diff

Applies each profile (with _inherits resolved) against a fresh TConfig in isolation, walks a hand-curated comparable-field list, and prints rows where the two sides disagree. Rows where they agree are suppressed.

$ pasclaw profile diff baseline max-build
field                                         baseline   max-build
vault_tools_enabled                           false      true
web_fetch_enabled                             false      true
vector_search_enabled                         false      true
promptware_enabled                            false      true
condense_reversible                           false      true
tool_output_cap                               0          16384
orient_task_aware                             false      true
stats_collection_enabled                      false      true
checkpoints_enabled                           false      true
checkpoints_keep_last                         0          32
self_improving_skills.self_manage             false      true
self_improving_skills.progressive_disclosure  false      true
self_improving_skills.distiller.enabled       false      true
auto_router.enabled                           false      true
prompt_cache.enabled                          false      true
prompt_cache.ttl                                         1h
(16 differing field(s))

Why a hand-listed field set instead of walking ToJSON: ToJSON is "tidy" — it suppresses fields matching their default, which would make rows ambiguous (no row could mean "same value" OR "both at default"). Walking live TConfig fields post-apply is unambiguous.

profile bench

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, prints a comparison table:

$ pasclaw profile bench --task "implement fizzbuzz in pascal" \
                       --profiles baseline,low-token,max-build \
                       --runs 3

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 in the active profile (max-build / all-on have it; others don't). 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 across these profiles on this task" comparison harness for eyeballing.

Test plan

  • make test-config-profile — new TestDiffMaterial test verifies the invariant diff depends on: baseline vs max-build differ on at least one tracked field; stock vs no-profile match on the tracked subset
  • make clean && make — full FPC 3.2.2 build clean
  • Regression: test-plan-build-mode, test-loop-shaping-defaults, test-config-secret-merge all green
  • Live CLI:
    • profile diff baseline max-build shows 16 differing fields
    • profile diff stock stock shows "(no differences across the comparable field set)"
    • profile diff low-token max-build shows only the 7 fields max-build overrides on top of its _inherits parent
    • profile bench validates arguments (missing --task / --profiles / unknown profile name all bail with ✗ ...)
    • profile bench with no provider configured correctly reports exit=256 (failed) per run with wall time captured

Out of scope (explicit follow-ups)

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

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.

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

Comment on lines +525 to +526
Cmd := PasClawExePath + ' agent --profile ' + ProfileName +
' --quiet --session ' + Run.SessionId + ' -m ' + ShellQuoteSingle(Task);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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.).
@FMXExpress
FMXExpress merged commit 959f2b8 into main Jun 16, 2026
FMXExpress pushed a commit that referenced this pull request Jun 21, 2026
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).
FMXExpress added a commit that referenced this pull request Jun 21, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
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.
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