mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
This reverts commit c9cd067be6.
This commit is contained in:
@@ -22,9 +22,6 @@ string deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYM
|
||||
var skillsProvider = new FileAgentSkillsProvider(skillPath: Path.Combine(AppContext.BaseDirectory, "skills"));
|
||||
|
||||
// --- Agent Setup ---
|
||||
// WARNING: DefaultAzureCredential is convenient for development but requires careful consideration in production.
|
||||
// In production, consider using a specific credential (e.g., ManagedIdentityCredential) to avoid
|
||||
// latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
|
||||
AIAgent agent = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential())
|
||||
.GetResponsesClient(deploymentName)
|
||||
.AsAIAgent(new ChatClientAgentOptions
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net10.0</TargetFrameworks>
|
||||
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<NoWarn>$(NoWarn);MAAI001</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.AI.OpenAI" />
|
||||
<PackageReference Include="Azure.Identity" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.OpenAI\Microsoft.Agents.AI.OpenAI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copy skills directory to output -->
|
||||
<ItemGroup>
|
||||
<None Include="skills\**\*.*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
// This sample demonstrates how to use Agent Skills with script execution via the hosted code interpreter.
|
||||
// When FileAgentSkillScriptExecutor.HostedCodeInterpreter() is configured, the agent can load and execute scripts
|
||||
// from skill resources using the LLM provider's built-in code interpreter.
|
||||
//
|
||||
// This sample includes the password-generator skill:
|
||||
// - A Python script for generating secure passwords
|
||||
|
||||
using Azure.AI.OpenAI;
|
||||
using Azure.Identity;
|
||||
using Microsoft.Agents.AI;
|
||||
using OpenAI.Responses;
|
||||
|
||||
// --- Configuration ---
|
||||
string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
|
||||
?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
|
||||
string deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
|
||||
|
||||
// --- Skills Provider with Script Execution ---
|
||||
// Discovers skills and enables script execution via the hosted code interpreter
|
||||
var skillsProvider = new FileAgentSkillsProvider(
|
||||
skillPath: Path.Combine(AppContext.BaseDirectory, "skills"),
|
||||
options: new FileAgentSkillsProviderOptions
|
||||
{
|
||||
ScriptExecutor = FileAgentSkillScriptExecutor.HostedCodeInterpreter()
|
||||
});
|
||||
|
||||
// --- Agent Setup ---
|
||||
// WARNING: DefaultAzureCredential is convenient for development but requires careful consideration in production.
|
||||
// In production, consider using a specific credential (e.g., ManagedIdentityCredential) to avoid
|
||||
// latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
|
||||
AIAgent agent = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential())
|
||||
.GetResponsesClient(deploymentName)
|
||||
.AsAIAgent(new ChatClientAgentOptions
|
||||
{
|
||||
Name = "SkillsAgent",
|
||||
ChatOptions = new()
|
||||
{
|
||||
Instructions = "You are a helpful assistant that can generate secure passwords.",
|
||||
},
|
||||
AIContextProviders = [skillsProvider],
|
||||
});
|
||||
|
||||
// --- Example: Password generation with script execution ---
|
||||
Console.WriteLine("Example: Generating a password with a skill script");
|
||||
Console.WriteLine("---------------------------------------------------");
|
||||
AgentResponse response = await agent.RunAsync("Generate a secure password for my database account.");
|
||||
Console.WriteLine($"Agent: {response.Text}\n");
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
# 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](../Agent_Step01_BasicSkills/), 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:
|
||||
|
||||
```csharp
|
||||
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 script
|
||||
- `references/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
|
||||
1. Set environment variables:
|
||||
```bash
|
||||
export AZURE_OPENAI_ENDPOINT="https://your-endpoint.openai.azure.com/"
|
||||
export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini"
|
||||
```
|
||||
|
||||
2. Run the sample:
|
||||
```bash
|
||||
dotnet run
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
The sample asks the agent to generate a secure password. The agent:
|
||||
1. Loads the password-generator skill
|
||||
2. Reads the `generate.py` script via `read_skill_resource`
|
||||
3. Executes the script using the code interpreter with appropriate parameters
|
||||
4. Returns the generated password
|
||||
|
||||
## Learn More
|
||||
|
||||
- [Agent Skills Specification](https://agentskills.io/)
|
||||
- [Step01: Basic Skills](../Agent_Step01_BasicSkills/) — Skills without script execution
|
||||
- [Microsoft Agent Framework Documentation](../../../../../docs/)
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
---
|
||||
name: password-generator
|
||||
description: Generate secure passwords using a Python script. Use when asked to create passwords or credentials.
|
||||
---
|
||||
|
||||
# Password Generator
|
||||
|
||||
This skill generates secure passwords using a Python script.
|
||||
|
||||
## Usage
|
||||
|
||||
When the user requests a password:
|
||||
1. First, review `references/PASSWORD_GUIDELINES.md` to determine the recommended password length and character sets for the user's use case
|
||||
2. Load `scripts/generate.py` and adjust its parameters (length, character set) based on the guidelines and user's requirements
|
||||
3. Execute the script
|
||||
4. Present the generated password clearly
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
# Password Generation Guidelines
|
||||
|
||||
## General Rules
|
||||
|
||||
- Never reuse passwords across services.
|
||||
- Always use cryptographically secure randomness (e.g., `random.SystemRandom()`).
|
||||
- Avoid dictionary words, keyboard patterns, and personal information.
|
||||
|
||||
## Recommended Settings by Use Case
|
||||
|
||||
| Use Case | Min Length | Character Set | Example |
|
||||
|-----------------------|-----------|----------------------------------------|--------------------------|
|
||||
| Web account | 16 | Upper + lower + digits + symbols | `G7!kQp@2xM#nW9$z` |
|
||||
| Database credential | 24 | Upper + lower + digits + symbols | `aR3$vK8!mN2@pQ7&xL5#wY` |
|
||||
| Wi-Fi / network key | 20 | Upper + lower + digits + symbols | `Ht4&jL9!rP2#mK7@xQ` |
|
||||
| API key / token | 32 | Upper + lower + digits (no symbols) | `k8Rm3xQ7nW2pL9vT4jH6yA` |
|
||||
| Encryption passphrase | 32 | Upper + lower + digits + symbols | `Xp4!kR8@mN2#vQ7&jL9$wT` |
|
||||
|
||||
## Symbol Sets
|
||||
|
||||
- **Standard symbols**: `!@#$%^&*()-_=+`
|
||||
- **Extended symbols**: `~`{}[]|;:'",.<>?/\`
|
||||
- **Safe symbols** (URL/shell-safe): `!@#$&*-_=+`
|
||||
- If the target system restricts symbols, use only the **safe** set.
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
# Password generator script
|
||||
# Usage: Adjust 'length' as needed, then run
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
length = 16 # desired length
|
||||
|
||||
pool = string.ascii_lowercase + string.ascii_uppercase + string.digits + string.punctuation
|
||||
password = "".join(random.SystemRandom().choice(pool) for _ in range(length))
|
||||
print(f"Generated password ({length} chars): {password}")
|
||||
@@ -5,4 +5,3 @@ Samples demonstrating Agent Skills capabilities.
|
||||
| Sample | Description |
|
||||
|--------|-------------|
|
||||
| [Agent_Step01_BasicSkills](Agent_Step01_BasicSkills/) | Using Agent Skills with a ChatClientAgent, including progressive disclosure and skill resources |
|
||||
| [Agent_Step02_ScriptExecutionWithCodeInterpreter](Agent_Step02_ScriptExecutionWithCodeInterpreter/) | Using Agent Skills with script execution via the hosted code interpreter |
|
||||
|
||||
Reference in New Issue
Block a user