foundry agents . can a tool output be a file?

alejandro piccardo 60 Reputation points
2025-09-03T14:10:58.56+00:00

tengo un agente con code interpreter.

y una tool en mi backend que es un extractor sql.

antes de habilitar el code interpreter, mi agent loop ejecutaba la tool lo que devolvia un dataframe pasado a txt...

estaba intentando que en vez de pasarle texto. la tool suba a code interpreter la file como .csv .
el problema es que como en mi agent loop la run esta en curso, no puedo subir archivos attatchment al code interpreter con ".messages.create"

mi sdk muestra una forma de actualizar el run actual con el comando ".agents.runs.update"

self._project.agents.runs.update(
	thread_id=thread_id,
	run_id=run.id,
	tool_resources=ToolResources(
		code_interpreter= CodeInterpreterToolResource(file_ids=uploaded_ids)
                                 ),
                                )
except Exception as e:
                                update_error = f"No se pudo actualizar tool_resources: {e}"
                                upload_errors.append(update_error)

pero creo que ese comando ya no soporta tool_resources
console:Session.request() got an unexpected keyword argument 'tool_resources'"]}

¿Existe una forma de que la tool suba un archivo al code interpreter? o siempre tiene que devolver texto?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
{count} votes

Answer accepted by question author
  1. Ravada Shivaprasad 1,955 Reputation points Microsoft External Staff Moderator
    2025-09-03T16:37:06.7766667+00:00

    Hi alejandro piccardo

    To accurately and effectively upload a file to the Code Interpreter during an active agent run, it’s important to understand the current limitations and supported workflows within the OpenAI SDK. Previously, developers could use the agents.runs.update() method to inject tool_resources, such as file IDs, directly into an ongoing run. However, this capability has been deprecated, and attempting to use tool_resources in this way now results in an error like Session.request() got an unexpected keyword argument 'tool_resources'. This confirms that the SDK no longer supports updating a run with tool resources dynamically.

    The correct and supported approach now involves leveraging the thread and message architecture. Specifically, your tool (e.g., an SQL extractor) should return the file ID(s) of the uploaded .csv file as part of its output payload. These file IDs must then be attached to the thread using the threads.messages.create() method. This method allows you to associate the file with a message in the thread, which the Code Interpreter can then access in subsequent steps of the run.
    For example, after your tool uploads the file and returns the file ID, your agent loop should create a message like: client.beta.threads.messages.create(thread_id=..., role="user", content="Here is the CSV file.", file_ids=["file-abc123"]). This ensures the file is properly linked to the thread and available to the Code Interpreter.Files cannot be attached directly to an active run or injected mid-run using deprecated methods. Instead, the tool should return file IDs, and the agent loop must create a new message in the thread using threads.messages.create() to attach those files. This ensures the Code Interpreter can access them and keeps the workflow aligned with OpenAI’s current architecture.

    Hope it Helps!

    Thank you


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.