Record Class ToolInvocationCommand

java.lang.Object
java.lang.Record
com.agentforge4j.core.command.ToolInvocationCommand
Record Components:
toolInvocationId - stable invocation id; generated if absent
capability - non-blank logical capability id, for example "github.create_pull_request"
arguments - tool arguments as a JSON object; never null (defaults to empty)
llmRationale - model rationale for audit, or null
All Implemented Interfaces:
LlmCommand

public record ToolInvocationCommand(String toolInvocationId, String capability, Map<String,Object> arguments, String llmRationale) extends Record implements LlmCommand
Request from the LLM to invoke a logical tool capability. An LlmCommand that always flows through the runtime's ToolExecutionService chokepoint, never directly to an external system.

toolInvocationId correlates audit events and approval resume. The LLM omits it when emitting the command, so the compact constructor generates a UUID when it is null or blank — leaving an explicitly supplied id untouched.

arguments is a JSON object: the LLM emits it as a structured object, not an escaped JSON string. The runtime serializes it to JSON text at the ToolProvider boundary, preserving the opaque-string contract there.

  • Constructor Details

    • ToolInvocationCommand

      public ToolInvocationCommand(String toolInvocationId, String capability, Map<String,Object> arguments, String llmRationale)
      Validates capability, generates toolInvocationId when it is null or blank, and defensively copies arguments (null becomes an empty map).
  • Method Details

    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • toolInvocationId

      public String toolInvocationId()
      Returns the value of the toolInvocationId record component.
      Returns:
      the value of the toolInvocationId record component
    • capability

      public String capability()
      Returns the value of the capability record component.
      Returns:
      the value of the capability record component
    • arguments

      public Map<String,Object> arguments()
      Returns the value of the arguments record component.
      Returns:
      the value of the arguments record component
    • llmRationale

      public String llmRationale()
      Returns the value of the llmRationale record component.
      Returns:
      the value of the llmRationale record component