Sunday, 5 October 2025

Enable Code Interpreter in Copilot Studio (Full Version)

Code interpreter in Copilot Studio is a built in runtime that lets Copilot write and run short Python code in a secure sandbox. It can read files that you upload, perform calculations, build charts, transform data, and return the outputs inline or as downloadable files. Typical uses include quick analysis of CSV or Excel data, data cleaning, format conversions, and simple visualizations, all driven by natural language prompts. More information here.

In the full Copilot Studio experience you enable it at the environment level and then turn it on for specific prompts so your agent can choose when to use code for better answers.

So in this post, let’s enable the new Code interpreter capability in the full version of Copilot Studio and use it from a prompt. We’ll keep it small: flip the right admin switch, add a prompt as a tool in an agent, and verify with a quick run. 

This is not about Copilot Studio Lite/Agent Builder (that already exposes a simple toggle), this walkthrough is for the full Copilot Studio experience.


On a high level, we’ll:

  1. Turn on Code interpreter for your environment in the Power Platform admin center (PPAC).

  2. In Copilot Studio (full), add a Prompt tool to an agent and enable Code interpreter in the prompt’s settings.

  3. Test with a couple of natural‑language requests that execute Python under the hood.

Prereqs: You’ll need access to PPAC (or an admin), a Copilot Studio environment, and a Microsoft 365 Copilot or Copilot Studio license in the right tenant. If you see a message like “Code interpreter is disabled for your environment or tenant”, it usually means step 1 wasn’t completed.

1) Enable at the environment level (admin step)

In Power Platform admin center:

  1. Go to Copilot → Settings.

  2. Under Copilot Studio, open Code generation and execution in Copilot Studio.

  3. Select your environment, choose On, and Save.



That switch unlocks Python‑based execution for prompts and agents in that environment. If you manage multiple environments (Dev/Test/Prod), repeat per environment.

2) Add a prompt to an agent and enable Code interpreter

In Copilot Studio (full):

  1. Open your agentTools tab → New toolPrompt.

  2. In the prompt editor, select … → Settings.

  3. Toggle Enable code interpreterSave/Close.

Tip: This is easy to miss the toggle lives in the prompt’s Settings, not in the agent’s capabilities. If the toggle is missing or disabled, double‑check step 1 or your permissions.


 

3) A minimal prompt

Create a new prompt with the following Instructions:

You are a helpful assistant that can use Code interpreter when it’s the best tool for the task.
If the user asks to analyze data, perform calculations, transform files, 
or generate charts,
write and run Python code with safe defaults.
Explain what you ran and summarize the output clearly for a non‑technical audience.

Add Inputs:

  • question (Text)

Test ideas:

  • “Simulate compound growth at 8% for 10 years and plot the curve.”

When you select Test, you should see the system take two passes: first it plans, then it generates and executes Python, returning results (and charts) inline.



Now you can start using this prompt tool just like any other tool in your agent!

Troubleshooting

  • Toggle isn’t visible: The prompt’s settings show Code interpreter only when the environment is enabled in PPAC.

  • Blocked by policy: Some tenants restrict code execution. Check with your admin if the PPAC toggle is greyed out.

  • Host differences: In‑context agents that run inside other hosts may have limitations when Code interpreter is on. Test in your target host early.

  • Quotas: Code execution may be subject to usage limits. If runs are throttled, try again later or reduce dataset size.

Notes

  • In Copilot Studio Lite / Agent Builder, you’ll find Code interpreter under Configure → Capabilities as a simple toggle. This post focuses on the full Copilot Studio flow, where the setting lives inside each Prompt.

  • If you build agents with the Agents Toolkit/VS Code, you can also declare CodeInterpreter in the agent manifest (schema v1.2+). That’s a different path but useful for source‑controlled agents.

Wrapping up

That’s the minimal path: enable at PPAC → toggle in the Prompt settings → test with a simple data task. From here, stitch the prompt into your agent’s flow, pass inputs from variables, and add guardrails (size limits, safe defaults).

Hope this helps!

No comments: