OpenAI adapter
Responses API with a configured GPT-5.6 model, structured output, normalized usage, bounded timeout, and task-specific prompt version.
The LLM layer helps with ambiguous product ranking, basket suggestions, explanations, and recovery hints. Structured contracts keep model output advisory and testable.
interface IntelligencePort {
generateStructured<TInput, TOutput>(
request: IntelligenceRequest<TInput>,
outputSchema: JsonSchema
): Promise<IntelligenceResult<TOutput>>;
}
type IntelligenceTask =
| 'basket.propose'
| 'product.match-candidates'
| 'substitution.rank'
| 'order.explain-changes'
| 'browser.recovery-hint';
| Task | Model contribution | Deterministic verification |
|---|---|---|
| Basket proposal | Suggest likely due items from sanitized history features | User confirmation, cadence rules, active product refs |
| Candidate ranking | Rank a small set of similar retailer products | Exact ID, size, availability, approved policy, fresh price |
| Substitution ranking | Explain tradeoffs among already allowed candidates | Approved alternatives and item-level limits |
| Change explanation | Turn reason codes into concise household language | Every statement traces to structured facts |
| Recovery hint | Suggest how to re-locate a changed page element | No direct action; reviewed locator and postcondition required |
Responses API with a configured GPT-5.6 model, structured output, normalized usage, bounded timeout, and task-specific prompt version.
Messages API with claude-opus-4-8, equivalent schemas, normalized finish reasons, and the same contract suite.
Changing the configured model is not only a configuration edit. The candidate-matching, injection, faithfulness, schema-validity, latency, and cost evaluation set must pass again.
Prices, fees, quantities, savings, and budget enforcement come from retailer data and deterministic calculation.
A generated product reference is never trusted. It must resolve against a fresh retailer candidate and pass product rules.
Automation mode, approval validity, restricted categories, and final checkout are evaluated outside the LLM.