Record Class ToolCallDecision

java.lang.Object
java.lang.Record
org.springframework.ai.model.tool.ToolCallDecision
Record Components:
toolCallId - the key of the tool call the decision is about: its id, or its position key when it has no id of its own (see ToolCallDecisions.toolCallKeys(org.springframework.ai.chat.messages.AssistantMessage))
allowed - whether the call may run
message - for a denied call, the result the model receives; null for the default, never blank

public record ToolCallDecision(String toolCallId, boolean allowed, @Nullable String message) extends Record
A caller's decision on one tool call that waits for confirmation: allow it to run, or deny it with a message that the model receives as the call's result.
Since:
2.1.0
Author:
Christian Tzolov
See Also:
  • Field Details

    • DEFAULT_DENY_MESSAGE

      public static final String DEFAULT_DENY_MESSAGE
      The result a denied call answers the model with when the decision gives none.
      See Also:
  • Constructor Details

    • ToolCallDecision

      public ToolCallDecision(String toolCallId, boolean allowed, @Nullable String message)
      Creates an instance of a ToolCallDecision record class.
      Parameters:
      toolCallId - the value for the toolCallId record component
      allowed - the value for the allowed record component
      message - the value for the message record component
  • Method Details

    • allow

      public static ToolCallDecision allow(String toolCallId)
      Allows the tool call to run.
    • deny

      public static ToolCallDecision deny(String toolCallId)
      Denies the tool call; the model receives the default message.
    • deny

      public static ToolCallDecision deny(String toolCallId, String message)
      Denies the tool call; the model receives the message as the call's result.
    • denyMessage

      public String denyMessage()
      The result a denied call answers the model with.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • toolCallId

      public String toolCallId()
      Returns the value of the toolCallId record component.
      Returns:
      the value of the toolCallId record component
    • allowed

      public boolean allowed()
      Returns the value of the allowed record component.
      Returns:
      the value of the allowed record component
    • message

      public @Nullable String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component