Code execution lets an Agent run code to work with your data directly, instead of only describing what it would do. It inspects uploaded files, works through larger datasets, and returns the result as a finished file you can download from the chat.
What it is
With code execution enabled, the Agent can run shell commands inside an isolated container to inspect data, produce files, and refine its approach step by step. A typical turn looks like this: you send a message with a file, the Agent works on it in the sandbox, and any files it produces come back in the conversation as downloads.
This is what makes an Agent useful for work that does not fit in a chat message — a spreadsheet with tens of thousands of rows, a folder of exports to reconcile, a chart that has to be generated rather than described.
Turning it on
Code execution is a per-Agent capability, switched on in the Agent's settings alongside file upload. Two things to know:
- It only works with models that support it. If an Agent is set to a model without code execution, the capability stays inactive no matter the toggle.
- It pairs with file upload. Without the ability to send files, there is little for the sandbox to work on.
For personal Agents, code execution is governed centrally: an administrator enables it for everyone's personal Agent at once, rather than per user.
The sandbox
The Agent works in an isolated environment that is reused across the messages of one conversation. That is deliberate — it means intermediate results survive from one message to the next, so you can say "now group that by region" without re-uploading anything.
The environment is rebuilt in two cases:
- it expires after a period of inactivity, or
- the Skills available to the Agent change, which requires a fresh environment.
After a rebuild, files from earlier in the conversation are made available again, but anything the Agent created only inside the environment and never returned is gone. If a result matters, it is safest to have the Agent hand it back as a file.
Files
Files you upload and files the Agent produces are both kept with the conversation, so a download stays available after the sandbox itself is gone.
Occasionally a produced file cannot be retrieved and the Agent will say so rather than pretend it succeeded — in that case, ask it to produce the file again.
Working with Skills
Skills and code execution reinforce each other. A Skill's bundled files land in the sandbox as real files on disk, so a Skill can carry a template, a reference dataset, or a script that the Agent then runs against your input. The Skill supplies the procedure; code execution supplies the ability to carry it out.