Repository navigation
fix(help): commands/help expands enum params instead of collapsing them to "any" — the invisible tool contract - #1946
Merged
Conversation
…em to "any" — the invisible tool contract
Found firsthand by taking the SWE-bench test through `cu` myself (a teammate in the exam): `code/edit` was
effectively uncallable. Its `edit_mode` is a serde-tagged enum, but `commands/help` read only a param's scalar
`"type"` — an enum has none — so it printed `edit_mode (any, required)` with an `<any>` placeholder. A model
literally could not tell what to pass; a local persona would flail and produce 0 edits (exactly the "she acted
but changed nothing" symptom on real repos). The full variant schema was sitting right there in the param's
`oneOf`; the renderer just never walked it.
Fix: `render_ai_help` now resolves `$ref`/`allOf` against the schema's `definitions`/`$defs` and expands enums:
- internally-tagged (`#[serde(tag = "type")]`, like EditMode) → `search_replace{search, replace, all} |
line_range{...} | ...`, with a concrete FLAT `{"type":"search_replace", ...}` example (the shape that works).
- externally-tagged and plain unit enums handled too; graceful `any` fallback on any unknown shape (no regression).
Live-verified: code/edit help now lists all four variants + fields + a copy-pasteable example. This lifts EVERY
complex-param tool for EVERY model (persona, cloud, grid) at once — the "make the tools honest so it can run on
its own" repair. [[px-persona-experience-tools-as-good-ux]] [[adaptive-tool-surface-meets-you-in-the-middle]]
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Jul 8, 2026
…of looping the search forever (#1949) Glass-boxed live: a local 14B on a SWE task fired `code/search(pattern="**/*.py")` twelve times in a row and never advanced to read/edit. Root cause: it conflates code/search (grep file CONTENTS — `pattern` is the search TERM, `file_glob` filters files) with code/glob (find files BY name). A glob in `pattern` greps contents for the literal text "**/*.py" → 0 matches → the model retries the identical call and stalls. This is the same class of confusing-tool-contract bug as the code/edit `edit_mode`-as-"any" fix (#1946): a 14B can't infer the two-param split, so the tool must meet it halfway. Fix: when `pattern` looks like a file glob (`*`/`?` + a path-glob shape, conservative so a real content regex like `foo.*bar` / `fn .*Params` is NOT misclassified — unit-tested) and no `file_glob` was given, do what it MEANT — run the glob and return the matching FILE paths as results, plus a one-line note on the correct shape. One call now makes progress instead of looping. Strictly-better for the detected case (which otherwise always returns 0); the normal grep path (real term, or file_glob set) is untouched, so no regression is possible. Behavior-validation (persona reads→edits) is PENDING a stable coder lane: this session's heavy core-reboot churn left the local llama-server 500ing "Compute error" on restart, which blocks all evals (separate infra issue, being left to stabilize). Unit test green; logic is opt-in on a currently-useless case. [[px-persona-experience-tools-as-good-ux]] Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found firsthand by taking the SWE-bench test through
cumyself (a teammate in the exam):code/editwaseffectively uncallable. Its
edit_modeis a serde-tagged enum, butcommands/helpread only a param's scalar"type"— an enum has none — so it printededit_mode (any, required)with an<any>placeholder. A modelliterally could not tell what to pass; a local persona would flail and produce 0 edits (exactly the "she acted
but changed nothing" symptom on real repos). The full variant schema was sitting right there in the param's
oneOf; the renderer just never walked it.Fix:
render_ai_helpnow resolves$ref/allOfagainst the schema'sdefinitions/$defsand expands enums:#[serde(tag = "type")], like EditMode) →search_replace{search, replace, all} | line_range{...} | ..., with a concrete FLAT{"type":"search_replace", ...}example (the shape that works).anyfallback on any unknown shape (no regression).Live-verified: code/edit help now lists all four variants + fields + a copy-pasteable example. This lifts EVERY
complex-param tool for EVERY model (persona, cloud, grid) at once — the "make the tools honest so it can run on
its own" repair. [[px-persona-experience-tools-as-good-ux]] [[adaptive-tool-surface-meets-you-in-the-middle]]
Co-Authored-By: Claude Opus 4.8 [email protected]
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo