Skip to content

fix: correct three bugs in built-in Tools#109

Open
rthrash wants to merge 1 commit into
mainfrom
fix/built-in-tool-bugs
Open

fix: correct three bugs in built-in Tools#109
rthrash wants to merge 1 commit into
mainfrom
fix/built-in-tool-bugs

Conversation

@rthrash
Copy link
Copy Markdown
Member

@rthrash rthrash commented Jun 5, 2026

What

Fixes three bugs in modAI's built-in Tool classes, discovered while documenting them (see #107). Verified by reading the code; each is a small, targeted change.

Bugs fixed

1. name filter searches by the wrong argument (get_chunks, get_templates)

The name branch built its WHERE clause from $arguments['query'] instead of $arguments['name'].

  • GetChunks.php['name' => $arguments['query']]
  • GetTemplates.php['templatename' => $arguments['query']]

Effect: calling get_chunks with {"name": "myChunk"} and no query filtered on the unset query value (null) and returned nothing. With both supplied, the name value was ignored. Fix: use $arguments['name'].

2. create_resource schema required list didn't match its properties

CreateResource.php declared "required" => ["name", "description", "content"], but the item properties are pagetitle, template, parent, content. So it marked two non-existent properties as required while omitting template/parent — which runTool enforces at runtime.

Effect: the advertised schema let the model omit template/parent, then the tool rejected the call with a runtime "required" error. Fix: "required" => ["pagetitle", "template", "parent", "content"]. (CreateChunk/CreateTemplate were already correct and are unchanged.)

3. edit_chunk cache refresh was unreachable on success

EditChunk.php returned the success response before the clear_cache refresh block, so the cache was never refreshed after a successful chunk edit (the refresh was only reachable on the failed-save path).

Effect: with clear_cache enabled (default), editing a cached chunk left stale output cached. Fix: inverted the save check so the refresh runs before the success return — mirroring EditTemplate, which already had the correct order and is not changed.

Notes

🤖 Generated with Claude Code

Found while documenting the built-in tools.

- GetChunks / GetTemplates: the `name` filter built its WHERE clause from
  `$arguments['query']` instead of `$arguments['name']`, so filtering by
  exact name searched by the (often empty) query value and returned
  nothing.

- CreateResource: the JSON-Schema `required` list was ["name",
  "description", "content"] — properties that don't exist on the item —
  while omitting `template` and `parent`, which runTool enforces at
  runtime. Corrected to ["pagetitle", "template", "parent", "content"]
  so the advertised schema matches what the tool actually requires.

- EditChunk: the success branch returned before the clear_cache refresh,
  so the cache was never refreshed after a successful chunk edit (the
  refresh was only reachable on the failed-save path). Inverted the save
  check so the refresh runs before the success return, matching
  EditTemplate (which was already correct and is unchanged).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rthrash rthrash requested a review from theboxer June 5, 2026 22:19
@rthrash rthrash added the bug Something isn't working label Jun 5, 2026
@rthrash rthrash requested a review from matdave June 5, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant