Azure / Azure/azure-dev

[Bug] `azure.ai.agent` host does not persist `agent.yaml` environment_variables into the deployed agent version

Open
#9,247 0 comments 0 reactions 0 assignees View on GitHub
bug ext-agents
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

### Summary

With the `azure.ai.agent` host (`azure.ai.agents` beta.5), the *"Registering agent environment variables"* step is effectively a **no-op**: the `environment_variables` declared in `agent.yaml` are **not** embedded into the deployed agent version's definition.

### What happens

Our hosted Foundry agent crashes on boot:

```
AZURE_APPCONFIG_ENDPOINT env var is required
-> 424 session_not_ready
-> /agent/chat returns 500
```

even though `AZURE_APPCONFIG_ENDPOINT` is declared in `agent.yaml`. The deployed version simply doesn't carry the env.

Related: `azure.yaml` `${VAR}` interpolation for `image:` is resolved at project-load (before predeploy), so we also can't point `image:` at the freshly-built immutable tag. (Filed separately.)

### Current workaround

`agent-postdeploy.ts` -> `ensureAgentAppConfigEnv()` uses the Foundry **data-plane API**:

1. `GET .../agents//versions/@latest`
2. if `image != AGENT_DEPLOYED_IMAGE` **or** `environment_variables.AZURE_APPCONFIG_ENDPOINT` is missing -> `POST` a new version cloning the definition, pinning the image, embedding env
3. idempotent — no-op when already correct

### Ask

The `azure.ai.agent` host should actually persist `agent.yaml` `environment_variables` (and the pinned image) into the deployed version's definition. That would let us delete `ensureAgentAppConfigEnv`.

---
_Context: encountered while deploying a multi-component AI/chat service (App Service + Function App + Logic App + Foundry hosted agent) end-to-end with `azd` provision/deploy in [Azure/azure-sdk-tools `tools/sdk-ai-bots/deployment`](https://github.com/Azure/azure-sdk-tools/tree/main/tools/sdk-ai-bots/deployment). We currently work around this with a TypeScript hook._

Contributor guide

Open the contributing guide

Research direction

Start by tracing the azure.ai.agent deployment flow in the azure-dev repository and compare it with the agent-postdeploy.ts workaround described here. Inspect how agent.yaml environment_variables and the pinned image reach the deployed agent version, then verify that the resulting version definition contains both values and that the workaround is no longer needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go, typescript
Domain
ai, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.