Skip to content

fix(help): commands/help expands enum params instead of collapsing them to "any" — the invisible tool contract - #1946

Merged
joelteply merged 1 commit into
canaryfrom
fix/help-expands-enum-params
Jul 8, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/help-expands-enum-params

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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

…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
joelteply merged commit fdf47a7 into canary Jul 8, 2026
@joelteply
joelteply deleted the fix/help-expands-enum-params branch July 8, 2026 16:58
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant