Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This article is prerelease documentation and is subject to change.]
By using code interpreter, Copilot Studio agents can generate and run Python code when they need to respond to user prompts. Code interpreter supports tasks such as statistical analysis, table joins, forecasting, and chart generation. These tasks work with structured files like CSV and Excel.
Important
This article contains Microsoft Copilot Studio preview documentation and is subject to change.
Preview features aren't meant for production use and may have restricted functionality. These features are available before an official release so that you can get early access and provide feedback.
If you're building a production-ready agent, see Microsoft Copilot Studio Overview.
The value proposition of using code interpreter to analyze structured data files is:
- By using deterministic, reproducible computation, you can unlock trustworthy analysis inside agents instead of relying on large language model's inherent math and inference capabilities to answer analytical questions.
- Lower the skill barrier for advanced analytics by letting users ask analytic questions in natural language.
- Generate tables and visualizations of results programmatically that users can see, download, and reuse.
Copilot Studio agents can use code interpreter to analyze structured files that are provided to the agent by the following two ways:
- As an end-user, when you upload structured files while chatting with the agent.
- As a maker, when you add SharePoint Documents library as a knowledge source, which in turn contains the structured files.
Requirements
Licensing: Microsoft Copilot Studio billing and licensing. Code generation and execution count as text and generative AI tools (premium) features.
Supported regions: Available for all public clouds. Sovereign clouds aren't currently supported.
Extensively tested scenarios
Microsoft has tested the following scenarios extensively with a high level of confidence.
Note
- If your scenario isn't among the scenarios listed in the tables, it might still work. The scenarios listed in the below tables reflect the group of scenarios that Microsoft tested extensively based on anticipated customer use.
- The size limit for each file that can be analyzed by code interpreter, irrespective of file type, is 16 MB. You can upload a maximum of 10 files.
Scenarios for Excel (.xlsx) files
| Category | Scenario description | Example 1 | Example 2 | Example 3 |
|---|---|---|---|---|
| Lookup - single sheet | Retrieve a specific value, label, or record from a single sheet of an Excel file. No cross-row computation needed. The answer exists as a direct cell/row lookup. Covers numeric values, text attributes (names, roles, categories), and timestamps. | Which fixtures include a side netting a minimum of three goals? | What was the Free cash flow in Q4 2024? | Which segment do Wholesale fuels belong to starting Q1 2024? |
Scenarios for .csv files
| Category | Scenario description | Example 1 | Example 2 | Example 3 |
|---|---|---|---|---|
| Lookup - single file | Retrieve a specific value, attribute, or record from a single CSV file. Covers entity lookups (contacts, airports, wind projects), point-in-time value retrieval, and small table lookups. No cross-row aggregation required. | Who is the developer of the Sunrise Wind project? | How many motorcycles were registered in Tennessee in 1970? | Who owns the Horseshoe Landings airport in Keenesburg, CO? |
| Aggregate - single file | Compute totals, counts, differences, group-by summaries, or ranked lookups within a single CSV file. Covers financial aggregations, conditional counts, ranked retrievals (max/min), and group-level summaries returned as numbers, text, or tables. | What was the total royalty value of onshore oil sales in 2019? | How many more trucks were registered in California in 2020 than in 2010? | What is the total sales revenue generated by each region in January 2025? |
| Lookup - multiple files | Join or cross-reference multiple CSV files to retrieve a specific value or list (for example, looking up inventory by matching part names across a parts list, inventory, and price list; or querying emissions data by joining sector names to a main emissions file). | How many water jet cutters are available in the East warehouse? | What is the educational price of a 10x24 lathe? | How many 3/8" drill bits are in stock in the East warehouse? |
| Aggregate - multiple files | Aggregate or compare data spread across multiple CSV files (for example, summing employee hours across monthly CSVs for a quarterly total, counting deals across annual CSV exports, or ranking sectors by emissions across joined files). | How many total work hours were recorded in Q3? | What was the earliest time Chris clocked in during July? | Which sector produced the most CO2 in 2020? |
Use code interpreter for analysis of a user-uploaded structured data file
In Copilot Studio, select Settings > Generative AI. Under File processing capabilities, turn on the File uploads toggle.
Under File processing capabilities, turn on the Code interpreter toggle.
Select Save.
In the test pane, write a query that requires the agent to perform a calculation using data from a structured data file. Attach the data file to the prompt.
Use code interpreter for analysis of a structured data file as a Sharepoint knowledge source
If your agent doesn't already have a SharePoint structured data file as a knowledge source, add this SharePoint file as a knowledge source.
In Copilot Studio, select Settings > Generative AI. Under File processing capabilities, turn on the Code interpreter toggle.
Under Search, turn on the Tenant graph grounding with semantic search toggle.
Select Save.
If you added a SharePoint file following instructions in the first step, publish your agent.
Test your agent by giving it a query that requires the agent to do a computation in order to answer.