Class ToolResultPart

java.lang.Object
com.codename1.ai.MessagePart
com.codename1.ai.ToolResultPart

public final class ToolResultPart extends MessagePart
The result of a tool invocation, sent back to the model so it can continue reasoning. Pairs with the originating ToolCall via the toolCallId. The carrying ChatMessage should use Role.TOOL. Result content sent back to a model after executing a requested tool call. The result is JSON text so providers receive the original structured value.
  • Constructor Details

    • ToolResultPart

      public ToolResultPart(String toolCallId, String resultJson)
      resultJson is the literal JSON string the tool produced. If the tool result isn't valid JSON, wrap it like "{\"text\":\"...\"}" -- the providers expect JSON-shaped values. Creates a tool result part.
      Parameters:
      toolCallId - id of the ToolCall being answered
      resultJson - JSON value returned by the application tool
  • Method Details

    • getToolCallId

      public String getToolCallId()
      Returns:
      provider tool-call id this result answers
    • getResultJson

      public String getResultJson()
      Returns:
      application result encoded as JSON