Class ToolResultObject

java.lang.Object
com.github.copilot.sdk.json.ToolResultObject

public final class ToolResultObject extends Object
Result object returned from a tool execution.

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

Example: Success Result


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

Example: Error Result


 return new ToolResultObject().setResultType("error").setError("File not found: " + path);
 
Since:
1.0.0
See Also:
  • Constructor Details

    • ToolResultObject

      public ToolResultObject()
  • Method Details

    • getTextResultForLlm

      public String getTextResultForLlm()
      Gets the text result to be sent to the LLM.
      Returns:
      the text result
    • setTextResultForLlm

      public ToolResultObject setTextResultForLlm(String textResultForLlm)
      Sets the text result to be sent to the LLM.
      Parameters:
      textResultForLlm - the text result
      Returns:
      this result for method chaining
    • getBinaryResultsForLlm

      public List<ToolBinaryResult> getBinaryResultsForLlm()
      Gets the binary results to be sent to the LLM.
      Returns:
      the list of binary results
    • setBinaryResultsForLlm

      public ToolResultObject setBinaryResultsForLlm(List<ToolBinaryResult> binaryResultsForLlm)
      Sets binary results (images, files) to be sent to the LLM.
      Parameters:
      binaryResultsForLlm - the list of binary results
      Returns:
      this result for method chaining
    • getResultType

      public String getResultType()
      Gets the result type.
      Returns:
      the result type ("success" or "error")
    • setResultType

      public ToolResultObject setResultType(String resultType)
      Sets the result type.
      Parameters:
      resultType - "success" or "error"
      Returns:
      this result for method chaining
    • getError

      public String getError()
      Gets the error message.
      Returns:
      the error message, or null if successful
    • setError

      public ToolResultObject setError(String error)
      Sets an error message for failed tool execution.
      Parameters:
      error - the error message
      Returns:
      this result for method chaining
    • getSessionLog

      public String getSessionLog()
      Gets the session log entry.
      Returns:
      the session log text
    • setSessionLog

      public ToolResultObject setSessionLog(String sessionLog)
      Sets a log entry to be recorded in the session.
      Parameters:
      sessionLog - the log entry
      Returns:
      this result for method chaining
    • getToolTelemetry

      public Map<String,Object> getToolTelemetry()
      Gets the tool telemetry data.
      Returns:
      the telemetry map
    • setToolTelemetry

      public ToolResultObject setToolTelemetry(Map<String,Object> toolTelemetry)