Switch invocations_ws agent endpoint to path-based routing#9049
Conversation
Update the `invocations_ws` agent WebSocket URL from the preview
dispatcher form (single literal `/api/projects/agents/...` path with
`project_name`/`agent_name` query parameters) to the GA path-based
route, mirroring the HTTP `invocations` shape:
wss://<account>.services.ai.azure.com/api/projects/<project>/agents/<agent>/endpoint/protocols/invocations_ws?api-version=v1
Project and agent are now carried as path segments; the only query
parameters are the required `api-version` and an optional
`agent_session_id`. This updates the URL registered as
`AGENT_{KEY}_INVOCATIONS_WS_ENDPOINT` on `azd deploy` and shown as
`Endpoint (invocations_ws)` by `azd ai agent show`.
Ref: coreai-microsoft/foundrysdk_specs#221
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates how the hosted-agent invocations_ws WebSocket endpoint URL is constructed in the azure.ai.agents extension. It migrates from the preview "dispatcher" form (project/agent carried as project_name/agent_name query parameters on a fixed /api/projects/agents/... path) to the GA path-based route where project and agent travel as path segments, mirroring the HTTP invocations route shape. This value is what azd deploy registers as AGENT_{KEY}_INVOCATIONS_WS_ENDPOINT and what azd ai agent show displays.
Changes:
buildInvocationsWSProtocolURLnow reuses the project endpoint's host + path, swaps the scheme towss, and appends/agents/<agent>/endpoint/protocols/invocations_ws?api-version=<version>; the malformed-endpoint guard (returns""so the entry is filtered) is preserved, and the now-unusedpathimport is removed.- Unit tests updated to assert the path-based URL and to drop the obsolete
wantURLOmitAgent/query-parameter assertions. - Added a CHANGELOG entry under
1.0.0-beta.5 (Unreleased).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go |
Rewrites buildInvocationsWSProtocolURL to emit the path-based route, updates the doc comment, and removes the unused path import. |
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent_test.go |
Updates TestDisplayableProtocolFor, TestAgentInvocationEndpoints, and TestBuildInvocationsWSProtocolURL_TrimsWhitespace to assert the new path-based URL. |
cli/azd/extensions/azure.ai.agents/CHANGELOG.md |
Adds a Bugs Fixed entry describing the endpoint format switch. |
I reviewed the URL-construction logic, the preserved malformed-endpoint guard, encoding consistency with the sibling buildResponsesProtocolURL/buildInvocationsProtocolURL builders, and confirmed no other callers still rely on the old dispatcher form. The tests are updated consistently and the CHANGELOG format is correct. I did not find any issues that warrant a comment.
jongio
left a comment
There was a problem hiding this comment.
The URL construction is correct and now consistent with the sibling HTTP protocol builders. Tests properly updated. Note: this PR has merge conflicts that need resolving before merge.
Resolve the post-beta.5 changelog conflict by placing this change in the new beta.6 unreleased section. Trim trailing slashes from brownfield project endpoint paths so the generated WebSocket route never contains a double slash, with regression coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Updates the hosted-agent
invocations_wsWebSocket endpoint thatazd deployregisters andazd ai agent showdisplays, switching it from the preview dispatcher form to the GA path-based route, per coreai-microsoft/foundrysdk_specs#221.Before (single literal path, project/agent in query string):
After (path-based, mirrors the HTTP
invocationsshape):Project and agent now travel as path segments; the only WebSocket query parameters are the required
api-versionand an optionalagent_session_id. The previewfoundry_features/project_name/agent_namequery parameters are dropped.Backward compatibility
The preview dispatcher URL is still active in the live hosted-agent environment tested on 2026-07-09: both the old URL and the new path-based URL completed a WebSocket upgrade with
101 Switching Protocols. The old URL was handled directly; there was no redirect.However, the old dispatcher route is a preview compatibility surface, not part of the GA contract in foundrysdk_specs#221. The GA spec does not define a redirect or guarantee continued support for the old URL, so callers should migrate to the path-based URL. Once the service removes the preview route, callers using it should expect an error.
Changes
buildInvocationsWSProtocolURLnow emits the path-based route (reusing the project endpoint's host + path, swapping the scheme towssand the trailing segment toinvocations_ws). The malformed-endpoint guard (returns""so the entry is filtered) is preserved./agents/..., preventing a broken double-slash route.pathimport.1.0.0-beta.6 (Unreleased)changelog section following the beta.5 release.This affects the value registered as
AGENT_{KEY}_INVOCATIONS_WS_ENDPOINTonazd deployand shown asEndpoint (invocations_ws)byazd ai agent show.Testing
go build ./...go test ./internal/project/... ./internal/cmd/... ./internal/pkg/agents/...invocations_ws: the generated path-based URL returned101 Switching Protocols, both with and withoutagent_session_id.gofmt/go vetcleanFixes #9076
Ref: coreai-microsoft/foundrysdk_specs#221