Repository navigation
Resolve a qualified tool call from any of its segments - #1478
Merged
Merged
Conversation
A chat template that renders bare tool names as namespace patterns tells the model to address `read.*`, so the model invents a second segment -- usually by borrowing a parameter name, giving `read.filePath`. Tool name alignment only tried the last segment, which handles `functions.read` but not this shape, so the call was rejected as an unavailable tool. Try every segment and rewrite only when the offered tools agree on exactly one target, deduplicated so `glob.glob` resolves while `read.write` stays untouched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0190e2eb-abe4-451f-b36d-44a035a99b7e
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1478 +/- ##
==========================================
+ Coverage 82.10% 82.64% +0.54%
==========================================
Files 12 12
Lines 5471 5475 +4
Branches 5471 5475 +4
==========================================
+ Hits 4492 4525 +33
+ Misses 780 757 -23
+ Partials 199 193 -6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
The symptom
Every OpenCode session opened with a failed tool call:
The agent recovered on the retry, so the session worked, but every task paid for a wasted round trip.
The root cause is in the chat template
chat_template.jinjainfers a namespace withfn.name.split('.')[0]and renders it unconditionally as a pattern. OpenCode offers bare tool names, so the system prompt became:The model was told it must address
read.*. It supplied a second segment by borrowing something at hand -- typically a parameter name.read.filePathis the model doing exactly what the prompt asked.That template lives in the model package, and it has been fixed there. This PR is the server-side half.
The change
align_tool_callsalready rewrote qualified names, but only tried the last segment. That handlesfunctions.read; it cannot handleread.filePath, where the tool is the first segment.Now every segment is tried, and the rewrite happens only when the offered tools agree on exactly one target. The candidate set is deduplicated so that:
glob.globresolves toglob(both segments name the same tool),read.writeis left alone (two different offered tools -- no way to tell which was meant).Verification
cargo test -p onnx-genai-server --lib-- 239 passed, 0 failed.tool_name_alignment_testsis 7/7 with two new cases covering the shapes above.CI runners are down; validated locally.