feat(ai-agents): add --inspector-port flag to azd ai agent run - #9366
feat(ai-agents): add --inspector-port flag to azd ai agent run#9366Glenn Harper (glharper) wants to merge 8 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds configurable Agent Inspector UI ports to support concurrent local agents.
Changes:
- Adds and validates
--inspector-port. - Forwards explicitly configured ports to Agent Inspector.
- Documents and tests the new flag.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
README.md |
Documents custom Inspector ports. |
internal/cmd/run.go |
Registers, validates, and forwards the flag. |
internal/cmd/run_test.go |
Tests registration, validation, and forwarding. |
Co-authored-by: glharper <64209257+glharper@users.noreply.github.com>
Jon Gallant (jongio)
left a comment
There was a problem hiding this comment.
Two optional hardening ideas inline, both about --inspector-port values that pass validation but still don't reach the inspector. Neither blocks.
LOW
--inspector-portis accepted and then dropped when the local client is suppressed, and when the project is an activity agent--inspector-portequal to--portclears validation and fails later at bind time
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cli/azd/extensions/azure.ai.agents/internal/cmd/run.go:571
- [azd-code-reviewer] This collision check runs before the activity profile is resolved, so an activity agent invoked with equal values (for example,
--port 9002 --inspector-port 9002) exits here instead of reaching the documented warning-and-ignore path. The Playground never binds the inspector port; move this check into the non-activity branch after profile resolution, or make validation profile-aware.
if flags.inspectorPort == flags.port {
Jon Gallant (jongio)
left a comment
There was a problem hiding this comment.
Incremental pass on 0103ac7. Both of my earlier points are handled. Three low-severity follow-ups inline, none blocking.
LOW
- the activity-agent warning prints after the agent process has already started, so it lands in the middle of the server's own output, and it's the one new behavior here without a test
- the
--portcollision check only fires when--inspector-portis set explicitly, so--port 8087on its own still hits the same bind conflict silently - README documents the flag but not the two new ways it can now fail
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cli/azd/extensions/azure.ai.agents/internal/cmd/run.go:569
- [azd-code-reviewer] This collision check runs before the service is resolved, so it also rejects activity-protocol agents even though they launch the Playground and never bind an Inspector port. That contradicts the later activity path, which is designed to warn and continue when
--inspector-portis irrelevant. Move this check until afterresolveActivityRunProfileand apply it only to non-activity agents.
if flags.inspectorPort == flags.port {
Jon Gallant (jongio)
left a comment
There was a problem hiding this comment.
Incremental pass on 52b87ab. One low-severity follow-up inline, not blocking.
LOW
- the new
--port 8087warning fires before azd knows whether the inspector extension is installed, so a machine without the extension gets a bind-conflict warning and then a not-installed warning
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
Jon Gallant (jongio)
left a comment
There was a problem hiding this comment.
One test gap remains:
run_test.go:481: the non-default-port case short-circuits before testing the port comparison.
🤖 agent jongio
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
|
Rechecked the latest review state locally. GitHub currently reports 0 unresolved threads. The one item in jongio's latest review summary ( Focused regression tests pass, and a fresh local code review found no remaining issues. No additional code change or push was needed. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
cli/azd/extensions/azure.ai.agents/README.md:26
- [azd-code-reviewer] This now identifies
--no-inspectoras deprecated, but lines 10–13 still recommend it as the primary way to suppress the client. Update that earlier instruction and example to use the canonical--no-clientflag so the README does not direct users to a deprecated option.
- with `--no-client` (or the deprecated `--no-inspector`), since no local client
cli/azd/extensions/azure.ai.agents/internal/cmd/run_test.go:307
- [azd-code-reviewer] These cases manually pass
set: true, so they do not exercise the new Cobra wiring that populatesinspectorPortSet. If theFlags().Changed("inspector-port")assignment regresses, this suite still passes while an explicit--inspector-port 0is silently treated as unset again. Add a command-level assertion for that exact invocation.
{name: "unset is allowed", port: 0},
{name: "explicit zero is rejected", port: 0, set: true, wantErr: true},
Summary
--inspector-portflag toazd ai agent runand forward it toai inspector launchazure.ai.inspectorextension stays the source of truth for the default UI port (8087) and existing behavior is unchangedUnblocks running two agents side by side: each agent already gets its own
--port, but both Inspectors previously tried to bind 8087.azd ai agent run --port 9091 --inspector-port 9002 # forwards: ai inspector launch --port 9091 --inspector-port 9002 --silentThe optional auto-increment-on-conflict idea from the issue is not included; that behavior belongs to the inspector extension, which owns the bind.
Testing
go test ./internal/cmd -count=1go build ./...golangci-lint run ./internal/cmd/...cspell lint internal/cmd/run.go internal/cmd/run_test.goNew coverage:
--inspector-portis omitted when unset and forwarded when set, the flag is registered with the documented default, and out-of-range values are rejected.No
TestFigSpecsnapshot update: that snapshot installs published extension artifacts fromregistry.json, so it picks this flag up on the nextazure.ai.agentsrelease.Fixes #9222