Overview

genai_has_tool_calls

You can use this function to filter conversations that use function calling, monitor tool usage patterns, identify integration opportunities, or track feature adoption of function calling capabilities.

Usage#

Syntax#

genai_has_tool_calls(messages)

Parameters#

Name Type Required Description
messages dynamic Yes An array of message objects from a GenAI conversation. Each message typically contains role and content fields.

Returns#

Returns a boolean value: true if the messages contain tool calls, false otherwise.

Example#

Check if a GenAI conversation contains any tool calls or function calls.

Query

['otel-demo-genai']
| extend has_tools = genai_has_tool_calls(['attributes.gen_ai.input.messages'])
| summarize
    conversations_with_tools = countif(has_tools),
    total_conversations = count(),
    adoption_rate = round(100.0 * countif(has_tools) / count(), 2)

Run in Playground

Output

conversations_with_tools total_conversations adoption_rate
345 1450 23.79

This query tracks function calling adoption, helping you understand feature usage trends.

Other query languages#

Splunk SPL users

In Splunk SPL, you would check if tool-related fields exist in the messages.

Splunk example

| eval has_tools=if(isnotnull(tool_calls), "true", "false")

APL equivalent

['ai-logs']
| extend has_tools = genai_has_tool_calls(messages)
ANSI SQL users

In ANSI SQL, you would check for existence of tool calls in the messages array.

SQL example

SELECT
  conversation_id,
  EXISTS(
    SELECT 1 FROM UNNEST(messages)
    WHERE JSON_EXTRACT(content, '$.tool_calls') IS NOT NULL
  ) as has_tools
FROM conversations

APL equivalent

['ai-logs']
| extend has_tools = genai_has_tool_calls(messages)

Updated

Was this page helpful?