makepad/libs/asset/chat/tests/tool_call_spellings.rs
Admin 2d23dba736 libs/asset: the store runs on our own SQLite, and the importers learn the whole map contract
The asset store now uses libs/sqlite_query as its ONLY engine — not a feature
flag, not a fallback. That closes the Windows gap (the embedded store starts
there now, and a SHARED->EXCLUSIVE upgrade is handled rather than assumed
free) and takes the C dependency out of the build everywhere else.

Around it:

  - store: a garbage collector, catalogued content that is referenced in place
    instead of copied, the `vjeffect` kind, and host/chat routes that keep up
    with the chat wire below.
  - importer: the unified map contract reaches quake2, quake3, doom and duke —
    world placement, nav, welding, prelit maps and glTF node handling shared
    rather than reimplemented per game. Music import, billboards and stateful
    props move to the data crate so readers stop linking the importer.
  - ai: the serving side of multi-lane chat — per-lane conversations, honest
    progress and acceptance reporting, penalties and a watchdog, context as a
    per-box number that compacts instead of erupting, a realtime session mode,
    and inpaint/flux2 backends. `chat_bench` measures the rate the way the
    client meter computes it.
  - client / chat / chat_ui: a publication can NAME a file instead of carrying
    it; the wire says whether a turn is warm and whether it is thinking, so a
    client stops guessing; transcript and feed widgets render history the way
    the model wrote it. `SessionConfig::catalog_runtime` lets a host size the
    catalog runtime's lanes itself — a browsing UI puts every listing, every
    per-tile resolve and every thumbnail blob through that one runtime and
    wants a wider fast lane than the shared default, while media lanes keep
    it (a few big transfers, not a thousand small ones).
  - widgets: the shared asset widgets — one video view (knobbed seek,
    transport, bracket trim, rail playback) used everywhere, plus thumb,
    preview, scene view, walk-world and the lyric reader.
2026-08-23 01:34:34 +02:00

53 lines
2.4 KiB
Rust

//! Every tool-call spelling a served model has actually produced here.
//!
//! The extractor is the one place that decides whether a turn does work or
//! dies. Each line below cost a real conversation before it parsed: the
//! `tool_name` variant left the model retrying the same block forever while
//! the user watched an empty reply, and the namespaced `world` + `action`
//! shape got a bare "unknown tool" that convinced it it had no tools at all.
use makepad_asset_chat::toolcall::{extract, Extract};
#[test]
fn the_observed_tool_call_spellings_all_parse() {
let bodies = [
// The generation surface's own marker.
r#"<<tool>>{"name":"world.get_source","args":{}}"#,
// Qwen on the fleet box, verbatim.
"<tool_call>\n{\"tool_name\": \"world.get_source\", \"arguments\": {}}\n</tool_call>",
"<tool_call>\n{\"function\": \"world.get_source\", \"arguments\": {}}\n</tool_call>",
"<tool_call>\n{\"name\": \"world.get_source\", \"parameters\": {}}\n</tool_call>",
// The trained template the agentic surface teaches.
"<tool_call>\n<function=world.get_source>\n</function>\n</tool_call>",
// Same, with the args as a bare JSON body.
"<tool_call>\n<function=world.get_source>\n{}\n</function>\n</tool_call>",
];
for body in bodies {
match extract(body) {
Extract::Call { name, .. } => assert_eq!(name, "world.get_source", "{body}"),
other => panic!("{body} did not parse: {other:?}"),
}
}
}
/// The arguments survive the spelling, not just the name.
#[test]
fn arguments_arrive_whatever_the_key_is_called() {
for body in [
"<tool_call>\n{\"tool_name\": \"world.spawn\", \"arguments\": {\"model\": \"kenney/x\"}}\n</tool_call>",
"<tool_call>\n{\"name\": \"world.spawn\", \"parameters\": {\"model\": \"kenney/x\"}}\n</tool_call>",
"<tool_call>\n<function=world.spawn>\n<parameter=model>\nkenney/x\n</parameter>\n</function>\n</tool_call>",
] {
match extract(body) {
Extract::Call { name, args, .. } => {
assert_eq!(name, "world.spawn", "{body}");
assert_eq!(
args.get("model").and_then(makepad_asset_client::json::Value::as_str),
Some("kenney/x"),
"{body}"
);
}
other => panic!("{body} did not parse: {other:?}"),
}
}
}