Class JevModelRouterMiddleware
- All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase
Routing happens in two hooks: onAgent(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, io.agentscope.core.middleware.AgentInput, java.util.function.Function<io.agentscope.core.middleware.AgentInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>>) asks Jev once per agent invocation (using the
latest user message) and stores the result in RuntimeContext; onModelCall(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, io.agentscope.core.middleware.ModelCallInput, java.util.function.Function<io.agentscope.core.middleware.ModelCallInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>>)
replaces ModelCallInput.model on every subsequent model call in that invocation. This
means an intermediate tool result cannot cause the agent to switch models mid-run. When the
decision is unusable (no user text, confidence below threshold, Jev failure while
failOpen is set, or an unrecognized answer), the model configured on the agent is used
as the fallback.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final recordA model candidate and the routing criteria sent to Jev.static final recordThe selected model and the calibrated values returned by Jev. -
Method Summary
Modifier and TypeMethodDescriptiondecision(io.agentscope.core.agent.RuntimeContext ctx) Returns the most recent routing decision for the runtime context.reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>onAgent(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.AgentInput input, Function<io.agentscope.core.middleware.AgentInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>onModelCall(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ModelCallInput input, Function<io.agentscope.core.middleware.ModelCallInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) intorder()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.middleware.MiddlewareBase
onActing, onReasoning, onSystemPrompt
-
Method Details
-
builder
-
order
public int order()- Specified by:
orderin interfaceio.agentscope.core.middleware.MiddlewareBase
-
onAgent
public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> onAgent(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.AgentInput input, Function<io.agentscope.core.middleware.AgentInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) - Specified by:
onAgentin interfaceio.agentscope.core.middleware.MiddlewareBase
-
onModelCall
public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> onModelCall(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ModelCallInput input, Function<io.agentscope.core.middleware.ModelCallInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) - Specified by:
onModelCallin interfaceio.agentscope.core.middleware.MiddlewareBase
-
decision
public static JevModelRouterMiddleware.RoutingDecision decision(io.agentscope.core.agent.RuntimeContext ctx) Returns the most recent routing decision for the runtime context.- Parameters:
ctx- the runtime context, may benull- Returns:
- the decision, or
nullwhen the router has not run
-