Skip to main content

ToolResponseContent

Tool/function execution response returned to the LLM with result data and optional API metadata.

Import

import type { ToolResponseContent } from '@adaline/api';

Type Definition

interface ToolResponseContent {
  modality: 'tool-response';
  index: number;
  id: string;
  name: string;
  data: string;
  apiResponse?: {
    statusCode?: number;
  } | null;
}

Fields

modality
string
required
Must be "tool-response".
index
number
required
Zero-based index matching the tool call. Minimum: 0.
id
string
required
Identifier matching the corresponding tool call id.
name
string
required
Name of the function that was called.
data
string
required
JSON-encoded string of the function result.
apiResponse
{ statusCode?: number } | null
Optional API response metadata with HTTP status code.

Example

import type { ToolResponseContent, PromptMessage } from '@adaline/api';

const toolResponse: ToolResponseContent = {
  modality: 'tool-response',
  index: 0,
  id: 'call_abc123',
  name: 'get_weather',
  data: JSON.stringify({
    temperature: 72,
    conditions: 'sunny',
    humidity: 65
  }),
  apiResponse: {
    statusCode: 200
  }
};

const message: PromptMessage = {
  role: 'tool',
  content: [toolResponse]
};
JSON:
{
  "modality": "tool-response",
  "index": 0,
  "id": "call_abc123",
  "name": "get_weather",
  "data": "{\"temperature\":72,\"conditions\":\"sunny\",\"humidity\":65}",
  "apiResponse": {
    "statusCode": 200
  }
}