-
Notifications
You must be signed in to change notification settings - Fork 817
.NET: Sync samples of hosted agents with the ones in foundry-samples repo #2454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SergeyMenshykh
wants to merge
8
commits into
microsoft:main
Choose a base branch
from
SergeyMenshykh:sync-samples-for-hosted-agents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+215
−58
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
50866be
sync samples of hosted agents with the ones in foundry-samples repo
SergeyMenshykh e352e70
Merge branch 'main' into sync-samples-for-hosted-agents
SergeyMenshykh 586db5c
Update the disclaimer
SergeyMenshykh b0df457
Merge branch 'sync-samples-for-hosted-agents' of https://github.com/S…
SergeyMenshykh 7b14425
Update dotnet/samples/HostedAgents/AgentsInWorkflows/README.md
SergeyMenshykh 1e19521
Update dotnet/samples/HostedAgents/AgentsInWorkflows/README.md
SergeyMenshykh 13d224e
Update dotnet/samples/HostedAgents/AgentWithTextSearchRag/README.md
SergeyMenshykh f378661
Update dotnet/samples/HostedAgents/AgentWithHostedMCP/README.md
SergeyMenshykh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,88 @@ | ||
| **IMPORTANT!** All samples and other resources made available in this GitHub repository ("samples") are designed to assist in accelerating development of agents, solutions, and agent workflows for various scenarios. Review all provided resources and carefully test output behavior in the context of your use case. AI responses may be inaccurate and AI actions should be monitored with human oversight. Learn more in the transparency documents for [Agent Service](https://learn.microsoft.com/en-us/azure/ai-foundry/responsible-ai/agents/transparency-note) and [Agent Framework](https://github.com/microsoft/agent-framework/blob/main/TRANSPARENCY_FAQ.md). | ||
|
|
||
| Agents, solutions, or other output you create may be subject to legal and regulatory requirements, may require licenses, or may not be suitable for all industries, scenarios, or use cases. By using any sample, you are acknowledging that any output created using those samples are solely your responsibility, and that you will comply with all applicable laws, regulations, and relevant safety standards, terms of service, and codes of conduct. | ||
|
|
||
| Third-party samples contained in this folder are subject to their own designated terms, and they have not been tested or verified by Microsoft or its affiliates. | ||
|
|
||
| Microsoft has no responsibility to you or others with respect to any of these samples or any resulting output. | ||
|
|
||
| # What this sample demonstrates | ||
|
|
||
| This sample demonstrates the use of AI agents as executors within a workflow. | ||
| This sample demonstrates how to use AI agents as executors within a workflow, hosted using | ||
| [Azure AI AgentServer SDK](https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.agentserver.agentframework-readme) and | ||
| deploy it to Microsoft Foundry using the Azure Developer CLI [ai agent](https://aka.ms/azdaiagent/docs) extension. | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Agents in Workflows | ||
|
|
||
| This sample demonstrates the integration of AI agents within a workflow pipeline. The workflow operates as follows: | ||
|
|
||
| 1. **French Agent** - Receives input text and translates it to French | ||
| 2. **Spanish Agent** - Takes the French translation and translates it to Spanish | ||
| 3. **English Agent** - Takes the Spanish translation and translates it back to English | ||
|
|
||
| The agents are connected sequentially in a workflow, creating a translation chain that demonstrates: | ||
| - How AI-powered agents can be seamlessly integrated into workflow pipelines | ||
| - Sequential execution patterns where each agent's output becomes the next agent's input | ||
| - Composable agent architectures for multi-step processing | ||
|
|
||
| This workflow uses three translation agents: | ||
| 1. French Agent - translates input text to French | ||
| 2. Spanish Agent - translates French text to Spanish | ||
| 3. English Agent - translates Spanish text back to English | ||
| ### Agent Hosting | ||
|
|
||
| The agents are connected sequentially, creating a translation chain that demonstrates how AI-powered components can be seamlessly integrated into workflow pipelines. | ||
| The agent workflow is hosted using the [Azure AI AgentServer SDK](https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.agentserver.agentframework-readme), | ||
| which provisions a REST API endpoint compatible with the OpenAI Responses protocol. This allows interaction with the agent workflow using OpenAI Responses compatible clients. | ||
|
|
||
| ## Prerequisites | ||
| ### Agent Deployment | ||
|
|
||
| Before you begin, ensure you have the following prerequisites: | ||
| The hosted agent workflow can be seamlessly deployed to Microsoft Foundry using the Azure Developer CLI [ai agent](https://aka.ms/azdaiagent/docs) extension. | ||
| The extension builds a container image for the agent, deploys it to Azure Container Instances (ACI), and creates a hosted agent version and deployment on Foundry Agent Service. | ||
|
|
||
| - .NET 10 SDK or later | ||
| - Azure OpenAI service endpoint and deployment configured | ||
| - Azure CLI installed and authenticated (for Azure credential authentication) | ||
| ## Running the Agent Locally | ||
|
|
||
| **Note**: This demo uses Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). | ||
| ### Prerequisites | ||
|
|
||
| Before running this sample, ensure you have: | ||
|
|
||
| 1. An Azure OpenAI endpoint configured | ||
| 2. A deployment of a chat model (e.g., `gpt-4o-mini`) | ||
| 3. Azure CLI installed and authenticated (`az login`) | ||
| 4. .NET 9.0 SDK or later installed | ||
SergeyMenshykh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Environment Variables | ||
|
|
||
| Set the following environment variables: | ||
|
|
||
| - `AZURE_OPENAI_ENDPOINT` - Your Azure OpenAI endpoint URL (required) | ||
| - `AZURE_OPENAI_DEPLOYMENT_NAME` - The deployment name for your chat model (optional, defaults to `gpt-4o-mini`) | ||
|
|
||
| **PowerShell:** | ||
| ```powershell | ||
| # Replace with your Azure OpenAI endpoint | ||
| $env:AZURE_OPENAI_ENDPOINT="https://your-openai-resource.openai.azure.com/" | ||
|
|
||
| # Optional, defaults to gpt-4o-mini | ||
| $env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" | ||
| ``` | ||
|
|
||
| ### Running the Sample | ||
|
|
||
| To run the agent, execute the following command in your terminal: | ||
|
|
||
| ```powershell | ||
| $env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" # Replace with your Azure OpenAI resource endpoint | ||
| $env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini | ||
| dotnet run | ||
| ``` | ||
|
|
||
| This will start the hosted agent workflow locally on `http://localhost:8080/`. | ||
|
|
||
| ### Interacting with the Agent | ||
|
|
||
| You can interact with the agent workflow using: | ||
|
|
||
| - The `run-requests.http` file in this directory to test and prompt the agent | ||
| - Any OpenAI Responses compatible client by sending requests to `http://localhost:8080/` | ||
|
|
||
| Try providing text in English to see it translated through the workflow chain (English ? French ? Spanish ? English). | ||
SergeyMenshykh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Deploying the Agent to Microsoft Foundry | ||
|
|
||
| To deploy your agent to Microsoft Foundry, follow the comprehensive deployment guide at https://aka.ms/azdaiagent/docs | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.