diff --git a/common/chat-auto-parser-generator.cpp b/common/chat-auto-parser-generator.cpp
index 104fe47..b682578 100644
--- a/common/chat-auto-parser-generator.cpp
+++ b/common/chat-auto-parser-generator.cpp
@@ -511,6 +511,41 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
any_arg |= opt;
}
+ /* RADIANCE: AN ARGUMENT THE SCHEMA DOES NOT DECLARE MUST NOT TAKE THE REPLY DOWN WITH IT.
+ *
+ * Every arm above matches its parameter name as a LITERAL, so a name outside the schema
+ * matches nothing, the call matches nothing, and p.end() makes that the whole reply --
+ * which comes back to the caller as prose with the XML in it. Observed on MiniCPM5-2B
+ * calling a `read` tool whose only parameter is `path`:
+ *
+ * read
+ *
+ * one hallucinated argument name, and the turn was lost. The model then reads its own
+ * call echoed back as text, concludes the tool is broken, and rewrites it.
+ *
+ * Tried LAST, so every declared name still binds to its own schema-checked arm and
+ * nothing that parses today parses differently. The value is taken the way a string
+ * argument takes it -- the text up to the value suffix, which is what delimits it in
+ * this format. What is given up is knowing that the argument was undeclared; the TOOL
+ * gets to say so, which it can do properly, and which a reply that never arrives cannot.
+ * Same argument as the non-JSON container fallback above. */
+ /* WHAT ENDS THE NAME IS NOT ALWAYS `name_suffix`. This format decomposes
+ * `v` as prefix `` -- so a generic name runs until value_prefix here, and the first
+ * cut of this arm guarded on `!name_suffix.empty()` and silently never built itself. */
+ const std::string & name_end =
+ arguments.name_suffix.empty() ? arguments.value_prefix : arguments.name_suffix;
+ if (!arguments.name_prefix.empty() && !name_end.empty() &&
+ !arguments.value_suffix.empty()) {
+ auto unknown_arg =
+ p.tool_arg(p.tool_arg_open(arguments.name_prefix +
+ p.tool_arg_name(p.until(name_end)) +
+ arguments.name_suffix) +
+ arguments.value_prefix + p.tool_arg_string_value(until_suffix) +
+ p.tool_arg_close(p.literal(arguments.value_suffix)));
+ any_arg |= p.rule("tool-" + name + "-arg-undeclared", unknown_arg);
+ }
+
common_peg_parser args_seq = p.eps();
if (!required_parsers.empty()) {
args_seq = any_arg + p.repeat(p.space() + any_arg, 0, -1);