JevModelRouterMiddleware chooses among available models registered by the application and keeps that choice within an Agent invocation. Route simple questions and complex analysis separately without replaying executed tools to select another model.
Example: a short explanation versus analysis of unusual refunds
A user might ask for a one-sentence explanation of refund rules or for an investigation of multiple anomalous refunds with verification steps. A lightweight model may suit the first request and a stronger model the second. An investigation may span several tool and model calls; do not route anew each round. Register allowed candidates and describe their roles. JEV chooses at invocation start. Later model requests recheck availability and compatibility with their tools.1. Register candidates and capability constraints
client as in Client setup. fastModel and strongModel are configured Model instances. The example sets represent a host capability catalog, not claims about particular models.
Both callbacks should return promptly. A real resource catalog must reflect changes, not rely indefinitely on a static set.
2. Keep the original model as fallback
originalModel is your existing model and must meet the original request’s requirements. SHADOW records a recommendation but uses it unchanged. In ENFORCE only a clearly eligible recommendation replaces the model for this request.
3. Understand sticky selection and invalidation
One Agent invocation might make three model requests:
After invalidation the original model stays in use for the rest of the invocation. No reelection or tool replay occurs. Generation errors follow the original execution chain rather than causing the router to rerun the Agent.
Run and verify
SetJEV_CP using the example build instructions: