Interface ToolCallGuardrail
- All Superinterfaces:
Guardrail
An implementation has a public constructor, optionally taking a GuardrailContext
parameter, which gives access to the guardrail's configured name and config section. The per-call
data is delivered to decide(akka.javasdk.agent.ToolCallGuardrail.CallContext) via ToolCallGuardrail.CallContext. Guardrails are enabled via
configuration; see the agent documentation.
The runtime shares one instance across concurrent calls from different sessions and agents. An implementation must be thread safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePer-call context passed to aToolCallGuardrailduringdecide(akka.javasdk.agent.ToolCallGuardrail.CallContext).Nested classes/interfaces inherited from interface akka.javasdk.agent.Guardrail
Guardrail.GuardrailException, Guardrail.Message, Guardrail.Result -
Method Summary
Modifier and TypeMethodDescriptionDecides whether the tool call described byctxmay be dispatched.default CompletionStage<Decision> Async variant ofdecide(akka.javasdk.agent.ToolCallGuardrail.CallContext), for implementations that prefer composing futures.
-
Method Details
-
decide
Decides whether the tool call described byctxmay be dispatched.Use
Decision.Denyto refuse the call. ReturningDecision.Failand throwing are equivalent: both mean the guardrail reached no verdict, which is distinct from refusing the call.This is the method to implement. It may block: guardrails are always evaluated on virtual threads.
- Returns:
- the decision
-
decideAsync
Async variant ofdecide(akka.javasdk.agent.ToolCallGuardrail.CallContext), for implementations that prefer composing futures.The default implementation delegates to
decide(akka.javasdk.agent.ToolCallGuardrail.CallContext). When this method is overridden,decide(akka.javasdk.agent.ToolCallGuardrail.CallContext)is no longer used, and it is then safe to have it throwUnsupportedOperationExceptionor returnnull.Completing with
Decision.Fail, failing the returned stage, and throwing are equivalent: all three mean the guardrail reached no verdict, which is distinct from refusing the call.- Returns:
- a CompletionStage with the decision
-