You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once cli/azd/extensions/azure.ai.agents/go.mod is bumped past the version that includes #7312 (currently pinned to github.com/azure/azure-dev/cli/azd v1.23.14), azd ai agent ... fails to start because the extension declares flags that collide with azd's reserved global flag registry:
The extension builds its root with a bare cobra.Command{} and manually wires --debug / --no-prompt, instead of using azdext.NewExtensionRootCommand() which already provides every SDK-managed global plus an *ExtensionContext (OutputFormat, Environment, Debug, NoPrompt, Cwd). Several subcommands then redundantly redeclare --output/-o, and init declares its own --environment (which the host pre-parser would hijack anyway).
Proposed changes (extension only)
Switch internal/cmd/root.go to azdext.NewExtensionRootCommand(); drop the manual --debug/--no-prompt registrations and the AZD_NO_PROMPT fallback in PersistentPreRunE (the SDK handles both). Thread the returned *ExtensionContext to subcommands.
Remove the per-subcommand --output/-o registrations in show.go:101, files.go:452 (files list), files.go:754 (files stat), and sessions*.go (create|list|show). Read extCtx.OutputFormat instead. The accepted values (json, table) are already standard azd Format constants from cli/azd/pkg/output/formatter.go. Preserve current per-command default-format behavior by mapping the SDK default "default" → "json" per command, and consider rejecting unknown values explicitly (today they silently fall through to JSON).
Rename or remove init --environment (init.go:518) — either rename to --env-name/--target-env, or drop it and use extCtx.Environment.
Update tests in files_test.go, show_test.go, session_test.go that read --output from cobra flags to read from extCtx.OutputFormat.
cd cli/azd/extensions/azure.ai.agents
go build ./... && go test ./...
azd x build
azd ai agent --help
azd ai agent show -o json
azd ai agent files list
Summary
Once
cli/azd/extensions/azure.ai.agents/go.modis bumped past the version that includes #7312 (currently pinned togithub.com/azure/azure-dev/cli/azd v1.23.14),azd ai agent ...fails to start because the extension declares flags that collide with azd's reserved global flag registry:Root cause
The extension builds its root with a bare
cobra.Command{}and manually wires--debug/--no-prompt, instead of usingazdext.NewExtensionRootCommand()which already provides every SDK-managed global plus an*ExtensionContext(OutputFormat,Environment,Debug,NoPrompt,Cwd). Several subcommands then redundantly redeclare--output/-o, andinitdeclares its own--environment(which the host pre-parser would hijack anyway).Proposed changes (extension only)
internal/cmd/root.gotoazdext.NewExtensionRootCommand(); drop the manual--debug/--no-promptregistrations and theAZD_NO_PROMPTfallback inPersistentPreRunE(the SDK handles both). Thread the returned*ExtensionContextto subcommands.--output/-oregistrations inshow.go:101,files.go:452(files list),files.go:754(files stat), andsessions*.go(create|list|show). ReadextCtx.OutputFormatinstead. The accepted values (json,table) are already standard azdFormatconstants fromcli/azd/pkg/output/formatter.go. Preserve current per-command default-format behavior by mapping the SDK default"default"→"json"per command, and consider rejecting unknown values explicitly (today they silently fall through to JSON).init --environment(init.go:518) — either rename to--env-name/--target-env, or drop it and useextCtx.Environment.files_test.go,show_test.go,session_test.gothat read--outputfrom cobra flags to read fromextCtx.OutputFormat.go.modto the post-Add reserved global flags registry for extensions #7312cli/azdversion once the above is done.Validation
Related
cli/azd/docs/extensions/extensions-style-guide.mdcli/azd/docs/design/extension-flag-architecture.mdOut of scope
--outputreserved is intentional — the SDK already provides it at the extension root.