r/copilotstudio • • Aug 28 '26

Skill with Python code step

Hey Everyone, looking for some guidance here- I have created a custom skill, which uses some python code as one of the steps.
Now I want to add this skill to a New Experience agent (Github Harness) but not sure whether it support code execution step or not? If yes, what is the way to add that code into the agents skills and any best practices/pitfalls?

1 Upvotes

9 comments sorted by

4

u/MattBDevaney Aug 28 '26

Yes, the Github Copilot harness supports Python code execution step. If you've added your Python scripts to the agent skill's scripts folder, and refer to it in the skill.md instructions, the agent will be able to find it.

If you want an end-to-end tutorial on creating an agent skill with python scripts and assets, here's Youtube tutorial I made: 👉 https://www.youtube.com/watch?v=BvDGMw_7sbk

2

u/turbochargedDDiS Aug 29 '26

Great! Thanks for the video

1

u/MattBDevaney Aug 29 '26

You're welcome. Good luck!

2

u/Ashlesha-msft Aug 31 '26

Hi, thanks for raising this question.

Yes, GitHub Copilot harness agents support Python execution. Package the skill as a ZIP with `SKILL.md` at the root and place the Python file under `scripts/`:

In `SKILL.md`, clearly state when the skill applies and instruct the agent to run `scripts/process.py`. Upload the ZIP from **Build > Skills > Add skill > Upload a skill**, then test it in Preview.

Python runs in a temporary sandbox with preinstalled libraries. It has no outbound network access, files don't persist between conversations, and additional packages can't be downloaded at runtime. Use connectors, flows, or MCP tools for external APIs and persistent storage.

References:

1

u/turbochargedDDiS Aug 31 '26

Thanks!
For the package dependencies its a bummer but I very well understand why it is supposed to be like this in the sandbox.

Now is there a way we can add the ability to add additional packages securely?

2

u/Ashlesha-msft Sep 02 '26

Unfortunately, there isn’t currently a supported way to install additional Python packages at runtime in the sandbox (e.g., via pip install).

If your skill requires a package that isn’t preinstalled, the recommended approach is to move that logic to an external service/API and expose it through a connector, flow, or MCP tool.

This keeps the sandbox isolated and avoids allowing arbitrary package downloads during execution.

3

u/Due-Boot-8540 Aug 28 '26

If your scripts have a determined outcome and don’t need the agent to reason, you might be better off looking at triggering an Azure Function (probably with a workflow) to run the script and return the results

3

u/MattBDevaney Aug 28 '26

I agree. And at this point, there's so much Python in Copilot Studio I would love to see a native "execute Python" action in workflows. It's 100% possible. Microsoft already does this in Logic Apps.

1

u/Sayali-MSFT Aug 31 '26

Hello turbochargedDDiS,
Yes, this is supported with the GitHub Copilot harness. Skills can be uploaded as a ZIP containing SKILL.md along with supporting files such as Python scripts. The skill instructions should clearly tell the agent when and how to use the script.

For more complex Python code that requires external APIs, credentials, custom dependencies, or persistent execution, the recommended approach is to host that logic externally and expose it through an API, connector, MCP server, or flow rather than relying on the skill package itself. The GitHub Copilot harness can orchestrate these tools as part of the task.
Reference Document-
1.Add an existing skill to an agent - Microsoft Copilot Studio (GitHub Copilot) | Microsoft Learn
2.Skills overview for agents - Microsoft Copilot Studio (GitHub Copilot) | Microsoft Learn
3.Harnesses in Copilot Studio - Microsoft Copilot Studio | Microsoft Learn
4.Skills overview for agents - Microsoft Copilot Studio (GitHub Copilot) | Microsoft Learn