[feat] optimzie progressive update + adapt to new azure.yaml - #9003
Conversation
There was a problem hiding this comment.
Pull request overview
This PR polishes the azd ai agent optimize command's live progress experience and adapts the eval/optimize commands to the newer azure.yaml inline agent-definition model. During polling it now renders a live-updating candidate results table (completed rows appended in place, with an overwritten in-progress status line) instead of a single spinner line, and it replaces the removed on-disk agent.yaml detection in eval with the shared projectpkg.LoadAgentDefinition, which understands inline, legacy-config, and disk sources.
Changes:
- Progressive polling UI: extracted shared table helpers (
candidateTableHeader,formatCandidateRow,candidateDisplayName,writeCandidateRow), added a live candidate table with server-timestamp-based "Total time"/"Duration" output, softened the pre-run warning to a "Note", and bumped the default--poll-intervalfrom 5s to 10s. azure.yamladaptation:evalnow resolves agent kind viaLoadAgentDefinition(with legacy-shape warnings) and drops the localdetectEvalAgentKind/relPathForYamlhelpers;--agenthelp text is aligned across optimize/deploy/apply/eval to describe service-name vs Foundry-name semantics.- Model additions:
JobProgress.BaselineScoreand a newInProgressCandidate(CreatedAt,CandidateGenerated) type for richer server progress reporting.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
internal/pkg/agents/optimize_api/models.go |
Adds BaselineScore and InProgressCandidate to job progress payload. |
internal/cmd/optimize.go |
Live candidate table rendering during polling; softened warning; --poll-interval default 10; total-time output. |
internal/cmd/optimize_helpers.go |
New shared candidate-table rendering helpers; removes loadLastOptimizeJobID. |
internal/cmd/optimize_status.go |
Uses loadOptimizeJobIDForAgent; adds Updated/Duration to summary; poll default 10. |
internal/cmd/optimize_deploy.go / optimize_apply.go |
--agent help text and comments updated for azure.yaml semantics. |
internal/cmd/eval.go |
Replaces on-disk kind detection with LoadAgentDefinition; removes now-unused helpers. |
internal/cmd/eval_generate.go |
--agent help text updated. |
*_test.go (optimize, status, helpers, deploy, eval) |
Updates poll-interval assertions, adds table-helper and summary-duration tests, removes tests for deleted helpers. |
jongio
left a comment
There was a problem hiding this comment.
Clean refactoring that consolidates agent kind detection into the shared LoadAgentDefinition utility and improves the optimize polling UX with a live-updating candidate table.
Key things I verified:
loadOptimizeJobIDForAgent("", envName)correctly falls back to the globalOPTIMIZE_LAST_OPERATION_IDkey, matching the removedloadLastOptimizeJobIDbehavior.- The
resolveOptimizeAgentreordering (project-first, flag-as-Foundry-name fallback) is consistent with other commands and preserves backwards compatibility for users specifying a Foundry name directly. - New table rendering helpers are well-tested and the extraction from the inline loop is a good separation of concerns.
One optional suggestion inline.
trangevi
left a comment
There was a problem hiding this comment.
This looks good overall — just a couple of comments.
Optimize: progressive polling UX, azure.yaml agent detection, and
--output jsonfor statusSummary
Improves the
azd ai agent optimizepolling experience with live-updating candidate rows and phase-aware progress indicators, migrates agent kind detection to the new azure.yaml inline/config agent definition format, and adds--output jsonsupport tooptimize status.Changes
Agent detection from azure.yaml (
eval.go,optimize.go)detectEvalAgentKindwithprojectpkg.LoadAgentDefinition, which supports the latest azure.yaml agent definition shapes:configpointer in azure.yamlagent.yamlfile on diskazure.yaml (inline),azure.yaml (config),agent.yaml) instead of just showing the file path.WarnLegacyAgentShapewhen legacy config shapes are detected.detectEvalAgentKindandrelPathForYamlfunctions and their tests.Optimize agent resolution refactor (
optimize.go)resolveOptimizeAgentnow tries the azd project context first (passing--agentas a service name toresolveAgentService), then falls back to treating--agentas a raw Foundry agent name. Previously, a non-empty--agentflag would skip project resolution entirely.--agentflag now also reads the agent version from the environment (viaAGENT_{KEY}_VERSION), enabling version-aware optimization."Agent service name from azure.yaml, or Foundry agent name outside a project".optimize applyandoptimize deployflag descriptions.Progressive polling UX (
optimize.go,optimize_helpers.go)InProgressCandidate.CandidateGeneratedfield.Generating candidate 2/5(fromMaxCandidates) orGenerating candidate 2when max is unknown.InProgressCandidate.CreatedAt(server timestamp) instead of a locally-tracked timer.candidateDisplayName,candidateTableHeader,formatCandidateRow,writeCandidateRoware now shared helpers, eliminating duplicated rendering between polling and final results.optimize status --output json(optimize_status.go)--outputflag (json|table, defaulttable) viaazdext.RegisterFlagOptions.--output json: prints the fullOptimizeJobStatusas indented JSON.--output json --watch: suppresses table output during polling, prints final status as JSON.API model updates (
optimize_api/models.go)InProgressCandidatestruct withCreatedAtandCandidateGeneratedfields.InProgressCandidatefield toJobProgress.Tests
optimize_status_test.go:--outputflag registration, default poll interval,printOptimizeStatusJSON, job summary duration display (present/missing/equal timestamps).optimize_helpers_test.go:candidateDisplayName,candidateTableHeader,formatCandidateRow(empty/non-empty eval & strategy, hidden columns).optimize_test.go:TestPrintOptimizeResults_StrategyDashForMixedMutations.TestDetectEvalAgentKind,TestRelPathForYaml(functions deleted).TestOptimizeDeployCommand_AgentResolvedFromFlagOrYaml→…FromFlagOrProject.