Skip to content

tools: schema trim + error-message audit (C4 + B3)#416

Merged
FMXExpress merged 3 commits into
mainfrom
claude/schema-trim-errors
Jul 2, 2026
Merged

tools: schema trim + error-message audit (C4 + B3)#416
FMXExpress merged 3 commits into
mainfrom
claude/schema-trim-errors

Conversation

@FMXExpress

@FMXExpress FMXExpress commented Jul 2, 2026

Copy link
Copy Markdown
Owner

The last two items of the effectiveness queue, based on merged main (#415). Three commits: C4, B3, and the bench scenario that proves B3 end-to-end.

C5 (promptware scoping) is deliberately dropped: web_fetch save_to / shell curl > file followed by read_file would launder fetched content past any trust-local-reads exemption, so the injection scan keeps covering all tool output.

Harness-verified — same bench binary, before = merged main (#415), after = this branch

metric before after
build-site.first_request_bytes (fixed cost every call pays) 18,726 17,780 (~240 tokens/request)
realtask.total_request_bytes (original pasclaw.dev prompt, 11 calls) 296,859 286,453
error-guidance scenario (typo'd tool + wrong-dir read through real dispatch) 2 FAIL — bare unknown tool: X / no such file: Y PASS — "did you mean: read_file", "Did you mean: pages/sub-dir-page.html"
realtask deliverable (index.html) byte-identical either way — same output, cheaper production

C4 — trim always-sent schemas; formats teach on the error path

  • edit_file: the full hashline patch grammar leaves the description — PreflightToolCall + the PasClaw.Hashline validators reply with the exact syntax the moment a patch is malformed, the only time the model needs it.
  • grep_files: skip-list enumeration collapses; gains read_file start_line/end_line and find_files cross-references.
  • apply_patch: keeps the envelope shape, drops the tutorial.
  • execute_code: keeps the pasclaw __tool callback contract, drops the fan-out story.

B3 — every tool error states the next move

  • no such file (read_file/edit_file) → bounded walk (3 hits, 400 dirs, error-path only) appends "Did you mean: pages/sub-dir-page.html?" — right name, wrong directory is the dominant real case. Nothing similar → a concrete find_files glob.
  • unknown tool → up to 3 similar registered names (containment or shared 4-char prefix; hidden aliases excluded): "unknown tool: read_files — did you mean: read_file?"
  • apply_patch context-not-found → context must match the current file byte-exactly; re-read the region with read_file start_line/end_line first.
  • shell denylist refusals → name the rewrite and the dedicated-tool alternatives instead of just refusing.

Tests

fs_tool_naming_tests gains the B3 section (nearest-file, find_files fallback, similar-tool, shell-denial remediation, apply_patch re-read hint); new error-guidance bench scenario fails on main and passes here. Full bench (7 scenarios) + regression sweep green on the rebased branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6

claude added 3 commits July 2, 2026 07:26
Tool descriptions are fixed per-request overhead -- every byte rides on
EVERY provider call. The fattest ones were tutorials for formats the
error path already teaches:

  * edit_file: the full hashline patch grammar (anchors, payload
    markers, header hash) moves out of the description -- the format-
    error messages (PreflightToolCall + the PasClaw.Hashline validators)
    reply with the exact syntax the moment a patch is malformed, which
    is the only time the model needs it.
  * grep_files: the skip-list enumeration collapses to "skips VCS/build/
    deps dirs and binaries"; gains the read_file start_line/end_line and
    find_files cross-references (cheaper than the prose they replace and
    they steer the next call).
  * apply_patch: keeps the envelope shape, drops the tutorial; format
    errors reply with the expected syntax.
  * execute_code: keeps the callback contract, drops the fan-out story.

Measured (bench/agentloop, new build-site.first_request_bytes metric --
the fixed cost every single call pays):
    before: 18720   after: 17774   (~240 tokens saved per request)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
Errors-as-documentation already worked here (the write_file truncation
error, the malformed-call nudge); this pass extends it to the errors a
coding agent actually loops on:

  * no such file (read_file / edit_file): a bounded walk from the
    working directory (3 hits, 400 dirs, error-path only) appends
    "Did you mean: sub/deep.pas?" -- the dominant real case is right
    name, wrong directory. Nothing similar -> points at find_files
    with a concrete glob.
  * unknown tool: TToolRegistry.RunTool appends up to 3 similar
    registered names (containment or shared 4-char prefix; hidden
    aliases excluded via Names) -- "unknown tool: read_files -- did
    you mean: read_file?".
  * apply_patch context-not-found: tells the model the context must
    match the CURRENT file byte-exactly and to re-read the region with
    read_file start_line/end_line before rebuilding the hunk.
  * shell denylist refusals: name the rewrite ("without <token>") and
    the dedicated-tool alternatives instead of just refusing.

Units: nearest-file suggestion (wrong dir), find_files fallback,
similar-tool suggestion, shell-denial remediation, apply_patch re-read
hint. Full bench + regression sweep green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
Drives a typo'd tool name (read_files) and a wrong-directory read
through the real dispatch path and asserts the errors carry the next
move ("did you mean: read_file", "Did you mean: pages/sub-dir-page.html").
On the pre-B3 binary both assertions fail (bare "unknown tool: X" /
"no such file: Y"), so the audit is now harness-verified, not just
unit-tested.

Fresh before/after against merged main (#415), same bench binary:
    first_request_bytes:      18726 -> 17780   (C4, every request)
    realtask total bytes:    296859 -> 286453  (trim x 11 requests)
    error-guidance:           2 FAIL -> PASS   (B3)
    realtask deliverable:  byte-identical index.html either way

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
@FMXExpress FMXExpress merged commit 947999d into main Jul 2, 2026
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