Record Class ToolResultObject

java.lang.Object
java.lang.Record
com.github.copilot.sdk.json.ToolResultObject
Record Components:
resultType - the result type ("success" or "error"), defaults to "success"
textResultForLlm - the text result to be sent to the LLM
binaryResultsForLlm - the list of binary results to be sent to the LLM
error - the error message, or null if successful
sessionLog - the session log text
toolTelemetry - the tool telemetry data

public record ToolResultObject(String resultType, String textResultForLlm, List<ToolBinaryResult> binaryResultsForLlm, String error, String sessionLog, Map<String,Object> toolTelemetry) extends Record
Result object returned from a tool execution.

This record represents the structured result of a tool invocation, including text output, binary data, error information, and telemetry.

Example: Success Result


 return ToolResultObject.success("File contents: " + content);
 

Example: Error Result


 return ToolResultObject.error("File not found: " + path);
 

Example: Custom Result


 return new ToolResultObject("success", "Result text", null, null, null, null);
 
Since:
1.0.0
See Also:
  • Constructor Details

  • Method Details

    • success

      public static ToolResultObject success(String textResultForLlm)
      Creates a success result with the given text.
      Parameters:
      textResultForLlm - the text result to be sent to the LLM
      Returns:
      a success result
    • error

      public static ToolResultObject error(String error)
      Creates an error result with the given error message.
      Parameters:
      error - the error message
      Returns:
      an error result
    • error

      public static ToolResultObject error(String textResultForLlm, String error)
      Creates an error result with both a text result and error message.
      Parameters:
      textResultForLlm - the text result to be sent to the LLM
      error - the error message
      Returns:
      an error result
    • failure

      public static ToolResultObject failure(String textResultForLlm, String error)
      Creates a failure result with the given text and error message.

      The "failure" result type indicates that the tool execution itself failed (e.g., tool not found), while "error" indicates the tool executed but encountered an error during processing.

      Parameters:
      textResultForLlm - the text result to be sent to the LLM
      error - the error message
      Returns:
      a failure result
    • 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.
    • resultType

      public String resultType()
      Returns the value of the resultType record component.
      Returns:
      the value of the resultType record component
    • textResultForLlm

      public String textResultForLlm()
      Returns the value of the textResultForLlm record component.
      Returns:
      the value of the textResultForLlm record component
    • binaryResultsForLlm

      public List<ToolBinaryResult> binaryResultsForLlm()
      Returns the value of the binaryResultsForLlm record component.
      Returns:
      the value of the binaryResultsForLlm record component
    • error

      public String error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component
    • sessionLog

      public String sessionLog()
      Returns the value of the sessionLog record component.
      Returns:
      the value of the sessionLog record component
    • toolTelemetry

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