Skip to content

Tool-call parse validates names and arguments only for JSON-schema tools #1986

Closed

Description

@leehack

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/).

Activity

  1. leehack commented on Nov 13, 2026

    @leehack
    OwnerAuthor

    Triage: bug, P3, tool calling. Only reachable when output bypasses the grammar. Not scheduled; candidate for the next patch tracker.

  2. added
    bug
    structured-output
    priority:P3
    on Nov 13, 2026
  3. leehack commented on Nov 14, 2026

    @leehack
    OwnerAuthor

    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.

  4. leehack commented on Nov 15, 2026

    @leehack
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P3structured-output

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions