Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
0b1ed03
Add Azure AI Foundry Responses hosting adapter
Mar 31, 2026
69597d7
Bump System.ClientModel to 1.10.0 for Azure.Core 1.52.0 compat
Apr 1, 2026
52cc4a9
Clean up tests and sample formatting
Apr 2, 2026
59ad429
Update Azure.AI.AgentServer packages to 1.0.0-alpha.20260401.5
Apr 2, 2026
bb7082d
Add hosted package version suffix (0.9.0-hosted) to distinguish from …
Apr 2, 2026
a1c19b9
Move Foundry Responses hosting into Microsoft.Agents.AI.Foundry package
Apr 2, 2026
af9807b
Bump package version to 0.9.0-hosted.260402.2
Apr 2, 2026
5ba8521
Bump OpenTelemetry packages to fix NU1109 downgrade errors
Apr 2, 2026
3b03c6d
Fix CA1873: guard LogWarning with IsEnabled check
Apr 2, 2026
21dc531
Fix model override bug and add client REPL sample
Apr 3, 2026
eb67379
Catch agent errors and emit response.failed with real error message
Apr 3, 2026
23db956
Renaming and merging hosting extensions. (#5091)
alliscode Apr 3, 2026
53dd990
Address breaking changes in 260408
rogerbarreto Apr 9, 2026
176b8f9
Bump hosted internal package version
rogerbarreto Apr 9, 2026
fed3c06
Add UserAgent middleware tests for Foundry hosting
rogerbarreto Apr 9, 2026
7407c0a
Hosting Samples update
rogerbarreto Apr 11, 2026
4ab4373
Hosting Samples update
rogerbarreto Apr 11, 2026
026f71a
Hosting Samples update
rogerbarreto Apr 11, 2026
eb7f861
Hosting Samples update
rogerbarreto Apr 11, 2026
a82c1ed
ChatClientAgent working
rogerbarreto Apr 11, 2026
fcc9682
Adding SessionStorage and SessionManagement, improving samples to ali…
rogerbarreto Apr 11, 2026
4895ad7
Using updates
rogerbarreto Apr 13, 2026
9e842e1
Update chat client agent for contributor and devs
rogerbarreto Apr 13, 2026
340ec82
Foundry Agent Hosting
rogerbarreto Apr 13, 2026
ad62560
Address text rag sample working
rogerbarreto Apr 13, 2026
d02cee5
Version bump
rogerbarreto Apr 13, 2026
4b9d848
Adding LocalTools + Workflow samples
rogerbarreto Apr 13, 2026
1584879
Removing extra using samples
rogerbarreto Apr 13, 2026
5b16684
Add Hosted-McpTools sample with dual MCP pattern
rogerbarreto Apr 15, 2026
548dfb1
.NET: Bump Azure.AI.AgentServer packages to 1.0.0-beta.1/beta.21 and …
alliscode Apr 15, 2026
12251b1
Add Azure AI Foundry Responses hosting adapter
Mar 31, 2026
e5c1203
Bump System.ClientModel to 1.10.0 for Azure.Core 1.52.0 compat
Apr 1, 2026
15e36ef
Clean up tests and sample formatting
Apr 2, 2026
5368e53
Update Azure.AI.AgentServer packages to 1.0.0-alpha.20260401.5
Apr 2, 2026
4dd3a30
Add hosted package version suffix (0.9.0-hosted) to distinguish from …
Apr 2, 2026
838fd7f
Move Foundry Responses hosting into Microsoft.Agents.AI.Foundry package
Apr 2, 2026
4a2e255
Bump package version to 0.9.0-hosted.260402.2
Apr 2, 2026
226abeb
Bump OpenTelemetry packages to fix NU1109 downgrade errors
Apr 2, 2026
eccdcff
Fix CA1873: guard LogWarning with IsEnabled check
Apr 2, 2026
afce566
Fix model override bug and add client REPL sample
Apr 3, 2026
a25502b
Catch agent errors and emit response.failed with real error message
Apr 3, 2026
6e834fc
Renaming and merging hosting extensions. (#5091)
alliscode Apr 3, 2026
34eeea1
Address breaking changes in 260408
rogerbarreto Apr 9, 2026
cf4a3f6
Bump hosted internal package version
rogerbarreto Apr 9, 2026
3a26179
Add UserAgent middleware tests for Foundry hosting
rogerbarreto Apr 9, 2026
d0fc749
Hosting Samples update
rogerbarreto Apr 11, 2026
bf779f2
Hosting Samples update
rogerbarreto Apr 11, 2026
3984ef4
Hosting Samples update
rogerbarreto Apr 11, 2026
3ef5436
Hosting Samples update
rogerbarreto Apr 11, 2026
990330e
ChatClientAgent working
rogerbarreto Apr 11, 2026
ac6a0e3
Adding SessionStorage and SessionManagement, improving samples to ali…
rogerbarreto Apr 11, 2026
a451904
Using updates
rogerbarreto Apr 13, 2026
9e820aa
Update chat client agent for contributor and devs
rogerbarreto Apr 13, 2026
ebb3483
Foundry Agent Hosting
rogerbarreto Apr 13, 2026
28f3d17
Address text rag sample working
rogerbarreto Apr 13, 2026
0949260
Version bump
rogerbarreto Apr 13, 2026
e70f206
Adding LocalTools + Workflow samples
rogerbarreto Apr 13, 2026
8b49a0a
Removing extra using samples
rogerbarreto Apr 13, 2026
930d477
Add Hosted-McpTools sample with dual MCP pattern
rogerbarreto Apr 15, 2026
4739d1e
Bump Azure.AI.AgentServer packages to 1.0.0-beta.1/beta.21 and fix br…
Apr 15, 2026
5af3d47
Fixing small issues.
Apr 15, 2026
e751779
Fix IDE0009: add 'this' qualification in DevTemporaryTokenCredential
Apr 16, 2026
c1ea834
Fix IDE0009: add 'this' qualification in all HostedAgentsV2 samples
Apr 16, 2026
8d30cad
Fix CHARSET: add UTF-8 BOM to Hosted-LocalTools and Hosted-Workflows
Apr 16, 2026
bc303d8
Fix dotnet format: add Async suffix to test methods (IDE1006), fix en…
Apr 16, 2026
93306f5
Register AgentSessionStore in test DI setups
Apr 16, 2026
53fec2a
Add Invocations protocol samples (hosted echo agent + client) (#5278)
rogerbarreto Apr 16, 2026
030ef3a
Merge branch 'feature/responses-hosting' of https://github.com/micros…
rogerbarreto Apr 16, 2026
d49d546
Restructure FoundryHostedAgents samples into invocations/ and responses/
rogerbarreto Apr 16, 2026
98d3a81
Remove launchSettings, use .env for port configuration
rogerbarreto Apr 16, 2026
10077bd
Use placeholder for AGENT_NAME in Hosted-FoundryAgent .env.example
rogerbarreto Apr 16, 2026
e6dfdd4
Move FoundryResponsesHosting to responses/Hosted-WorkflowHandoff, use…
rogerbarreto Apr 16, 2026
77529dc
Rename Hosted-Workflows to Hosted-Workflow-Simple, Hosted-WorkflowHan…
rogerbarreto Apr 16, 2026
7c9ed7f
Remove FoundryResponsesRepl and empty FoundryResponsesHosting directory
rogerbarreto Apr 16, 2026
518e90e
Add Dockerfiles, README, agent yamls and bearer token support to Host…
rogerbarreto Apr 16, 2026
8f5a6ec
Fix AgentFrameworkResponseHandlerTests: implement session methods in …
rogerbarreto Apr 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ celerybeat.pid
.venv
env/
venv/

# Foundry agent CLI (contains secrets, auto-generated)
.foundry-agent.json
.foundry-agent-build.log
ENV/
env.bak/
venv.bak/
Expand Down
9 changes: 8 additions & 1 deletion dotnet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,11 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml

# Foundry agent CLI config (contains secrets, auto-generated)
.foundry-agent.json
.foundry-agent-build.log

# Pre-published output for Docker builds
out/
27 changes: 16 additions & 11 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
<PackageVersion Include="Aspire.Microsoft.Azure.Cosmos" Version="$(AspireAppHostSdkVersion)" />
<PackageVersion Include="CommunityToolkit.Aspire.OllamaSharp" Version="13.0.0" />
<!-- Azure.* -->
<PackageVersion Include="Azure.AI.AgentServer.Core" Version="1.0.0-beta.21" />
<PackageVersion Include="Azure.AI.AgentServer.Invocations" Version="1.0.0-beta.1" />
<PackageVersion Include="Azure.AI.AgentServer.Responses" Version="1.0.0-beta.1" />
<PackageVersion Include="Azure.AI.Projects" Version="2.0.0" />
<PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.10" />
<PackageVersion Include="Azure.AI.OpenAI" Version="2.9.0-beta.1" />
<PackageVersion Include="Azure.Identity" Version="1.20.0" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.4.0" />
<PackageVersion Include="Azure.Core" Version="1.53.0" />
<PackageVersion Include="Azure.Identity" Version="1.21.0" />
<PackageVersion Include="DotNetEnv" Version="3.1.1" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.5.0" />
<!-- Google Gemini -->
<PackageVersion Include="Google.GenAI" Version="1.6.0" />
<PackageVersion Include="Mscc.GenerativeAI.Microsoft" Version="2.9.3" />
Expand All @@ -48,15 +53,15 @@
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
<PackageVersion Include="System.Net.Security" Version="4.3.2" />
<!-- OpenTelemetry -->
<PackageVersion Include="OpenTelemetry" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Api" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.13.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.13.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.13.0" />
<PackageVersion Include="OpenTelemetry" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Api" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.14.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.14.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.14.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.14.0" />
<!-- Microsoft.AspNetCore.* -->
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
Expand Down
56 changes: 39 additions & 17 deletions dotnet/agent-framework-dotnet.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Solution>
<Solution>
<Configurations>
<BuildType Name="Debug" />
<BuildType Name="Publish" />
Expand Down Expand Up @@ -260,7 +260,41 @@
<Project Path="samples/03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/06_MixedWorkflowAgentsAndExecutors.csproj" />
<Project Path="samples/03-workflows/_StartHere/07_WriterCriticWorkflow/07_WriterCriticWorkflow.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/" />
<Folder Name="/Samples/04-hosting/">
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/" />
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/invocations/" />
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/invocations/Hosted-Invocations-EchoAgent/">
<Project Path="samples/04-hosting/FoundryHostedAgents/invocations/Hosted-Invocations-EchoAgent/Hosted-Invocations-EchoAgent.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/invocations/Using-Samples/">
<Project Path="samples/04-hosting/FoundryHostedAgents/invocations/Using-Samples/SimpleInvocationsAgent/SimpleInvocationsAgent.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/" />
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/HostedChatClientAgent.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/HostedFoundryAgent.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/HostedLocalTools.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/HostedMcpTools.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/HostedTextRag.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/HostedWorkflowSimple.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/SimpleAgent.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/">
<Project Path="samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/HostedWorkflowHandoff.csproj" />
</Folder>
<Folder Name="/Samples/04-hosting/DurableAgents/" />
<Folder Name="/Samples/04-hosting/DurableAgents/AzureFunctions/">
<File Path="samples/04-hosting/DurableAgents/AzureFunctions/.editorconfig" />
Expand Down Expand Up @@ -310,15 +344,6 @@
<Project Path="samples/05-end-to-end/AGUIClientServer/AGUIDojoServer/AGUIDojoServer.csproj" />
<Project Path="samples/05-end-to-end/AGUIClientServer/AGUIServer/AGUIServer.csproj" />
</Folder>
<Folder Name="/Samples/05-end-to-end/HostedAgents/">
<Project Path="samples/05-end-to-end/HostedAgents/AgentsInWorkflows/AgentsInWorkflows.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/AgentThreadAndHITL.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/AgentWithLocalTools/AgentWithLocalTools.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/FoundryMultiAgent/FoundryMultiAgent.csproj" />
<Project Path="samples/05-end-to-end/HostedAgents/FoundrySingleAgent/FoundrySingleAgent.csproj" />
</Folder>
<Folder Name="/Samples/05-end-to-end/AspNetAgentAuthorization/">
<File Path="samples/05-end-to-end/AspNetAgentAuthorization/docker-compose.yml" />
<File Path="samples/05-end-to-end/AspNetAgentAuthorization/README.md" />
Expand Down Expand Up @@ -480,13 +505,12 @@
<Project Path="src/Microsoft.Agents.AI.AGUI/Microsoft.Agents.AI.AGUI.csproj" />
<Project Path="src/Microsoft.Agents.AI.Anthropic/Microsoft.Agents.AI.Anthropic.csproj" />
<Project Path="src/Microsoft.Agents.AI.AzureAI.Persistent/Microsoft.Agents.AI.AzureAI.Persistent.csproj" />
<Project Path="src/Microsoft.Agents.AI.Foundry/Microsoft.Agents.AI.Foundry.csproj" />
<Project Path="src/Microsoft.Agents.AI.CopilotStudio/Microsoft.Agents.AI.CopilotStudio.csproj" />
<Project Path="src/Microsoft.Agents.AI.CosmosNoSql/Microsoft.Agents.AI.CosmosNoSql.csproj" />
<Project Path="src/Microsoft.Agents.AI.Declarative/Microsoft.Agents.AI.Declarative.csproj" />
<Project Path="src/Microsoft.Agents.AI.DevUI/Microsoft.Agents.AI.DevUI.csproj" />
<Project Path="src/Microsoft.Agents.AI.DurableTask/Microsoft.Agents.AI.DurableTask.csproj" />

<Project Path="src/Microsoft.Agents.AI.Foundry/Microsoft.Agents.AI.Foundry.csproj" />
<Project Path="src/Microsoft.Agents.AI.GitHub.Copilot/Microsoft.Agents.AI.GitHub.Copilot.csproj" />
<Project Path="src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/Microsoft.Agents.AI.Hosting.A2A.AspNetCore.csproj" />
<Project Path="src/Microsoft.Agents.AI.Hosting.A2A/Microsoft.Agents.AI.Hosting.A2A.csproj" />
Expand All @@ -508,11 +532,10 @@
<Folder Name="/Tests/IntegrationTests/">
<Project Path="tests/AgentConformance.IntegrationTests/AgentConformance.IntegrationTests.csproj" />
<Project Path="tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletion.IntegrationTests.csproj" />
<Project Path="tests/Foundry.IntegrationTests/Foundry.IntegrationTests.csproj" />
<Project Path="tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistent.IntegrationTests.csproj" />
<Project Path="tests/CopilotStudio.IntegrationTests/CopilotStudio.IntegrationTests.csproj" />
<Project Path="tests/Foundry.IntegrationTests/Foundry.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/Microsoft.Agents.AI.DurableTask.IntegrationTests.csproj" />

<Project Path="tests/Microsoft.Agents.AI.GitHub.Copilot.IntegrationTests/Microsoft.Agents.AI.GitHub.Copilot.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests.csproj" />
Expand All @@ -528,12 +551,11 @@
<Project Path="tests/Microsoft.Agents.AI.AGUI.UnitTests/Microsoft.Agents.AI.AGUI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Anthropic.UnitTests/Microsoft.Agents.AI.Anthropic.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/Microsoft.Agents.AI.CosmosNoSql.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Declarative.UnitTests/Microsoft.Agents.AI.Declarative.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.DevUI.UnitTests/Microsoft.Agents.AI.DevUI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.DurableTask.UnitTests/Microsoft.Agents.AI.DurableTask.UnitTests.csproj" />

<Project Path="tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.A2A.UnitTests/Microsoft.Agents.AI.Hosting.A2A.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj" />
Expand Down
1 change: 1 addition & 0 deletions dotnet/samples/04-hosting/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ASPNETCORE_URLS=http://+:8088
ASPNETCORE_ENVIRONMENT=Development
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official .NET 10.0 ASP.NET runtime as a parent image
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o /app/publish

# Final stage
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
EXPOSE 8088
ENV ASPNETCORE_URLS=http://+:8088
ENTRYPOINT ["dotnet", "HostedInvocationsEchoAgent.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dockerfile for contributors building from the agent-framework repository source.
#
# This project uses ProjectReference to the local Microsoft.Agents.AI.Abstractions source,
# which means a standard multi-stage Docker build cannot resolve dependencies outside
# this folder. Instead, pre-publish the app targeting the container runtime and copy
# the output into the container:
#
# dotnet publish -c Debug -f net10.0 -r linux-musl-x64 --self-contained false -o out
# docker build -f Dockerfile.contributor -t hosted-invocations-echo-agent .
# docker run --rm -p 8088:8088 hosted-invocations-echo-agent
#
# For end-users consuming the NuGet package (not ProjectReference), use the standard
# Dockerfile which performs a full dotnet restore + publish inside the container.
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS final
WORKDIR /app
COPY out/ .
EXPOSE 8088
ENV ASPNETCORE_URLS=http://+:8088
ENTRYPOINT ["dotnet", "HostedInvocationsEchoAgent.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.Extensions.AI;

namespace Microsoft.Agents.AI;

/// <summary>
/// A minimal <see cref="AIAgent"/> that echoes the user's input text back as the response.
/// No LLM or external service is required.
/// </summary>
public sealed class EchoAIAgent : AIAgent
{
/// <inheritdoc/>
public override string Name => "echo-agent";

/// <inheritdoc/>
public override string Description => "An agent that echoes back the input message.";

/// <inheritdoc/>
protected override Task<AgentResponse> RunCoreAsync(
IEnumerable<ChatMessage> messages,
AgentSession? session = null,
AgentRunOptions? options = null,
CancellationToken cancellationToken = default)
{
var inputText = GetInputText(messages);
var response = new AgentResponse(new ChatMessage(ChatRole.Assistant, $"Echo: {inputText}"));
return Task.FromResult(response);
}

/// <inheritdoc/>
protected override async IAsyncEnumerable<AgentResponseUpdate> RunCoreStreamingAsync(
IEnumerable<ChatMessage> messages,
AgentSession? session = null,
AgentRunOptions? options = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var inputText = GetInputText(messages);
yield return new AgentResponseUpdate
{
Role = ChatRole.Assistant,
Contents = [new TextContent($"Echo: {inputText}")],
};

await Task.CompletedTask;
}

/// <inheritdoc/>
protected override ValueTask<AgentSession> CreateSessionCoreAsync(CancellationToken cancellationToken = default)
=> new(new EchoAgentSession());

/// <inheritdoc/>
protected override ValueTask<JsonElement> SerializeSessionCoreAsync(
AgentSession session,
JsonSerializerOptions? jsonSerializerOptions = null,
CancellationToken cancellationToken = default)
=> new(JsonSerializer.SerializeToElement(new { }, jsonSerializerOptions));

/// <inheritdoc/>
protected override ValueTask<AgentSession> DeserializeSessionCoreAsync(
JsonElement serializedState,
JsonSerializerOptions? jsonSerializerOptions = null,
CancellationToken cancellationToken = default)
=> new(new EchoAgentSession());

private static string GetInputText(IEnumerable<ChatMessage> messages)
{
foreach (var message in messages)
{
if (message.Role == ChatRole.User)
{
return message.Text ?? string.Empty;
}
}

return string.Empty;
}

/// <summary>
/// Minimal session for the echo agent. No state is persisted.
/// </summary>
private sealed class EchoAgentSession : AgentSession;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft. All rights reserved.

using Azure.AI.AgentServer.Invocations;
using Microsoft.Agents.AI;

namespace HostedInvocationsEchoAgent;

/// <summary>
/// An <see cref="InvocationHandler"/> that reads the request body as plain text,
/// passes it to the <see cref="EchoAIAgent"/>, and writes the response back.
/// </summary>
public sealed class EchoInvocationHandler(EchoAIAgent agent) : InvocationHandler
{
/// <inheritdoc/>
public override async Task HandleAsync(
HttpRequest request,
HttpResponse response,
InvocationContext context,
CancellationToken cancellationToken)
{
// Read the raw text from the request body.
using var reader = new StreamReader(request.Body);
var input = await reader.ReadToEndAsync(cancellationToken);

// Run the echo agent with the input text.
var agentResponse = await agent.RunAsync(input, cancellationToken: cancellationToken);

// Write the agent response text back to the HTTP response.
response.ContentType = "text/plain";
await response.WriteAsync(agentResponse.Text, cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
<RootNamespace>HostedInvocationsEchoAgent</RootNamespace>
<AssemblyName>HostedInvocationsEchoAgent</AssemblyName>
<NoWarn>$(NoWarn);</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.AgentServer.Invocations" />
<PackageReference Include="DotNetEnv" />
</ItemGroup>

<!-- For contributors: uses ProjectReference to build against local source -->
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Abstractions\Microsoft.Agents.AI.Abstractions.csproj" />
</ItemGroup>

<!-- For end-users: uncomment the PackageReference below and remove the ProjectReference above
<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" Version="1.0.0" />
<PackageReference Include="Azure.AI.AgentServer.Invocations" />
</ItemGroup>
-->

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft. All rights reserved.

using Azure.AI.AgentServer.Invocations;
using DotNetEnv;
using HostedInvocationsEchoAgent;
using Microsoft.Agents.AI;

// Load .env file if present (for local development)
Env.TraversePath().Load();

var builder = WebApplication.CreateBuilder(args);

// Register the echo agent as a singleton (no LLM needed).
builder.Services.AddSingleton<EchoAIAgent>();

// Register the Invocations SDK services and wire the handler.
builder.Services.AddInvocationsServer();
builder.Services.AddScoped<InvocationHandler, EchoInvocationHandler>();

var app = builder.Build();

// Map the Invocations protocol endpoints:
// POST /invocations — invoke the agent
// GET /invocations/{id} — get result (not used by this sample)
// POST /invocations/{id}/cancel — cancel (not used by this sample)
app.MapInvocationsServer();

app.Run();
Loading
Loading