chat: read a function name that ends at whitespace (Ling 3.0)

Ling-3.0-flash's template writes a call as the opener, the function name, a
newline, and only then the argument tags:

    <tool_call>read
    <arg_key>path</arg_key>
    <arg_value>/a</arg_value>
    </tool_call>

The differential analysis names the function between the opener and the first
argument tag, so its end is the bare newline and name_suffix comes out as
whitespace alone. chat_format_check refused that, so every request carrying
tools answered 501 with "this model's tool calls cannot be read back:
name_suffix must end the function name with something besides whitespace" --
the whole tool-calling surface, for every Ling-3.0 checkpoint.

A suffix with no core of its own is the suffixless ending written out: the
name stops at the whitespace. The reader now takes it that way (name_open keys
on the trimmed core, so the name runs to the first arg_prefix or call_end,
whitespace trimmed), while the grammar still writes the template's newline.
The object family has no such terminator -- its brace ends the name -- and
keeps the refusal, as does the wrapped format whose bare name_prefix would
otherwise read as a call.

Adds the real template as a fixture and a regression test that derives the
format, builds the grammar, and reads a two-call reply built from the derived
fields; a second test pins the object family's refusal.
This commit is contained in:
Victor Ionescu authored and StillDeadcode committed 2026-11-16 18:03:16 +01:00
1 parent bd3fa646bc
commit b988378e70
8 files changed
+275 -21

No files matched your search

+5 -3
View File
@@ -746,8 +746,8 @@ struct ReplyFormat::Impl {
/* Object family. `object`: a call's arguments are one object. `ns_object`: the object's own
* `{` ends the name (name_suffix empty), and ns_core is "{". */
bool object = false, ns_object = false;
/* Tagged family, name_suffix empty: a call's name ends where arg_prefix or end_core begins,
* and that tag is the first of the call's body. */
/* Tagged family, no core in name_suffix (empty, or whitespace alone): a call's name ends
* where arg_prefix or end_core begins, and that tag is the first of the call's body. */
bool name_open = false;
/* Where a key or value may begin, besides the object's punctuation: the dialect string's
* opener, and the call's close and end (written there by a reply that leaves its object
@@ -810,7 +810,9 @@ int ReplyFormat::compile(const ChatFormat& f, std::shared_ptr<const ReplyFormat>
m.name_end = f.arg_name_suffix + f.arg_value_prefix;
if (f.typed_tags()) m.name_end_json = f.arg_name_suffix + f.arg_json_value_prefix;
m.object = f.has_tools() && f.object_args();
m.name_open = f.has_tools() && !m.object && f.name_suffix.empty();
/* A suffix with no core of its own ends the name at whitespace, and the name then runs to
* the first argument tag or the call's end, as it does without a suffix (Ling 3.0). */
m.name_open = f.has_tools() && !m.object && m.ns_core.empty();
if (m.object && f.name_suffix.empty()) {
m.ns_object = true;
m.ns_core = "{";