Select an agent's model with an OpenAI Decisions Choice question.
Classifies the latest human message once before each agent run, stores the
answer as a ModelRoute in agent state under model_route, and uses the selected
route for every model call in the run. Keeping the complete answer makes
probabilities and confidence available in state and traces.
The message text and base64 images are classified. Hosted image URLs, files,
and audio are replaced with placeholders such as [image omitted]. If a request
with images is rejected (HTTP 400 or 413), routing is retried once with every
image replaced.
When no route is selected, because the model refused or the state has no human
message, model_route is set to None and model calls use the agent's own
model. API errors propagate and terminate the run.
Warning
This middleware is experimental. Its API may change without notice.