Skip to content

Comments

Python: Add file_ids support to AzureAIAgentClient.get_code_interpreter_tool()#4201

Open
giles17 wants to merge 2 commits intomicrosoft:mainfrom
giles17:azure_ai_code_int
Open

Python: Add file_ids support to AzureAIAgentClient.get_code_interpreter_tool()#4201
giles17 wants to merge 2 commits intomicrosoft:mainfrom
giles17:azure_ai_code_int

Conversation

@giles17
Copy link
Contributor

@giles17 giles17 commented Feb 23, 2026

Summary

Adds file_ids and data_sources keyword arguments to AzureAIAgentClient.get_code_interpreter_tool(), matching the underlying azure.ai.agents SDK CodeInterpreterTool constructor. This enables users to attach uploaded files for code interpreter analysis.

Problem

AzureAIAgentClient.get_code_interpreter_tool() accepted no parameters and always returned a CodeInterpreterTool() without file references. Users had no way to attach uploaded CSV/data files through the framework's factory method.

Changes

  • _chat_client.py: Updated get_code_interpreter_tool() to accept file_ids and data_sources keyword-only parameters, forwarding them to the SDK's CodeInterpreterTool(...). Added VectorStoreDataSource import.
  • test_azure_ai_agent_client.py: Added 3 tests covering basic instantiation, file_ids forwarding, and _prepare_tools_for_azure_ai correctly populating tool_resources.

Usage

from agent_framework.azure import AzureAIAgentClient

# With uploaded file IDs
tool = AzureAIAgentClient.get_code_interpreter_tool(file_ids=["file-abc123"])
agent = ChatAgent(client, tools=[tool])

Fixes #4050

…et_code_interpreter_tool()

Update the factory method to accept file_ids and data_sources keyword
arguments, matching the underlying azure.ai.agents SDK CodeInterpreterTool
constructor. This enables users to attach uploaded files for code
interpreter analysis.

Fixes microsoft#4050

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 23, 2026 23:34
@giles17 giles17 added bug Something isn't working python labels Feb 23, 2026
@giles17 giles17 changed the title Python: Add file_ids and data_sources support to AzureAIAgentClient.get_code_interpreter_tool() Python: Add file_ids support to AzureAIAgentClient.get_code_interpreter_tool() Feb 23, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 23, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai/agent_framework_azure_ai
   _chat_client.py4787584%406–407, 409, 593, 598–599, 601–602, 605, 608, 610, 615, 876–877, 879, 882, 885, 888–893, 896, 898, 906, 918–920, 924, 927–928, 936–939, 949, 957–960, 962–963, 965–966, 973, 981–982, 990–991, 996–997, 1001–1008, 1013, 1016, 1024, 1030, 1038–1040, 1043, 1065–1066, 1199, 1227, 1242, 1358, 1480
TOTAL22149347484% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4270 240 💤 0 ❌ 0 🔥 1m 16s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds file_ids and data_sources support to AzureAIAgentClient.get_code_interpreter_tool(), enabling users to attach uploaded files to the code interpreter for analysis. This addresses issue #4050 where users couldn't provide file attachments through the framework's factory method.

Changes:

  • Extended get_code_interpreter_tool() to accept file_ids and data_sources keyword arguments that are forwarded to the Azure Agents SDK's CodeInterpreterTool
  • Added VectorStoreDataSource import to support the new parameter type
  • Added comprehensive test coverage for basic instantiation, file_ids forwarding, and integration with the tool preparation pipeline

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py Added file_ids and data_sources parameters to get_code_interpreter_tool() method with updated docstring and examples; imported VectorStoreDataSource type
python/packages/azure-ai/tests/test_azure_ai_agent_client.py Added three test cases: basic tool creation, file_ids parameter forwarding, and tool_resources population in run options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Not able to read attached files when carryout simple analysis with csv files

2 participants