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

+9
View File
@@ -419,6 +419,15 @@ private:
/* The text frontend, loaded from the container. The sampler's grammars walk `vocab_view_`,
* which references `vocab_` and must not outlive it. */
std::shared_ptr<const Vocab> vocab_;
/* End-of-generation ids the chat format also writes as a call delimiter: a call boundary is
* not a turn's, so the decoder does not stop on them (run_server demotes them). */
std::vector<int32_t> eog_demoted_;
/* End-of-generation as the decoder sees it: the vocabulary's set, minus the demoted ids. */
bool is_eog(int32_t id) const {
if (!vocab_ || !vocab_->is_eog(id)) return false;
for (int32_t d : eog_demoted_) if (d == id) return false;
return true;
}
std::unique_ptr<VocabView> vocab_view_;
/* The container's second vocabulary (rad-convert --tokenizer2), which an image generator that
* declares `aux_tokens` reads its prompt through; null without one. */