mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
c9cd067be6
* support script execution by code interpretor * improve the instruction prompt * Add DefaultAzureCredential production warning to AgentSkills samples Add the standard three-line WARNING comment about DefaultAzureCredential production considerations to both AgentSkills sample Program.cs files, matching the convention used in all other GettingStarted/Agents samples. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address pr review comments * address feedback * rename Skill* types to FileAgentSkill* prefix for consistency - Rename SkillFrontmatter -> FileAgentSkillFrontmatter - Rename SkillScriptExecutor -> FileAgentSkillScriptExecutor - Add FileAgentSkillScriptExecutionContext and FileAgentSkillScriptExecutionDetails - Update sample, provider, loader, and tests accordingly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * reorder usings * use set for props initialization instead of init * rename HostedCodeInterpreterSkillScriptExecutor --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c9cd067be6
·
2026-02-26 13:17:21 +00:00
History
Script Execution with Code Interpreter
This sample demonstrates how to use Agent Skills with script execution via the hosted code interpreter.
What's Different from Step01?
In the basic skills sample, skills only provide instructions and resources as text. This sample adds script execution — the agent can load Python scripts from skill resources and execute them using the LLM provider's built-in code interpreter.
This is enabled by configuring FileAgentSkillScriptExecutor.HostedCodeInterpreter() on the skills provider options:
var skillsProvider = new FileAgentSkillsProvider(
skillPath: Path.Combine(AppContext.BaseDirectory, "skills"),
options: new FileAgentSkillsProviderOptions
{
ScriptExecutor = FileAgentSkillScriptExecutor.HostedCodeInterpreter()
});
Skills Included
password-generator
Generates secure passwords using a Python script with configurable length and complexity.
scripts/generate.py— Password generation scriptreferences/PASSWORD_GUIDELINES.md— Recommended length and symbol sets by use case
Project Structure
Agent_Step02_ScriptExecutionWithCodeInterpreter/
├── Program.cs
├── Agent_Step02_ScriptExecutionWithCodeInterpreter.csproj
└── skills/
└── password-generator/
├── SKILL.md
├── scripts/
│ └── generate.py
└── references/
└── PASSWORD_GUIDELINES.md
Running the Sample
Prerequisites
- .NET 10.0 SDK
- Azure OpenAI endpoint with a deployed model that supports code interpreter
Setup
-
Set environment variables:
export AZURE_OPENAI_ENDPOINT="https://your-endpoint.openai.azure.com/" export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" -
Run the sample:
dotnet run
Example
The sample asks the agent to generate a secure password. The agent:
- Loads the password-generator skill
- Reads the
generate.pyscript viaread_skill_resource - Executes the script using the code interpreter with appropriate parameters
- Returns the generated password
Learn More
- Agent Skills Specification
- Step01: Basic Skills — Skills without script execution
- Microsoft Agent Framework Documentation