Skip to main content
This document describes how tool/function calling is represented in OpenInference spans.

Tool Definitions

Tools available to the LLM are represented using the llm.tools prefix with flattened attributes:

Attribute Pattern

The json_schema contains the complete tool definition as a JSON string, including:
  • Tool type (usually “function”)
  • Function name
  • Function description
  • Parameter schema

Example Tool Definition

Tool Calls in Messages

When an LLM generates tool calls, they are represented in the output messages:

Attribute Pattern for Tool Calls

Where:
  • <messageIndex> is the zero-based index of the message
  • <toolCallIndex> is the zero-based index of the tool call within the message
  • <attribute> is the specific tool call attribute

Tool Call Attributes

  • tool_call.id: Unique identifier for the tool call
  • tool_call.function.name: Name of the function being called
  • tool_call.function.arguments: JSON string containing the function arguments

Example Tool Call

Multiple Tool Calls

When an LLM makes multiple tool calls in a single response:

Tool Results

Tool results are typically represented as input messages with role “tool”:
The message.tool_call_id links the result back to the original tool call. The message.name attribute MAY be set to identify which function produced the result — it typically matches tool_call.function.name from the corresponding tool call.

Complete Tool Call Flow Example

1. User Request

2. Available Tools

3. LLM Tool Call

4. Tool Result (in next request)

5. Final Response

Legacy Attributes

Some implementations may use legacy attributes for function calling. New implementations should use the tool_calls structure described above.
Legacy attributes:
  • message.function_call_name: Function name (deprecated, use tool_calls)
  • message.function_call_arguments_json: Function arguments (deprecated, use tool_calls)
  • llm.function_call: Complete function call as JSON (deprecated)