pickTool: name the chosen tool in the error and match tool names leniently#64
Open
walcz-de wants to merge 1 commit into
Open
pickTool: name the chosen tool in the error and match tool names leniently#64walcz-de wants to merge 1 commit into
walcz-de wants to merge 1 commit into
Conversation
…ently Two small robustness fixes for local-model tool selection, verified against production traffic (repeated hard turn-failures across two Qwen-class models). - pickTool now includes the chosen name in its error: "chosen tool %q not found" instead of a bare "chosen tool not found" (the name was only xlog.Debug-logged, leaving operators at info level with no diagnosability). - Tools.Find gains a lenient fallback that triggers ONLY when no exact match exists: it strips a leading namespace segment (functions./tools//ns::), case-folds, and treats '-' == '_'. Local models routinely emit variants like functions.foo, Foo or foo-bar. Exact matches are unaffected (fast path first). Adds table-driven tests for normalizeToolName, lenient Find, and the exact-wins-over-lenient guarantee. Signed-off-by: stefanwalcz <[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.
Two small, related robustness fixes in
tools.gofor local-model tool selection. We hit these repeatedly in production (agent pool via LocalAI) — 4 hard turn-failures in one evening across two different Qwen-class local models.1. The error hides the chosen name (
pickTool)When the model's chosen tool can't be resolved,
pickToolreturned a barechosen tool not found. The name was onlyxlog.Debug-logged, so operators running at info level saw repeated failures with zero diagnosability. Now:chosen tool %q not found.2.
Tools.Findmatched exact-onlyLocal models routinely emit namespaced / case / separator variants —
functions.coach_regeln,Coach_Regeln,tools/coach_regeln— each of which missed and became a hard failure.Findnow keeps exact match as the fast path and adds a lenient fallback that only triggers on a miss: it strips a leading namespace segment (functions./tools//ns::), case-folds, and treats-≡_. When an exact match exists it is always returned, so existing resolutions are unaffected (covered by a test).Tests
Table-driven tests for
normalizeToolName, lenientFind, and the exact-wins-over-lenient guarantee.go test,go vet,gofmtclean.Related in spirit to #60 / #62: helper/selection steps benefit from diagnosability and tolerance of model quirks. Happy to adjust (e.g. gate the lenient match behind an option) if preferred.
🤖 Generated with Claude Code