ADR 332 · Accepted

The document probe selects the model of a criteria-mode configuration

Context

DocumentAnalysisService::analyzeDocument() asks the provider a call will run on whether it reads PDF documents natively, and only then sends the whole document in one chat call. ADR-331 made that probe build the adapter from the model record of the configuration the call resolves to, as chat() does, and recorded one known limit: a configuration in criteria mode (ADR-066) names no model of its own. getLlmModel() is null, so the probe fell through to the keyed provider registry with no key, and KeyedProviderRegistry::getProvider() threw No provider specified and no default provider configured. A configuration switched from fixed to criteria mode is the other case: the backend form only hides the model field, so getLlmModel() still returns the model it had, and the probe asked that model while chat() selects by the criteria. Only a configuration a site names (ADR-244) reaches the probe in criteria mode; the resolver returns an installation default only when it has a model.

chat() handles such a configuration: inside the pipeline, ConfigurationCallPlanner::resolveModel() selects its model through ModelSelectionServiceInterface::resolveModelForCall() for the operation Chat. None of the service's dependencies offers that selection. LlmServiceManagerInterface has only entry points that also send, ConfigurationResolver returns configurations, not models, and ProviderAdapterRegistryInterface needs a model that is already chosen. DocumentAnalysisService is an @api final class, so a new dependency changes its frozen constructor. The product owner decided on 2026-11-29 to add one.

Decision

1. DocumentAnalysisService takes an optional trailing ?ModelSelectionServiceInterface $modelSelection = null constructor argument. The container autowires it. When the configuration the probe resolves is in criteria mode or names no model, and both this argument and the adapter registry of ADR-331 are present, the probe calls resolveModelForCall($configuration, ProviderOperation::Chat) and builds the adapter of the selected model. The selection mode decides, not the relation: a model relation a criteria-mode configuration retained from fixed mode is ignored, as chat() ignores it. A fixed-mode configuration with its own model is not selected again, and a pinned provider is still looked up in the keyed registry. A selection that fails throws: criteria that select no model fail with Configuration "…" has no model assigned, the message the send raises; a fixed-mode configuration whose model record is gone lands in the same branch and fails the same way, and a selection that refuses the operation throws its own UnsupportedFeatureException.

2. The operation is Chat. The native path sends through the chat entry points, and chatWithConfiguration() resolves with ProviderOperation::Chat. Criteria narrow the candidates by the capability the operation needs (ADR-138), so a different operation could select a model the send would not use.

3. The probe's selection is handed to the send. When the probe selected a model and the native path runs, the document is sent with LlmServiceManagerInterface::chatForConfiguration(), which takes the configuration and the probe's ModelResolution, as ConversationService hands over its decision (#922). Two selections moments apart can disagree, and the send must run on the model whose document support was checked. Every other call keeps chat() unchanged.

4. A selected model that reads no documents refuses the rasterization fallback. The fallback reads each page through VisionServiceInterface, whose options carry no configuration, so vision() runs on the installation default. When the probe selected the model of a criteria-mode configuration and that model reads no PDF, the call throws ServiceUnavailableException (code 1796473302, reason fallback_ignores_configuration): the selected model cannot read documents, and the fallback would ignore the configuration. The exception is built with its existing public constructor, so the API snapshot is unchanged.

5. A caller model that differs from the selection is refused. A model the caller names on ChatOptions wins the send over the selected model (ConfigurationCallPlanner::callOptions() keeps a non-empty model option), so the document would go to a model the probe never checked. When the probe selected the model of a criteria-mode configuration and the options name a different model id, the call throws ProviderException (code 1796473303) before anything is sent. Naming the selected model is no conflict.

Consequences

  • ●● A site that names a criteria-mode configuration can analyse documents. The probe asks the model the criteria select, and the native path sends to that same model.

  • ● No public signature breaks: a trailing parameter with a default is additive on the constructor of a final class (api-stability). The API snapshot records the new signature, and the change has an added changelog fragment.

  • ◐ The handed-over send goes through chatForConfiguration(), not chat(). One difference follows, on calls that failed in the probe before this record: the response carries no composed skill versions (ADR-322). chatForConfiguration() now threads the request-count metadata as chat() does, so ChatOptions::withSuppressRequestCount() is honoured on that path, for every caller of chatForConfiguration().

  • ◐ A criteria-mode configuration whose selected model reads no PDF fails with 1796473302 instead of sending its pages to the installation default. Such a call failed in the probe before this record, so no call that answered before fails now.

  • ◐ On a criteria-mode configuration, options that name another model than the selected one fail with 1796473303. Such a call failed in the probe before this record.

  • ◑ A fixed-mode site configuration whose model reads no PDF still falls back to rasterization through VisionServiceInterface, whose options carry no site, so its pages are read by the installation default's model. That gap predates this record, stays as it is here, and is tracked in #1503.

  • ◑ A DocumentAnalysisService constructed by hand without the new argument keeps the old failure for a criteria-mode configuration. Nothing warns about that.

Net Score: +2.0

Alternatives considered

Give ConfigurationResolver the selection service and let it return the selected model. Rejected: the resolver chooses configurations, and the planner keeps that decision apart from choosing a model; putting model selection into the resolver mixes the two in a type that five @api constructors take.

Probe and send the model the caller names instead of refusing it. Rejected: the service holds no repository and would need another constructor argument to find that model's record, and the named model would bypass the selection the configuration's criteria make.

Leave the limit as ADR-331 recorded it. Rejected: the configuration is valid and chat() serves it. Document analysis failing with "no default provider configured" for it points the operator at the wrong cause.

← All ADRs