fix: detect modern Python agents for code deploy#9171
Conversation
|
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. |
|
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. |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
Centralizes project-language detection and adds pyproject.toml support for Python code deployment.
Changes:
- Shares Python/.NET/Node detection across initialization and local-run flows.
- Adds regression tests for supported and unsupported projects.
- Documents the fix in the extension changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
init.go |
Uses shared code-deploy detection. |
init_from_code.go |
Replaces legacy language detectors. |
init_adopt.go |
Applies shared detection during adoption. |
helpers.go |
Implements consolidated language detection. |
helpers_test.go |
Adds language-detection coverage. |
CHANGELOG.md |
Documents the Python detection fix. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot rebase with latest main branch |
The branch is already up-to-date with |
jongio
left a comment
There was a problem hiding this comment.
Heads up on the diff scope: most of what shows in "Files changed" here isn't part of this change. The local-preflight to arm-provision rename, the telemetry event/field renames, the core CLI version bump, and the extension changelog/version bumps all come from already-merged PRs (#8844, #9163, #9182), not from this branch.
Diffed against current main, this PR is 6 files, all under extensions/azure.ai.agents/internal/cmd/:
helpers.gohelpers_test.goinit.goinit_adopt.goinit_adopt_deploymode_test.goinit_from_code.go
The PR's recorded base is 168f02a (before those merges), which is why the bot flagged an arm-provision gRPC contract break, telemetry-name breakage, and unrelated version bumps. None of those files are in the actual change, so those aren't action items on this PR. Re-syncing the base so the bot and reviewers stop re-reviewing already-merged code would help.
On the real change: the lone-.py fallback is gated by languages.python && !languages.node, and detectProjectType checks node before the standalone main.py, so a Node agent carrying an incidental helper like tools.py stays on container deploy. Recognizing pyproject.toml as a code-deploy signal is the #9123 fix.
The open items are @trangevi's two questions on helpers.go (the warning log and the conditional). Those are what need resolving before this merges.
0449907 to
5013818
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
The two items I flagged on helpers.go are now addressed in 5013818:
- The failed
os.ReadDirindetectProjectLanguageslogs a warning instead of silently returning an empty result.logis already imported. supportsCodeDeployis split out with a comment explaining that Python metadata is authoritative and a lone.pyfile only counts as a fallback when there is nopackage.json. Behavior is unchanged from the inlined condition, just readable.
The new table tests cover the node-plus-python-helper and standalone-python cases, and CI is green. The remaining unresolved threads (validation_provider, events, CHANGELOG, config_options) are outdated against the pre-rebase base and are not part of this diff anymore.
Fixes: #9123
Why
The "Use the code in the current directory" flow used a separate, older language detector that did not recognize
pyproject.toml. Modern Python projects could therefore be treated as unsupported, silently routed to container deployment, and prompted for an unnecessary Azure Container Registry.What changed
pyproject.tomlas a Python code-deploy signal while preserving existingrequirements.txt,*.py, and*.csprojbehavior.Why this approach
Sharing one set of project signals prevents init and local-run behavior from drifting again. The change stays shallow and uses the selected source directory as the deployment root, avoiding false positives from nested projects whose entry point and service path would not match the chosen root.
Validation
go test ./internal/cmdgo test ./...PR extension validation
azure.ai.agentsextension and packaged it as a self-contained bundle.azd extension installinto an isolatedAZD_CONFIG_DIR;azd ai agent versionreported PR commitc68cc1106.azd ai agent,azd ai agent init --help, andazd ai agent code --helpthrough the azd host.azd ai agent init --no-prompt --deploy-mode codepath for Python code deployment. It correctly reached the extension.