← All models Β· Llama 3.2 3B

use case Β· practical Β· agentic

Practical: a local tool router

The building block under every "agent": given a plain-English request and a menu of tools, the model must pick one tool and fill in its arguments as strict JSON β€” the step your code then dispatches to a real function. It leans on instruction-following and schema-adherence, exactly where the 3B pulls ahead of the 1B. WebLLM's JSON mode guarantees the output parses; the whole decision runs on your GPU with no server.

Available tools (the model must choose exactly one):

The function call streams here.
A valid call renders as tool β†’ args here (what your app would run).

How this stays reliable

We describe the tool schemas in the system prompt and pass response_format: { type: "json_object" } to WebLLM, which constrains decoding so the tokens can only form valid JSON β€” no "sometimes it wraps the call in prose" failure. The model returns { "tool": "…", "arguments": { … } }; the page parses it, checks the tool name against the known list, and shows the dispatch your code would perform. A wrong or unknown tool is flagged rather than hidden β€” this is a router you could actually wire to real functions.

← Basics Β· Llama 3.2 3B Β· Next: Wild β†’