Class JevAutoModeMiddleware

java.lang.Object
io.agentscope.extensions.judge.jev.example.JevAutoModeMiddleware
All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase

public final class JevAutoModeMiddleware extends Object implements io.agentscope.core.middleware.MiddlewareBase
Uses Jev to decide, before execution, whether a guarded tool call is safe enough to run automatically.

For every tool call whose name appears in guardedTools, this middleware asks Jev a yes/no risk question built from the conversation history and the tool input. Calls whose P(safe) is at least safetyThreshold pass through; the rest get a synthetic DENIED tool result written to the conversation state and are never dispatched to the toolkit. Tool calls that were already explicitly allowed by the user (state ALLOWED) skip the check entirely, so this guardrail cannot override a human confirmation.

The check runs in onActing(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, io.agentscope.core.middleware.ActingInput, java.util.function.Function<io.agentscope.core.middleware.ActingInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>>), after any outer middleware that filters or rewrites tool calls and immediately before the core permission/execution pipeline. This makes it complementary to the deterministic PermissionEngine: a call that passes the Jev assessment is still subject to permission deny rules inside the core acting pipeline, so this middleware adds a model-driven pre-check for the specific tools it guards without replacing the rule-based engine.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    onActing(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ActingInput input, Function<io.agentscope.core.middleware.ActingInput,reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next)
     
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.agentscope.core.middleware.MiddlewareBase

    onAgent, onModelCall, onReasoning, onSystemPrompt
  • Field Details

  • Method Details

    • builder

      public static JevAutoModeMiddleware.Builder builder(JevClient client)
    • order

      public int order()
      Specified by:
      order in interface io.agentscope.core.middleware.MiddlewareBase
    • onActing

      public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> onActing(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ActingInput input, Function<io.agentscope.core.middleware.ActingInput,reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next)
      Specified by:
      onActing in interface io.agentscope.core.middleware.MiddlewareBase