Step 5 of 13Fixed

The schema's shape, not the model

Through Ollama, a schema that is a union of command types scored 0 of 25, though the model named the right intent every time. One flat object scored 84%.

Union schema, Qwen3.5 4B
0 / 25
Flat schema
84%
5.5 s median
Two calls: classify, then fill
92%
7.3 s median

Problem

The command schema is a union: one branch per command type. Through Ollama, both candidate models answered every test command with a valid command of the wrong type. "Turn on the TV" came back as a confirmation whose reference was tv.power, the right intent, in the wrong command. Every earlier test had run against vLLM, so nothing had caught it.

Result

Five explanations were tested and ruled out:

TestResult
It picks the first branchthe right branch was first
Reverse the branch orderthe same answer
Drop the discriminatorthe same answer
Offer only the TV branchesstill the wrong branch
Enforce the schema in the prompt insteadinvalid JSON

A schema with the single right branch got the right answer. The trigger was a union of several branches. Measured on all 25 commands:

SchemaRightMedianp90
Union, as it was0%5.5 s
One flat object, the type as a field84%5.5 s6.6 s
Two calls: the type, then that branch alone92%7.3 s7.7 s

Decision

Fixed with the flat schema, at one call per command. A second call with the single matching branch runs only when the first answer fails validation. On eleven music commands that took the node from 5 right to 9; the two left are the model asking a fair question about which device was meant. A field the model kept filling with junk is no longer shown to it at all.