Skip to content

Attach Files to Code Interpreter in an Existinng version #44895

@sarmadafzalj

Description

@sarmadafzalj

Is your feature request related to a problem? Please describe.
Yes. When working with agents, tool configuration (specifically the Code Interpreter) is tightly coupled to the agent version. If I create an agent and later want to attach files to its Code Interpreter tool, I’m forced to create a new agent version. This is frustrating and impractical, especially for workflows where files are dynamic or message-specific. Additionally, attempting to attach files at message creation time—similar to how it works in the core OpenAI Responses API—results in a 400 invalid_payload error when an agent is specified.

Describe the solution you'd like
There should be a way to attach files to an agent’s Code Interpreter tool dynamically at message creation time, without requiring a new agent version. Ideally, this should work the same way it does in the core OpenAI Responses API, where files (or file-backed containers) can be passed with the request while referencing an existing agent. This would allow greater flexibility and avoid unnecessary agent version proliferation.

Describe alternatives you've considered
Creating a new version of the agent every time files need to be attached (not ideal or scalable).

  • Creating a separate Code Interpreter container, uploading files there, and attaching it to the conversation (currently not supported / not possible in this context).
  • Both alternatives introduce unnecessary complexity and break the expected workflow.

Additional context
Attempting to pass the Code Interpreter tool with file IDs at message creation time while referencing an agent results in the following error:

BadRequestError: Error code: 400 - {
  'error': {
    'code': 'invalid_payload',
    'message': 'Not allowed when agent is specified.',
    'param': 'tools',
    'type': 'invalid_request_error'
  }
}

Sample request:

with project_client.get_openai_client() as openai_client:
    openai_client.responses.create(
        input="Sarmad Afzal",
        tools=[
            CodeInterpreterTool(
                container=CodeInterpreterToolAuto(
                    file_ids=["assistant-Kv4KipWzvPcBbz7WffprCX"]
                )
            )
        ],
        extra_body={
            "agent": {
                "name": "636-c8cc323af274-agent",
                "type": "agent_reference"
            }
        }
    )

This limitation prevents attaching files dynamically and blocks common use cases where file inputs are message-specific rather than agent-version-specific.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI AgentsService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions