-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
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.