java.lang.Object
io.agentscope.core.chat.completions.model.ToolCall

public class ToolCall extends Object
Represents a tool call in OpenAI-compatible format.

This DTO is used to serialize tool calls in the conversation context, allowing clients to reconstruct the full conversation history including tool invocations.

Example JSON (non-streaming):


 {
   "id": "call_abc123",
   "type": "function",
   "function": {
     "name": "get_weather",
     "arguments": "{\"city\":\"Hangzhou\"}"
   }
 }
 

Example JSON (streaming with index):


 {
   "index": 0,
   "id": "call_abc123",
   "type": "function",
   "function": {
     "name": "get_weather",
     "arguments": "{\"city\":\"Hangzhou\"}"
   }
 }
 
  • Constructor Details

    • ToolCall

      public ToolCall()
      Default constructor for deserialization.
    • ToolCall

      public ToolCall(String id, String name, String arguments)
      Creates a new tool call.
      Parameters:
      id - Unique identifier for this tool call
      name - Function name
      arguments - JSON string of function arguments
    • ToolCall

      public ToolCall(Integer index, String id, String name, String arguments)
      Creates a new tool call with index (for streaming).
      Parameters:
      index - Index in the tool_calls array
      id - Unique identifier for this tool call
      name - Function name
      arguments - JSON string of function arguments
  • Method Details