fix: correct three bugs in built-in Tools#109
Open
rthrash wants to merge 1 commit into
Open
Conversation
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>
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.
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.
namefilter searches by the wrong argument (get_chunks,get_templates)The
namebranch built its WHERE clause from$arguments['query']instead of$arguments['name'].GetChunks.php→['name' => $arguments['query']]GetTemplates.php→['templatename' => $arguments['query']]Effect: calling
get_chunkswith{"name": "myChunk"}and noqueryfiltered on the unset query value (null) and returned nothing. With both supplied, thenamevalue was ignored. Fix: use$arguments['name'].2.
create_resourceschemarequiredlist didn't match its propertiesCreateResource.phpdeclared"required" => ["name", "description", "content"], but the item properties arepagetitle,template,parent,content. So it marked two non-existent properties as required while omittingtemplate/parent— whichrunToolenforces 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/CreateTemplatewere already correct and are unchanged.)3.
edit_chunkcache refresh was unreachable on successEditChunk.phpreturned the success response before theclear_cacherefresh 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_cacheenabled (default), editing a cached chunk left stale output cached. Fix: inverted the save check so the refresh runs before the success return — mirroringEditTemplate, which already had the correct order and is not changed.Notes
🤖 Generated with Claude Code