-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Summary
Add per-message file attachment support to AzureAIAgentClient (V1) via MessageAttachment in _prepare_messages().
Problem
The Azure AI Agents SDK supports per-message file scoping via MessageAttachment, which attaches a file to a specific message rather than the agent/thread. This is important for multi-user scenarios where the same agent is shared across users but files should be isolated per-request.
Currently, AzureAIAgentClient._prepare_messages() has no hosted_file case, so Content.from_hosted_file() is silently dropped when used in message contents.
Expected Behavior
Users should be able to attach files per-message like this:
file_content = Content.from_hosted_file(file_id=uploaded.id)
message = Message(role="user", contents=["Analyze the CSV.", file_content])
response = await agent.run(message)This should be converted to a MessageAttachment on the ThreadMessageOptions sent to the API.
Design Considerations
The MessageAttachment requires a tools parameter specifying which tools can use the file (CodeInterpreterTool, FileSearchTool, or both). The challenge is determining which tool definitions to include:
Content.from_hosted_file()is a framework-level concept with no tool type info_prepare_messages()currently has no access to the agent's configured tools- Hardcoding one tool type (e.g.,
CodeInterpreterTool) would break for other tool types - Passing tool definitions into
_prepare_messages()would deviate from the existing pattern across all clients
Options to consider:
- Pass tool definitions into
_prepare_messages()and filter for attachment-compatible types - Include both
CodeInterpreterToolandFileSearchToolon every attachment (needs API validation) - Add tool type info to
Content.from_hosted_file()(couples framework to Azure SDK concepts)
References
- PR Python: Add file_ids and data_sources support to get_code_interpreter_tool() #4201 discussion
- Issue Python: Not able to read attached files when carryout simple analysis with csv files #4050 (original feature request)
- Azure AI Agents SDK
MessageAttachmentpattern
Metadata
Metadata
Assignees
Labels
Type
Projects
Status