feat(ai.agents): local run + M365 Agents Playground for activity-protocol agents#8983
feat(ai.agents): local run + M365 Agents Playground for activity-protocol agents#8983v1212 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the azure.ai.agents azd extension to support activity-protocol (Teams) agents across both the cloud deploy lifecycle (Azure Bot + Teams channel provisioning/teardown) and a local inner-loop (azd ai agent run) that auto-launches the Microsoft 365 Agents Playground, while keeping non-activity agents on the existing Agent Inspector flow.
Changes:
- Add an activity-protocol “gate” (
ResolveActivityProfile) and reuse it across init/deploy/run flows. - Provision/teardown Azure Bot + Teams channel during
postdeploy/postdownfor activity agents (with a generated Teams setup guide). - Update
azd ai agent runto inject the local-only digital-worker toggle for activity agents and launch the Playground client, plus new flags/tests.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/project/activity_profile.go | Adds activity protocol detection + profile resolution + endpoint helper. |
| cli/azd/extensions/azure.ai.agents/internal/project/activity_profile_test.go | Tests activity protocol detection, resolution, and init round-trip. |
| cli/azd/extensions/azure.ai.agents/internal/pkg/botservice/botservice.go | New BotService client for ensuring/deleting Azure Bot + Teams channel. |
| cli/azd/extensions/azure.ai.agents/internal/pkg/botservice/botservice_test.go | Unit tests for bot provisioning, naming, and delete behavior. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/run.go | Adds activity gating, local-only env injection, and client auto-launch branching + flags. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/run_test.go | Tests Playground argv/URL behavior, gating, flags, and missing-CLI warning. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/run_activity.go | New Playground auto-launch helpers for activity agents. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go | Wires activity bot provisioning into postdeploy and teardown into postdown. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/listen_activity.go | Implements ensure/teardown + Teams setup guide generation and env helpers. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/listen_activity_test.go | Tests Teams setup guide content and file emission. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go | Adds activity_protocol to known protocols and prevents mixing with others. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code_test.go | Tests activity_protocol flag parsing/exclusivity and known protocol names. |
| cli/azd/extensions/azure.ai.agents/go.mod | Adds Azure BotService ARM SDK dependency. |
| cli/azd/extensions/azure.ai.agents/go.sum | Adds checksums for the new BotService SDK dependency. |
| cli/azd/extensions/azure.ai.agents/cspell.yaml | Adds activity-protocol / Playground related dictionary words. |
57bc773 to
7c0123f
Compare
Extend `azd ai agent run` to support local inner-loop testing of activity-protocol (Teams) agents via the Microsoft 365 Agents Playground, mirroring how the command already auto-launches Agent Inspector for responses/invocations agents. - Detect activity-protocol agents self-contained from the agent definition (container protocols or agent_endpoint 'activity'), with no dependency on the deploy-side activity provisioning work, so this can ship independently. - For activity agents, inject a local-only AGENT_DIGITAL_WORKER=1 toggle so the Playground emulator channel round-trips off-box (never set on deploy). - Auto-launch the Playground once the agent binds its port; reap the child via cmd.Wait; use 127.0.0.1 (IPv4) consistently to avoid ::1 failures. - Add --channel (Playground channel) and --no-client (protocol-neutral client suppress); deprecate --no-inspector in favor of --no-client while keeping it working for back-compat. - Tests for detection, flags (incl. deprecation), Playground argv/URL, and suppressed/missing-CLI paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
269aa90 to
2e6d48d
Compare
jongio
left a comment
There was a problem hiding this comment.
Verified: activity gate detection is self-contained (reads definition only, no deploy dependency), playground launch lifecycle correctly waits for port + reaps child process, IPv4 loopback (127.0.0.1) is consistent between displayHost, playgroundMessagesURL, and waitForLocalPort, flag deprecation uses MarkDeprecated properly, and suppressClient OR-logic covers both flags. No issues found.
Note
Independent of #8939. Earlier revisions were stacked on #8939
(
feat/activity-protocol-simple); this PR now detects activity-protocolagents with a self-contained gate and targets
maindirectly, so it can bereviewed and merged in parallel with #8939. Closes #8959.
Summary
Extends
azd ai agent runso an activity-protocol (Teams) agent can be testedin a pure-local inner loop — no Foundry deploy, no Azure Bot, no Teams sideload.
Targets the simple use case (Phase 1). The agent startup path is byte-for-byte
the same as today; only the auto-launched local client changes.
responses/invocations) are completely unaffected —everything sits behind a self-contained activity gate
(
isActivityProtocolDefinition) that only reads the agent definition, with nodependency on the deploy-side provisioning work.
runinjectsAGENT_DIGITAL_WORKER=1for the localprocess (anonymous auth so the emulator channel round-trips off-box; the default
"simple" model needs a managed identity that doesn't exist locally and would
500), then auto-launches the Microsoft 365 Agents Playground instead of the
Agent Inspector (Inspector only speaks
responses/invocations).Why the two flows differ
responses/invocationsai inspector launch --portactivity(emulator)agentsplayground -e http://127.0.0.1:<port>/api/messages -c emulatorGotchas encoded
127.0.0.1, notlocalhost— the agent binds IPv4;localhostresolves toIPv6
::1first and fails withECONNREFUSED ::1:<port>.toggle is set for the local process only; never during
azd deploy, soproduction keeps the default simple model.
agentsplaygroundCLI only warns (with awinget install agentsplaygroundhint) and keeps the agent running — mirrors howrunwarnswhen the Agent Inspector extension is missing.
What changed (file level)
internal/cmd/run_activity.go(new)resolveActivityRunProfile,playgroundCommandArgs,launchPlayground,handlePlaygroundAutoLaunch,startPlaygroundAfterAgentReady,missingPlaygroundWarning;AGENT_DIGITAL_WORKERconstant.internal/cmd/run.go--no-inspectorin favor of--no-client; add--channel.internal/cmd/run_test.gocspell.yamlagentsplayground,winget,ECONNREFUSED.The
quickstart-echosample (infoundry-samples, not this repo) gains anAGENT_DIGITAL_WORKERtoggle inmain.py(default unset = simple) plus a"Local testing" README section.
Flags
--no-client— protocol-neutral flag to suppress the auto-launched client (canonical).--no-inspector— deprecated alias for--no-client; still works (back-compat) but hidden from help.--channel— overrides the Playground channel (defaultemulator; activity only).How to try it (manual)
Prerequisites (one time):
winget install agentsplayground # the only local client that speaks ActivityRun the activity echo agent locally from a prepared
quickstart-echoproject(activity
agent.yaml+ anazure.ai.agentservice inazure.yaml):Expected:
Activity agent detected: starting in digital-worker (anonymous) mode ....http://0.0.0.0:<port>(default 8088).agentsplayground -e http://127.0.0.1:<port>/api/messages -c emulator;a browser tab opens. Type
hi-> the agent echoesEcho: hi.Variations:
azd ai agent run --no-client(or--no-inspector): agent starts, noPlayground is launched.
azd ai agent run --channel <name>: overrides the Playground channel.agentsplaygroundisn't installed: a warning with thewinget installhint is printed and the agent keeps running.
No-browser smoke check (inbound routing; the real Playground provides a working
emulator
serviceUrlfor the outbound reply):Testing
Automated
go build ./...,go vet ./..., andgo test ./internal/cmd/... ./internal/project/...all pass;
gofmtclean;cspell0 issues. New unit tests assert the exactagentsplayground -e http://127.0.0.1:<port>/api/messages -c emulatorargv (likeTestLaunchInspectorUsesWorkflowCommanddoes for the inspector), the activity gatedecision, flag parsing, the missing-CLI warning, and suppression.
Live (built via
azd x pack/publish/install, run through the branch extension)azd ai agent runActivity agent detected ...printed; agent bound0.0.0.0:8088; Playground auto-launched with the exactagentsplayground -e http://127.0.0.1:8088/api/messages -c emulatorargv. In the browser Playground the full round-trip works: theconversationUpdategreetingWelcome Buddy!appears, and typinghello/hireturnsEcho: hello/Echo: hi. Inbound POSTs return HTTP 202 (replies delivered) — confirming the anonymous digital-worker mode is active (the default simple model would 500 locally).--no-clientresponses) agentNon-goals