Skip to content

pickTool: name the chosen tool in the error and match tool names leniently#64

Open
walcz-de wants to merge 1 commit into
mudler:mainfrom
walcz-de:fix/picktool-lenient-match-and-error
Open

pickTool: name the chosen tool in the error and match tool names leniently#64
walcz-de wants to merge 1 commit into
mudler:mainfrom
walcz-de:fix/picktool-lenient-match-and-error

Conversation

@walcz-de

@walcz-de walcz-de commented Jul 7, 2026

Copy link
Copy Markdown

Two small, related robustness fixes in tools.go for 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, pickTool returned a bare chosen tool not found. The name was only xlog.Debug-logged, so operators running at info level saw repeated failures with zero diagnosability. Now: chosen tool %q not found.

2. Tools.Find matched exact-only

Local models routinely emit namespaced / case / separator variants — functions.coach_regeln, Coach_Regeln, tools/coach_regeln — each of which missed and became a hard failure. Find now 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, lenient Find, and the exact-wins-over-lenient guarantee. go test, go vet, gofmt clean.

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

…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant