chore: import upstream snapshot with attribution
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:25 +08:00
commit db620d33df
5151 changed files with 925932 additions and 0 deletions
@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<InjectIsExternalInitOnLegacy>true</InjectIsExternalInitOnLegacy>
<InjectSharedFoundryAgents>true</InjectSharedFoundryAgents>
<InjectSharedWorkflowsExecution>true</InjectSharedWorkflowsExecution>
<InjectSharedWorkflowsSettings>true</InjectSharedWorkflowsSettings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.Workflows.Declarative\Microsoft.Agents.AI.Workflows.Declarative.csproj" />
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.Workflows.Declarative.Foundry\Microsoft.Agents.AI.Workflows.Declarative.Foundry.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="InputArguments.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
@@ -0,0 +1,97 @@
#
# This workflow demonstrates providing input arguments to an agent.
#
# Example input:
# I'd like to go on vacation.
#
kind: Workflow
trigger:
kind: OnConversationStart
id: workflow_demo
actions:
# Capture the original user message for input to the location-aware agent
- kind: SetVariable
id: set_count_increment
variable: Local.InputMessage
value: =System.LastMessage
# Invoke the triage agent to determine location requirements
- kind: InvokeAzureAgent
id: solicit_input
conversationId: =System.ConversationId
agent:
name: LocationTriageAgent
input:
messages: =Local.ActionMessage
output:
messages: Local.TriageResponse
# Request input from the user based on the triage response
- kind: RequestExternalInput
id: request_requirements
variable: Local.NextInput
# Capture the most recent interaction for evaluation
- kind: SetTextVariable
id: set_status_message
variable: Local.LocationStatusInput
value: |-
AGENT - {MessageText(Local.TriageResponse)}
USER - {MessageText(Local.NextInput)}
# Evaluate the status of the location triage
- kind: InvokeAzureAgent
id: evaluate_location
agent:
name: LocationCaptureAgent
input:
messages: =UserMessage(Local.LocationStatusInput)
output:
responseObject: Local.LocationResponse
# Determine if the location information is complete
- kind: ConditionGroup
id: check_completion
conditions:
- condition: |-
=Local.LocationResponse.is_location_defined = false Or
Local.LocationResponse.is_location_confirmed = false
id: check_done
actions:
# Capture the action message for input to the triage agent
- kind: SetVariable
id: set_next_message
variable: Local.ActionMessage
value: =AgentMessage(Local.LocationResponse.action)
- kind: GotoAction
id: goto_solicit_input
actionId: solicit_input
elseActions:
# Create a new conversation so the prior context does not interfere
- kind: CreateConversation
id: conversation_location
conversationId: Local.LocationConversationId
# Invoke the location-aware agent with the location argument
# and loop until the user types "EXIT"
- kind: InvokeAzureAgent
id: location_response
conversationId: =Local.LocationConversationId
agent:
name: LocationAwareAgent
input:
messages: =Local.InputMessage
arguments:
location: =Local.LocationResponse.place
externalLoop:
when: =Upper(System.LastMessage.Text) <> "EXIT"
output:
autoSend: true
@@ -0,0 +1,151 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Projects;
using Azure.AI.Projects.Agents;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
using Shared.Foundry;
using Shared.Workflows;
namespace Demo.Workflows.Declarative.InputArguments;
/// <summary>
/// Demonstrate a workflow that consumes input arguments to dynamically enhance the agent
/// instructions. Exits the loop when the user enters "exit".
/// </summary>
/// <remarks>
/// See the README.md file in the parent folder (../README.md) for detailed
/// information about the configuration required to run this sample.
/// </remarks>
internal sealed class Program
{
public static async Task Main(string[] args)
{
// Initialize configuration
IConfiguration configuration = Application.InitializeConfig();
Uri foundryEndpoint = new(configuration.GetValue(Application.Settings.FoundryEndpoint));
// Ensure sample agents exist in Foundry.
await CreateAgentAsync(foundryEndpoint, configuration);
// Get input from command line or console
string workflowInput = Application.GetInput(args);
// Create the workflow factory. This class demonstrates how to initialize a
// declarative workflow from a YAML file. Once the workflow is created, it
// can be executed just like any regular workflow.
WorkflowFactory workflowFactory = new("InputArguments.yaml", foundryEndpoint);
// Execute the workflow: The WorkflowRunner demonstrates how to execute
// a workflow, handle the workflow events, and providing external input.
// This also includes the ability to checkpoint workflow state and how to
// resume execution.
WorkflowRunner runner = new();
await runner.ExecuteAsync(workflowFactory.CreateWorkflow, workflowInput);
}
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration)
{
// 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.
AIProjectClient aiProjectClient = new(foundryEndpoint, new DefaultAzureCredential());
await aiProjectClient.CreateAgentAsync(
agentName: "LocationTriageAgent",
agentDefinition: DefineLocationTriageAgent(configuration),
agentDescription: "Chats with the user to solicit a location of interest.");
await aiProjectClient.CreateAgentAsync(
agentName: "LocationCaptureAgent",
agentDefinition: DefineLocationCaptureAgent(configuration),
agentDescription: "Evaluate the status of soliciting the location.");
await aiProjectClient.CreateAgentAsync(
agentName: "LocationAwareAgent",
agentDefinition: DefineLocationAwareAgent(configuration),
agentDescription: "Chats with the user with location awareness.");
}
private static DeclarativeAgentDefinition DefineLocationTriageAgent(IConfiguration configuration) =>
new(configuration.GetValue(Application.Settings.FoundryModel))
{
Instructions =
"""
Your only job is to solicit a location from the user.
Always repeat back the location when addressing the user, except when it is not known.
"""
};
private static DeclarativeAgentDefinition DefineLocationCaptureAgent(IConfiguration configuration) =>
new(configuration.GetValue(Application.Settings.FoundryModel))
{
Instructions =
"""
Request a location from the user. This location could be their own location
or perhaps a location they are interested in.
City level precision is sufficient.
If extrapolating region and country, confirm you have it right.
""",
TextOptions =
new ResponseTextOptions
{
TextFormat =
ResponseTextFormat.CreateJsonSchemaFormat(
"TaskEvaluation",
BinaryData.FromString(
"""
{
"type": "object",
"properties": {
"place": {
"type": "string",
"description": "Captures only your understanding of the location specified by the user without explanation, or 'unknown' if not yet defined."
},
"action": {
"type": "string",
"description": "The instruction for the next action to take regarding the need for additional detail or confirmation."
},
"is_location_defined": {
"type": "boolean",
"description": "True if the user location is understood."
},
"is_location_confirmed": {
"type": "boolean",
"description": "True if the user location is confirmed. An unambiguous location may be implicitly confirmed without explicit user confirmation."
}
},
"required": ["place", "action", "is_location_defined", "is_location_confirmed"],
"additionalProperties": false
}
"""),
jsonSchemaFormatDescription: null,
jsonSchemaIsStrict: true),
}
};
private static DeclarativeAgentDefinition DefineLocationAwareAgent(IConfiguration configuration) =>
new(configuration.GetValue(Application.Settings.FoundryModel))
{
// Parameterized instructions reference the "location" input argument.
Instructions =
"""
Talk to the user about their request.
Their request is related to a specific location: {{location}}.
""",
StructuredInputs =
{
["location"] =
new StructuredInputDefinition
{
IsRequired = false,
DefaultValue = BinaryData.FromString(@"""unknown"""),
Description = "The user's location",
}
}
};
}
@@ -0,0 +1,11 @@
{
"profiles": {
"Default": {
"commandName": "Project"
},
"Vacation": {
"commandName": "Project",
"commandLineArgs": "\"I'd like to go on vacation.\""
}
}
}