Package com.github.copilot.sdk.json
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 LLMbinaryResultsForLlm- the list of binary results to be sent to the LLMerror- the error message, ornullif successfulsessionLog- the session log texttoolTelemetry- 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 Summary
ConstructorsConstructorDescriptionToolResultObject(String resultType, String textResultForLlm, List<ToolBinaryResult> binaryResultsForLlm, String error, String sessionLog, Map<String, Object> toolTelemetry) Creates an instance of aToolResultObjectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebinaryResultsForLlmrecord component.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.static ToolResultObjectCreates an error result with the given error message.static ToolResultObjectCreates an error result with both a text result and error message.static ToolResultObjectCreates a failure result with the given text and error message.final inthashCode()Returns a hash code value for this object.Returns the value of theresultTyperecord component.Returns the value of thesessionLogrecord component.static ToolResultObjectCreates a success result with the given text.Returns the value of thetextResultForLlmrecord component.Returns the value of thetoolTelemetryrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ToolResultObject
public ToolResultObject(String resultType, String textResultForLlm, List<ToolBinaryResult> binaryResultsForLlm, String error, String sessionLog, Map<String, Object> toolTelemetry) Creates an instance of aToolResultObjectrecord class.- Parameters:
resultType- the value for theresultTyperecord componenttextResultForLlm- the value for thetextResultForLlmrecord componentbinaryResultsForLlm- the value for thebinaryResultsForLlmrecord componenterror- the value for theerrorrecord componentsessionLog- the value for thesessionLogrecord componenttoolTelemetry- the value for thetoolTelemetryrecord component
-
-
Method Details
-
success
Creates a success result with the given text.- Parameters:
textResultForLlm- the text result to be sent to the LLM- Returns:
- a success result
-
error
Creates an error result with the given error message.- Parameters:
error- the error message- Returns:
- an error result
-
error
Creates an error result with both a text result and error message.- Parameters:
textResultForLlm- the text result to be sent to the LLMerror- the error message- Returns:
- an error result
-
failure
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 LLMerror- the error message- Returns:
- a failure result
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
resultType
Returns the value of theresultTyperecord component.- Returns:
- the value of the
resultTyperecord component
-
textResultForLlm
Returns the value of thetextResultForLlmrecord component.- Returns:
- the value of the
textResultForLlmrecord component
-
binaryResultsForLlm
Returns the value of thebinaryResultsForLlmrecord component.- Returns:
- the value of the
binaryResultsForLlmrecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-
sessionLog
Returns the value of thesessionLogrecord component.- Returns:
- the value of the
sessionLogrecord component
-
toolTelemetry
Returns the value of thetoolTelemetryrecord component.- Returns:
- the value of the
toolTelemetryrecord component
-