[docs] Document asHostedAgentWithProtocol for polyglot hosted agents - #1475
[docs] Document asHostedAgentWithProtocol for polyglot hosted agents#1475aspire-repo-bot[bot] wants to merge 4 commits into
Conversation
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure AI Foundry hosting integration documentation to cover protocol selection for hosted agents, aligning the docs with the recently introduced asHostedAgentWithProtocol capability and the C# AsHostedAgent(project, protocol, protocolVersion) overload.
Changes:
- Adds a new “Select a hosted agent protocol” subsection describing the default Responses
2.0.0protocol behavior. - Documents how to explicitly select a protocol/version in both C# and TypeScript, including an example using the Invocations protocol.
- Clarifies that existing polyglot AppHosts using
asHostedAgent(project, options?)continue to work unchanged with the default protocol/version.
Suppressed comments (1)
src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx:495
- For consistency with the rest of the docs, consider capitalizing “AppHosts” here as well (this appears to be used as a proper term throughout the site).
The defaulted `asHostedAgent` entry point and the explicit `asHostedAgentWithProtocol` entry point are both exported to polyglot app hosts, so existing AppHosts that call `asHostedAgent(project, options?)` continue to work unchanged with the Responses `2.0.0` default. Reach for `asHostedAgentWithProtocol` only when you need a protocol or version other than the default.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32c349b4-907d-42e9-aad8-2f0edc267779
| <TabItem id='csharp' label='C#'> | ||
|
|
||
| ```csharp | ||
| builder.AddPythonApp("agent-python", "..\\agent", "main:app") |
There was a problem hiding this comment.
"..\\agent" is a literal backslash path on macOS/Linux, so this C# sample fails to find the parent agent directory there. Could we use "../agent", matching the TypeScript sample? The earlier C# sample has the same issue.
Alistair Matthews (alistairmatthews)
left a comment
There was a problem hiding this comment.
Please consider my suggestion.
David Pine (IEvangelist)
left a comment
There was a problem hiding this comment.
🤖 Automated docs-accuracy review
Source of truth: microsoft/aspire branch release/13.5 @ 8ab6999850d96e0023670799edbd4bdc245ad63c
- Phase A — Claims verification (read
microsoft/aspire): 7 claims extracted → ✅ 4 verified · ❌ 2 contradicted · ⚪ 1 narrative (not blocking). - Phase B — doc-tester (blind user, no source consulted): exercised
/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/#select-a-hosted-agent-protocol, rendered locally from this PR''s head. Page renders cleanly (0 console errors/warnings). 0 critical · 2 warnings/knowledge-gaps.
Verdict: 🔴 Request changes. The C# tab and the "defaults to Responses 2.0.0" statements are accurate and verified. However, the TypeScript example and the sentence claiming both entry points are "exported to polyglot AppHosts" document an API (asHostedAgentWithProtocol + the HostedAgentProtocol enum) that is not present in the generated polyglot surface on release/13.5. See the two inline comments.
Phase A — Claim verification
Inline comments are anchored to the two contradicted locations (the TypeScript sample and the "both exported to polyglot" paragraph).
✅ Verified & verified-with-nuance claims (4) — evidence
| # | Claim | Verdict | Evidence (microsoft/aspire@8ab6999850) |
|---|---|---|---|
| C1 | AsHostedAgent (C#) and asHostedAgent (polyglot) default to the Responses protocol version 2.0.0. |
✅ verified | HostedAgent/HostedAgentBuilderExtension.cs:92 & :145-146 (ConfigureAsHostedAgent(..., HostedAgentProtocol.Responses, AzureHostedAgentResource.DefaultResponsesProtocolVersion, ...)); HostedAgent/AzureHostedAgentResource.cs:32 (DefaultResponsesProtocolVersion = "2.0.0"); api/Aspire.Hosting.Foundry.ats.txt:253 (asHostedAgent(project, options?)). |
| C2 | The HostedAgentProtocol enum exposes Responses and Invocations. |
✅ verified | HostedAgent/HostedAgentProtocol.cs:9-20 (enum HostedAgentProtocol { Responses, Invocations }). |
| C3 | C# AsHostedAgent(project, HostedAgentProtocol.Invocations, "1.0.0") overload exists, and the AddPythonApp(...).WithReference(...).AsHostedAgent(...) chain compiles. |
✅ verified | Public overload AsHostedAgent<T>(IResourceBuilder<AzureCognitiveServicesProjectResource>?, HostedAgentProtocol, string, Action<HostedAgentConfiguration>? = null) at HostedAgent/HostedAgentBuilderExtension.cs:194-203. PythonAppResource : ExecutableResource which implements IResourceWithEndpoints, IResourceWithEnvironment, IComputeResource — satisfies the generic constraint. |
| C4 | "Pass a protocol and version explicitly in C#." | ✅ verified | Same overload as C3. |
⚪ Narrative (1) — noted, not blocking
- C7 — "the Invocations protocol used by some Microsoft Agent Framework (MAF) agents." The
HostedAgentProtocol.Invocationsvalue exists, but the MAF association is prose not verifiable from source. Not blocking.
Phase B — doc-tester results (blind-user pass, no source code consulted)
Route exercised: /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/#select-a-hosted-agent-protocol (rendered locally via astro dev from this PR''s head content).
Rendering: Clean. The new ### Select a hosted agent protocol section appears in the On this page TOC; the C#/TypeScript tabs render and sync via aspire-lang; 0 console errors, 0 warnings.
✅ Passed checks
- Section renders and its anchor navigates correctly.
- Prose clearly states the Responses
2.0.0default and when to override it. - The C# and TypeScript tabs are parallel and structurally consistent.
- The
project/chatvariables used in both samples are established earlier on the page, so a reader following top-to-bottom has them in scope.
- The TypeScript snippet uses
HostedAgentProtocol.InvocationsandasHostedAgentWithProtocolbut shows noimportstatement, and — unlike the page''s other TypeScript AppHost examples (which aretwoslashand import from./.aspire/modules/aspire.mjs) — this block is nottwoslash, so it is not type-checked by the site and a polyglot reader cannot tell whereHostedAgentProtocolcomes from. (This is the visible symptom of the Phase A contradiction.) - No cross-reference/link to an API-reference entry for
asHostedAgentWithProtocol/HostedAgentProtocolthat would let a reader confirm the surface.
Knowledge boundary: As a blind user I could not compile the TypeScript block (not type-checked on the site) nor run an Azure Foundry hosted-agent deployment in this environment, so the TypeScript example could not be validated from the docs alone — flagged rather than filled.
Critical issues: none from the rendering/blind-user pass.
Automated hourly docs-accuracy reviewer. Phase A verifies claims against microsoft/aspire source; Phase B validates the rendered docs blind to source; this review merges both.
| .addPythonApp('agent-python', '../agent', 'main:app') | ||
| .withReference(project) | ||
| .withReference(chat) | ||
| .asHostedAgentWithProtocol(project, HostedAgentProtocol.Invocations, '1.0.0'); |
There was a problem hiding this comment.
❌ Contradicted (Phase A) — polyglot API not in the generated surface
This TypeScript sample calls asHostedAgentWithProtocol(...) and references HostedAgentProtocol.Invocations, but neither is present in the polyglot/TypeScript surface on release/13.5:
- The C# source does declare
[AspireExport("asHostedAgentWithProtocol")](src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:162) — but the generated capability dumpsrc/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.ats.txt(header:Generated by: aspire sdk dump --format ci) lists onlyasHostedAgent(project, options?)(line 253);asHostedAgentWithProtocolis absent. - The
HostedAgentProtocolenum is not projected to polyglot — the file''s "Enum Types" section exposes onlyFoundryRole. SoHostedAgentProtocol.Invocationsisn''t available to TypeScript AppHosts. - Source and baseline were committed together (
0028557bee), so the baseline is not stale. This repo''s own generated TS bindings agree:src/frontend/src/data/twoslash/aspire.d.tsandsrc/frontend/src/data/ts-modules/Aspire.Hosting.Foundry.*.jsoncontainasHostedAgentbut zero references toasHostedAgentWithProtocolorHostedAgentProtocol.
As written, this snippet won''t resolve for a polyglot AppHost. Please verify against the generated ats.txt / TS bindings: if the export is intended for polyglot, the HostedAgentProtocol enum must be exposed and the bindings regenerated; otherwise correct the TypeScript example. (The C# tab above is accurate.)
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| The defaulted `asHostedAgent` entry point and the explicit `asHostedAgentWithProtocol` entry point are both exported to polyglot AppHosts, so existing AppHosts that call `asHostedAgent(project, options?)` continue to work unchanged with the Responses `2.0.0` default. Reach for `asHostedAgentWithProtocol` only when you need a protocol or version other than the default. |
There was a problem hiding this comment.
❌ Contradicted (Phase A) — "both exported to polyglot AppHosts"
The asHostedAgent(project, options?) half is correct: it is exported and defaults to Responses 2.0.0 — verified (api/Aspire.Hosting.Foundry.ats.txt:253; AsHostedAgentForExport, HostedAgent/HostedAgentBuilderExtension.cs:132-148).
But asHostedAgentWithProtocol is not in the generated polyglot capability dump on release/13.5 — only the C# [AspireExport] attribute exists in source (see the inline comment on the TypeScript sample above). So the statement that both entry points "are both exported to polyglot AppHosts" is not accurate for this branch. Consider scoping explicit protocol selection to C#, or confirm/regenerate the polyglot bindings first.
Co-authored-by: Alistair Matthews <alistairwebdojo@live.com>
David Pine (IEvangelist)
left a comment
There was a problem hiding this comment.
🤖 Docs-accuracy review — automated (Phase A: claims vs. source · Phase B: doc-tester)
Phase A source of truth: microsoft/aspire @ branch release/13.5, SHA 8ab6999850d96e0023670799edbd4bdc245ad63c
Claims extracted: 9 total (8 non-narrative) — ✅ 7 verified · 🟡 1 verified-with-nuance · ❔ 0 unverifiable · ❌ 0 contradicted · 📝 1 narrative
Phase B (doc-tester): exercised /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/ (#select-a-hosted-agent-protocol), served locally from the PR head — 0 critical · 1 warning · 2 knowledge gaps.
Verdict: COMMENT. Every verifiable API claim in the new section matches release/13.5. The only item worth surfacing is a naming/clarity nuance: the intro prose tells readers to "use AsHostedAgentWithProtocol", but that PascalCase name is not a callable public C# API and does not appear in the C# example — it exists only as the camelCase polyglot export asHostedAgentWithProtocol (used correctly in the TypeScript tab). No factual contradictions and no critical rendering issues.
Phase A — Claim verification
Source PR is microsoft/aspire#18980; the described surface is present on release/13.5. Evidence paths below are in microsoft/aspire at the SHA above.
Every API/behavior claim checks out:
- Default = Responses
2.0.0— the parameterless-project overload callsConfigureAsHostedAgent(..., HostedAgentProtocol.Responses, AzureHostedAgentResource.DefaultResponsesProtocolVersion, ...)(src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:86-92), andDefaultResponsesProtocolVersionis the literal"2.0.0"(AzureHostedAgentResource.cs:32). - C#
AsHostedAgent(project, HostedAgentProtocol.Invocations, "1.0.0")— public overloadAsHostedAgent<T>(builder, project, HostedAgentProtocol protocol, string protocolVersion, Action<HostedAgentConfiguration>? configure = null)(HostedAgentBuilderExtension.cs:194-203); the exact call appears inplayground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs:70. - Polyglot
asHostedAgentWithProtocol(project, protocol, version)—[AspireExport("asHostedAgentWithProtocol")]onAsHostedAgentWithProtocolForExport(builder, project, HostedAgentProtocol protocol, string protocolVersion, HostedAgentOptions? options = null)(HostedAgentBuilderExtension.cs:162-168). HostedAgentProtocol.Invocations/.Responses—public enum HostedAgentProtocol { Responses, Invocations }(HostedAgent/HostedAgentProtocol.cs:9-21).- Both entry points exported to polyglot hosts —
[AspireExport("asHostedAgent", …)]at:132and[AspireExport("asHostedAgentWithProtocol")]at:162. - Existing
asHostedAgent(project, options?)unchanged, Responses2.0.0default — exportedasHostedAgent(project, HostedAgentOptions? options = null)resolves to Responses +DefaultResponsesProtocolVersion(:132-148); the in-source comment at:116-120confirms the original capability "retains its Responses/2.0.0 defaults."
🟡 One nuance (see the inline comment on line 469): the prose's AsHostedAgentWithProtocol (PascalCase) is not a public C# method. In C# the entry point is the AsHostedAgent(project, protocol, protocolVersion) overload; AsHostedAgentWithProtocol exists only as the internal AsHostedAgentWithProtocolForExport surfaced to polyglot hosts under the camelCase export name asHostedAgentWithProtocol. The code samples themselves are correct per language — only the prose naming is imprecise.
Full claim catalog with verdicts & evidence (9 claims)
| # | Type | Claim | Verdict | Evidence (microsoft/aspire@release/13.5) |
|---|---|---|---|---|
| C1 | api-behavior | AsHostedAgent defaults to Responses 2.0.0 |
✅ verified | HostedAgentBuilderExtension.cs:86-92; AzureHostedAgentResource.cs:32 (DefaultResponsesProtocolVersion = "2.0.0") |
| C2 | api-shape | C# AsHostedAgent(project, HostedAgentProtocol.Invocations, "1.0.0") overload |
✅ verified | HostedAgentBuilderExtension.cs:194-203; playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs:70 |
| C3 | api-shape | TS asHostedAgentWithProtocol(project, protocol, version) |
✅ verified | HostedAgentBuilderExtension.cs:162-168 ([AspireExport("asHostedAgentWithProtocol")]) |
| C4 | api-shape | HostedAgentProtocol.Invocations (and .Responses) enum |
✅ verified | HostedAgent/HostedAgentProtocol.cs:9-21 |
| C5 | api-behavior | Both asHostedAgent & asHostedAgentWithProtocol exported to polyglot hosts |
✅ verified | HostedAgentBuilderExtension.cs:132 & :162 |
| C6 | api-behavior | Existing asHostedAgent(project, options?) still works, Responses 2.0.0 default |
✅ verified | HostedAgentBuilderExtension.cs:132-148; comment :116-120 |
| C7 | api-shape | Prose: "use AsHostedAgentWithProtocol" |
🟡 verified-with-nuance | No public C# AsHostedAgentWithProtocol; C# uses AsHostedAgent(project,protocol,version) (:194), polyglot export is camelCase asHostedAgentWithProtocol (:162) |
| C8 | api-shape | AddPythonApp(name, appDirectory, scriptPath) |
✅ verified | src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs:68-69. Note: "main:app" is an ASGI module:app spec passed to the scriptPath parameter (the API's own example uses "main.py"); the parameter accepts any string, so not a contradiction |
| C9 | narrative | "some MAF agents use the Invocations protocol" | 📝 narrative | Non-blocking; consistent with the Invocations enum member |
Phase B — Doc-tester results (blind-user, docs-only view)
Served the PR head locally (http://localhost:4321/) and exercised the affected route with a browser only — no source code consulted in this phase.
Route exercised: /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/ → section #select-a-hosted-agent-protocol.
✅ Passed checks
- Page renders at the expected route; the new "Select a hosted agent protocol"
H3appears with a working table-of-contents entry and a self-anchor (#select-a-hosted-agent-protocol). - Section is placed logically, immediately after "Add a hosted agent to Azure AI Foundry" and before "Add and publish a prompt agent."
- The C# and TypeScript tabs both render, switch, and stay in sync via the
?aspire-lang=query param; both code blocks display fully and are copyable. - No console errors on load (0 errors / 0 warnings).
- Prose ↔ example naming mismatch (C#). The intro sentence (line 469) reads: "…use
AsHostedAgentWithProtocolor pass a protocol and version explicitly." But the C# tab below it calls.AsHostedAgent(project, HostedAgentProtocol.Invocations, "1.0.0")— the nameAsHostedAgentWithProtocolnever appears in the C# example. Only the TypeScript tab usesasHostedAgentWithProtocol. A reader following the C# path can reasonably look for aAsHostedAgentWithProtocolmethod that the example doesn't show. Suggest clarifying that C# selects a protocol via theAsHostedAgent(project, protocol, version)overload, whileasHostedAgentWithProtocolis the polyglot/TypeScript capability.
❔ Knowledge gaps (2)
- The samples reference a
chatvariable (.WithReference(chat)/.withReference(chat)) that isn't defined within this snippet; a copy-paste reader wouldn't know whatchatis from the section alone. - Neither tab shows the import/namespace needed to reference the
HostedAgentProtocolenum (e.g., theAspire.Hosting.Foundrynamespace in C#, or the equivalent TypeScript import), so a new user copying the example may not know how to resolveHostedAgentProtocol.
Recommendations
- Align the intro prose with the C# example (make the C#-vs-polyglot naming explicit).
- Optionally note the namespace/import for
HostedAgentProtocol.
Automated review. Phase A read microsoft/aspire@release/13.5 (8ab69998); Phase B used the doc-tester skill against the PR head served locally, blind to source code.
|
|
||
| ### Select a hosted agent protocol | ||
|
|
||
| `AsHostedAgent` defaults to the Responses protocol version `2.0.0`. If your hosted agent implements a different protocol or protocol version, use `AsHostedAgentWithProtocol` or pass a protocol and version explicitly. For example, some Microsoft Agent Framework (MAF) agents use the Invocations protocol: |
There was a problem hiding this comment.
🟡 verified-with-nuance — AsHostedAgentWithProtocol (PascalCase) is not a callable public C# API on microsoft/aspire@release/13.5. The C# entry point for explicit protocol selection is the AsHostedAgent(project, protocol, protocolVersion) overload (src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:194-203) — which is exactly what the C# tab below uses. AsHostedAgentWithProtocol exists only as the internal AsHostedAgentWithProtocolForExport (:163), surfaced to polyglot hosts under the camelCase export name asHostedAgentWithProtocol ([AspireExport("asHostedAgentWithProtocol")], :162), as the TypeScript tab correctly shows.
Since this sentence sits directly above a C# example that never uses AsHostedAgentWithProtocol, consider making the C#-vs-polyglot naming explicit — e.g. "in C#, pass a protocol and version to the AsHostedAgent(project, protocol, protocolVersion) overload; polyglot AppHosts use the asHostedAgentWithProtocol capability." (Non-blocking.)
Documents changes from microsoft/aspire#18980
@sebastienrosTargeting
release/13.5based on the source PR milestone13.5(exact match onmicrosoft/aspire.dev).Why
microsoft/aspire#18980 restores ATS compatibility for the polyglot
asHostedAgent(project, options?)capability by defaulting it to the Responses protocol version2.0.0, and introduces a new additiveasHostedAgentWithProtocolcapability for polyglot hosts that need to select an explicit protocol/version (mirroring the existing C#AsHostedAgent(project, protocol, protocolVersion, ...)overload). The Azure AI Foundry hosting integration reference page documentedAsHostedAgent/asHostedAgentbut had no mention of protocol selection at all, so the new capability and its C# equivalent overload were undocumented.What changed
Added a new "Select a hosted agent protocol" subsection to
azure-ai-foundry-host.mdx, immediately after the existing "Add a hosted agent to Azure AI Foundry" section, covering:AsHostedAgent/asHostedAgentdefault to Responses2.0.0.AsHostedAgent(project, protocol, protocolVersion)overload, and the polyglotasHostedAgentWithProtocol(project, protocol, protocolVersion)capability.asHostedAgent(project, options?)keep working unchanged.Files modified
src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx(existing page updated, no new pages created)