Azure provider missing tool/function support available in OpenAI provider

Created on 3 June 2025, 2 months ago

Problem/Motivation

The Azure AI provider module currently lacks support for tools/functions (function calling) that are available in the OpenAI provider. This limits the functionality when using Azure OpenAI models that support function calling, as users cannot leverage tool-based interactions that are essential for AI agents and advanced conversational AI applications.

When comparing the two providers:

  • OpenAI Provider: Full support for tools/functions including tool input processing, tool call responses, and tool message handling
  • Azure Provider: Missing tool support entirely

This creates inconsistency between providers and prevents users from utilising the full capabilities of Azure OpenAI models that support function calling.

Steps to reproduce

  1. Create a ChatInput with tools using setChatTools()
  2. Try to use the Azure provider with a model that supports function calling
  3. Notice that tools are not processed or sent to the API
  4. Compare with the OpenAI provider, which properly handles the same input

Proposed resolution

Implement tool/function support in the Azure provider to match the functionality available in the OpenAI provider. This includes:

  1. Add missing imports for tool-related classes:
    • use Drupal\Component\Serialization\Json;
    • use Drupal\ai\OperationType\Chat\Tools\ToolsFunctionOutput;
  2. Update chat method to handle tools in the input processing:
    • Process tool calls in message history (getToolsId(), getRenderedTools())
    • Add tools to API payload when getChatTools() is available
    • Support structured JSON schemas via getChatStructuredJsonSchema()
  3. Handle tool responses from the API:
    • Parse tool_calls from API responses
    • Create ToolsFunctionOutput objects for tool calls
    • Attach tools to the returned ChatMessage
  4. Maintain backward compatibility for existing implementations without tools
Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands euphoric_mv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024