][tools]` is the operator's answer to the cost, read * per turn in Chat\Pipeline::toolkitsFor(). * * How narrow that cost is on the default provider, said plainly rather than left to be * discovered: the vendored OllamaProvider maps only `vision` and `toolCalls` out of what * `/api/show` reports. `thinking` is never populated, `reasoning` falls back to `thinking` * and is false with it, the capability list is synthesised from those same two flags, and * fieldSources carries only context metadata. So on Ollama this reads as a description iff * the model declares vision or tools, and a `["completion"]` model and a * `["completion","thinking"]` model are both silent here and both keep tools — a declared * thinking model is not caught, however much "described-but-featureless" suggests it would * be. The practical effect on Ollama is close to the old denylist's outcome set, reached * from data instead of from three names, plus every other vision model; the ticket's own * failure mode (a model that advertises tools and cannot parse them) is the override's to * fix, not this rule's. */ public static function fromDefinition(ModelDefinition $definition): self { $model = self::fromId($definition->id); if (self::declaresCapabilities($definition)) { $model->tools = $definition->supportsToolCalls(); } $model->vision = $model->vision || $definition->supportsVision(); $model->thinking = $model->thinking || $definition->thinking; return $model; } /** * True when the definition carries any capability signal at all, in any of the spellings the * library fills in: the flags, a capability list holding more than plain text, or a stated * provenance for `toolCalls`. False is "the provider told us nothing", which is as close as * ModelDefinition comes to saying so. * * The flag and capability arms are positive claims, so on those alone a `false` could only * be honoured where something else was true — which leaves a provider that genuinely knows a * model has no features unable to say so. The `fieldSources` arm is that sentence: it says * the tool flag was reported rather than defaulted, so a bare `false` from such a provider * is an answer and not a silence. What sets it is a `fieldSources` entry keyed `toolCalls`, * and the plugin's WpAiClientProvider writes one, because CoreClient reads each core model's * support for function declarations one model at a time. No vendored code writes that entry * itself. The five sites that construct a ModelDefinition directly — AnthropicProvider's * discovery loop and its static fallback list, GeminiProvider, LlamaCppProvider, and the * Claude CLI adapter — each write `contextWindow` and `maxTokens` and nothing else, and the * discovery helper fills those same two provenances itself while passing every *other* * `fieldSources` pair in the payload through unchanged: normalizeFieldSources() keeps each * non-empty string => string pair and whitelists no keys, and only `contextWindow` and * `maxTokens` are written over. Three methods call ModelDefinition::fromDiscovery() -- * OllamaProvider::models(), OpenAICompatibleProvider::models() and * OpenAIResponsesProvider::models() -- and the second of those is inherited unchanged by * MistralProvider and XAIProvider, so five vendored providers reach it. Ollama hands the * helper a literal of those two keys, but the OpenAI-compatible path hands it the raw * upstream model entry, so a provider API that answered with a `fieldSources.toolCalls` * key would arrive here as a stated provenance. Across the payloads * the vendored code shapes itself the key is unambiguous, and a vendored model reads as * silent exactly as before. */ private static function declaresCapabilities(ModelDefinition $definition): bool { if ($definition->supportsToolCalls() || $definition->supportsVision() || $definition->thinking || $definition->reasoning) { return true; } if (array_key_exists('toolCalls', $definition->fieldSources)) { return true; } return array_filter($definition->capabilities, static fn(ModelCapability $c): bool => $c !== ModelCapability::Text) !== []; } /** @param array $a the shape toArray() produces (the transient payload) */ public static function fromArray(array $a): self { $id = (string) ($a['id'] ?? ''); return new self( $id, (string) ($a['label'] ?? $id), (bool) ($a['tools'] ?? false), (bool) ($a['vision'] ?? false), (bool) ($a['thinking'] ?? false), ); } /** @return array{id: string, label: string, tools: bool, vision: bool, thinking: bool} */ public function toArray(): array { return ['id' => $this->id, 'label' => $this->label, 'tools' => $this->tools, 'vision' => $this->vision, 'thinking' => $this->thinking]; } }