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:
| Test | Result |
|---|---|
| It picks the first branch | the right branch was first |
| Reverse the branch order | the same answer |
| Drop the discriminator | the same answer |
| Offer only the TV branches | still the wrong branch |
| Enforce the schema in the prompt instead | invalid 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:
| Schema | Right | Median | p90 |
|---|---|---|---|
| Union, as it was | 0% | 5.5 s | |
| One flat object, the type as a field | 84% | 5.5 s | 6.6 s |
| Two calls: the type, then that branch alone | 92% | 7.3 s | 7.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.