You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tool-call parse validates names and arguments only for JSON-schema tools #1986
bugSomething isn't workingpriority:P3Watch or strategic work blocked by upstream/runtime/design dependenciesstructured-outputJSON schema, grammar, and constrained output work
Resolved by the documented-and-pinned policy in #2013. JSON-schema tool declarations receive parse-time schema validation; ToolParam-only parsing retains its existing behavior, with grammars and the ChatSession tool loop keeping their separate checks. This does not add stricter ToolParam parse validation. Included in 0.19.11 preparation.
Original report
Summary
ChatTemplateEngine checks tool names and arguments only when one of the tools uses a JSON schema (tools.any(toolUsesJsonSchema) in chat_template_engine.dart). Tools declared with ToolParam skip the check, so a parse accepts:
drop_tables({"city":"Paris"}), an undeclared tool name, as a call;
get_weather({"city":7}), a wrong argument type, as a call.
The same tools built with ToolDefinition.fromJsonSchema throw The model returned an undeclared tool call. and Tool arguments do not match the input schema.
Required and auto grammars constrain names and types, and ChatSession's tool loop rejects unknown names, so only output that bypassed the grammar reaches this path. This is a consistency gap, not an exploit path.
Repro: parse LFM2 output with ChatTemplateEngine.parse(ChatFormat.lfm2.index, out, tools: [toolParamTool]) on main 768feb72. Found in the #1984 audit (llamadart-evidence/pr-1984/audit/).
Decision (maintainer, 2026-11-14): document and pin for 0.19.11. Behavior stays as it is. The current split is deliberate (#1086), and making ToolParam tools strict would break the documented tool loop, where the model gets an error for an unknown tool name and can recover. It would also break Llama 3 builtin tools and 21 pinned tests. Upstream checks names but not argument types.
The fix PR will:
document in ChatTemplateEngine.parse and the tool-calling guide that only schema tools are validated, and that by-hand callers should check call.name;
add tests that pin the split.
Making name checks strict is still possible as a separate breaking change in a minor release.
2026-11-15 disposition: #2013, merged 1b5366402432c189c98409ea3c06fd876baca939, implements the maintainer's document-and-pin decision above. API docs/guide/skill and regression fixtures describe schema-tool-only final validation; ToolParam behavior intentionally stays unchanged. Main/local contain this source delivery, public0.19.10 does not. This is an accepted/documented compatibility policy, NOT a new strict-validation behavior fix or security repair. Any stricter ToolParam admission remains a separate breaking-change decision; no owner artifact work or issue-state change by this scan.
bugSomething isn't workingpriority:P3Watch or strategic work blocked by upstream/runtime/design dependenciesstructured-outputJSON schema, grammar, and constrained output work
Activity
leehack commentedon Nov 13, 2026
Triage: bug, P3, tool calling. Only reachable when output bypasses the grammar. Not scheduled; candidate for the next patch tracker.
leehack commentedon Nov 14, 2026
Decision (maintainer, 2026-11-14): document and pin for 0.19.11. Behavior stays as it is. The current split is deliberate (#1086), and making
ToolParamtools strict would break the documented tool loop, where the model gets an error for an unknown tool name and can recover. It would also break Llama 3 builtin tools and 21 pinned tests. Upstream checks names but not argument types.The fix PR will:
ChatTemplateEngine.parseand the tool-calling guide that only schema tools are validated, and that by-hand callers should checkcall.name;Making name checks strict is still possible as a separate breaking change in a minor release.
Keep the system message when adding the generic tool instruction; doc…
leehack commentedon Nov 15, 2026
2026-11-15 disposition: #2013, merged
1b5366402432c189c98409ea3c06fd876baca939, implements the maintainer's document-and-pin decision above. API docs/guide/skill and regression fixtures describe schema-tool-only final validation; ToolParam behavior intentionally stays unchanged. Main/local contain this source delivery, public0.19.10 does not. This is an accepted/documented compatibility policy, NOT a new strict-validation behavior fix or security repair. Any stricter ToolParam admission remains a separate breaking-change decision; no owner artifact work or issue-state change by this scan.