Skip to content

feat(agents): poll for active state after deploy (container + code)#8175

Merged
trangevi merged 2 commits into
Azure:mainfrom
v1212:feature/deploy-poll-active
May 15, 2026
Merged

feat(agents): poll for active state after deploy (container + code)#8175
trangevi merged 2 commits into
Azure:mainfrom
v1212:feature/deploy-poll-active

Conversation

@v1212
Copy link
Copy Markdown
Collaborator

@v1212 v1212 commented May 14, 2026

Summary

  • Adds active-state polling after agent deployment for both container deploy and code deploy paths
  • Replaces inline polling in code deploy with shared waitForAgentActive() function (10s interval, 5min timeout, 2x consecutive confirmation)
  • Container deploy now also waits for the agent version to become active before returning
  • Adds Python 3.14 runtime option for code deploy (now supported by the service)

Design

  • Poll interval: 10 seconds
  • Timeout: 5 minutes
  • Confirmation: Requires 2 consecutive polls with same terminal status ("active" or "failed") to confirm — avoids transient service-side flickers
  • Already active: Skips polling entirely if API response already shows "active"
  • Poll errors: Reset counters, don't count as terminal states

Changes

File Change
service_target_agent.go Add waitForAgentActive() shared polling function; wire it into container deploy path (after createAgent()); replace inline polling in code deploy with waitForAgentActive() call; now polls for ALL code deploy modes (not just remote_build)
init_from_code.go Add Python 3.14 runtime option to selection lists

Notes

E2E Test Results (Round 3)

Full E2E testing on canadacentral (Foundry project wujia-aifproject260512), branch feature/deploy-poll-active.

Result: 15/15 test phases PASSED

Python (ZIP Upload - Code Deploy)

# Scenario Protocol Deploy Invoke Status
1 Template: Invocations invocations PASS
3 Template: Responses responses PASS
5 From-code: Streaming invocations PASS
6 From-code: Non-streaming invocations PASS

.NET (ZIP Upload - Code Deploy)

# Scenario Protocol Deploy Invoke Status
A Template: Invocations invocations PASS
B Template: Agent Framework Responses responses PASS
B-2 From-code: Invocations invocations PASS

Docker/ACR (Container Deploy)

# Scenario Language Deploy Invoke Status
C Container Image (Docker) Python PASS
D Container Image (Docker) .NET PASS

Key Observations

  1. Deploy polling confirmed working — Deploy output shows "Waiting for agent to become active" with spinner, only returns SUCCESS after agent reaches active state
  2. No manual sleep needed between deploy and invoke — polling handles readiness
  3. All scenarios tested using interactive azd ai agent init + azd deploy + curl invoke

Known Issues (not caused by this PR)

  • .NET templates ship with net10.0 in both .csproj and Dockerfile — must downgrade to net9.0 (remote build only supports .NET 9)
  • Docker/ACR path requires AcrPull role assigned to the project's system identity (not account identity)

How to Build

cd cli/azd/extensions/azure.ai.agents
go build ./...
go test ./...

@therealjohn
Copy link
Copy Markdown
Contributor

@v1212 Why is this needed?

We used to have polling for the creation of an agent, but it was changed because the create agent API now only returns once the agent is ready. Is there something different now?

…paths

Replace inline polling in code deploy with shared waitForAgentActive()
function. Add polling to container deploy path. Uses 10s interval,
5min timeout, and requires 2 consecutive confirmations to avoid
transient flickers.
@v1212 v1212 force-pushed the feature/deploy-poll-active branch from 338f9be to 30d498e Compare May 15, 2026 04:54
@v1212 v1212 marked this pull request as ready for review May 15, 2026 07:01
Copilot AI review requested due to automatic review settings May 15, 2026 07:01
@v1212
Copy link
Copy Markdown
Collaborator Author

v1212 commented May 15, 2026

@v1212 Why is this needed?

We used to have polling for the creation of an agent, but it was changed because the create agent API now only returns once the agent is ready. Is there something different now?

as Ankit explained in Teams Channel, the PR aims to make the azd deploy more friendly to handle the deploy request and result from platform LRO. quick improvement from this PR is

image

@v1212 v1212 closed this May 15, 2026
@v1212 v1212 reopened this May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds post-deploy active-state polling for both container and code deploy paths, consolidating the previously inline remote-build polling into a shared helper waitForAgentActive that uses a 10s interval, 5min timeout, and requires two consecutive matching terminal statuses to avoid flaky transitions. Also exposes Python 3.14 as a selectable code-deploy runtime.

Changes:

  • New shared waitForAgentActive helper invoked after createAgent (container) and after ZIP create/update (code) when the version is not already active.
  • Inline remote-build polling in deployHostedCodeAgent removed; polling now runs for all code-deploy modes (bundled + remote_build).
  • promptCodeConfig adds python_3_14 to Python-only and mixed runtime choice lists.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go Adds waitForAgentActive, wires it into container and code deploy flows, removes inline remote_build polling.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go Adds Python 3.14 option to runtime selection lists.

Copy link
Copy Markdown
Contributor

@therealjohn therealjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1212 Link the issue in the PR, or create one and link it.

@trangevi trangevi linked an issue May 15, 2026 that may be closed by this pull request
@trangevi
Copy link
Copy Markdown
Member

/check-enforcer override

@trangevi trangevi enabled auto-merge (squash) May 15, 2026 19:57
@trangevi trangevi merged commit 6c6125a into Azure:main May 15, 2026
32 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Agents Extension] Update Agent Creation Polling Logic

4 participants