Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs-site/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ no rollback capability. The SDK is the only path to automation.

---

## Decision 2: Delete + Recreate (Not Update)
## Decision 2: Versioned Agents (Not Delete + Recreate)

**Decision:** Each deployment deletes the old agent and creates a fresh one.
**Decision:** Each deployment creates a new **version** of the agent using `agents.create_version()`.

**Why:** Guarantees the deployed agent matches code exactly. No drift.
**Why:** Guarantees the deployed agent matches code exactly. No downtime — old version stays active until the new one is ready. Agent ID is stable across versions.

**Trade-off:** Agent ID changes. Use names, not IDs, for all integrations.
**Trade-off:** Versions accumulate (use the teardown script to clean up old agents).

---

Expand Down
8 changes: 4 additions & 4 deletions docs-site/concepts/agent-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is the most important file in the repository. It:
1. Loads a per-environment JSON config file
2. Reads the system prompt from a markdown file
3. Resolves tool definitions from Python code
4. Produces the exact parameters for `client.agents.create()`
4. Produces the exact parameters for `agents.create_version()`

```python title="src/agent/agent_definition.py" linenums="1"
@dataclass
Expand All @@ -24,7 +24,7 @@ class AgentConfig:
metadata: dict

def to_sdk_params(self) -> dict:
"""Convert to the dict that agents.create() expects (SDK v2)."""
"""Convert to the dict that agents.create_version() expects (SDK v2)."""
from azure.ai.projects.models import PromptAgentDefinition

# Filter to SDK-compatible built-in tools
Expand All @@ -48,7 +48,7 @@ class AgentConfig:
!!! info "SDK v2 — `PromptAgentDefinition`"
The `azure-ai-projects` SDK v2 wraps model, instructions, and tools into a
`PromptAgentDefinition` object. This is passed as the `definition` parameter
to `agents.create()`. The old v1 flat-parameter style (`create_agent(model=..., instructions=...)`)
to `agents.create_version()`. The old v1 flat-parameter style (`create_agent(model=..., instructions=...)`)
no longer works.

## Config File → AgentConfig → SDK Call
Expand All @@ -60,7 +60,7 @@ graph LR
D[tools/*.py] --> B
B --> E[AgentConfig]
E --> F[to_sdk_params]
F --> G[agents.create]
F --> G[agents.create_version]
style E fill:#9f6,stroke:#333
```

Expand Down
29 changes: 14 additions & 15 deletions docs-site/concepts/mental-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ but with different config.
!!! info "Key Insight"
There is no export/import or artifact promotion mechanism.
Your code and config **are** the deployment unit. The SDK
recreates the agent fresh in each environment.
creates a new versioned agent in each environment.

## What Makes Up an Agent?

Expand Down Expand Up @@ -66,8 +66,8 @@ client = AIProjectClient(
credential=DefaultAzureCredential()
)

agent = client.agents.create(
name="my-agent-dev",
agent = client.agents.create_version(
agent_name="my-agent-dev",
definition=PromptAgentDefinition(
model="gpt-4o-mini",
instructions="You are a helpful assistant...",
Expand All @@ -77,27 +77,26 @@ agent = client.agents.create(
)
```

That's it. **Everything else in this repo is plumbing around this call.**
That's it. **Everything else in this repo is plumbing around this call.** If the agent name already exists, it creates a new version; if not, it creates the agent.

- Config files → decide what parameters to pass
- Deploy scripts → wrap this call with error handling and logging
- CI/CD pipelines → run this call in the right environment with the right auth
- Evaluation → validate the agent works after this call

## Why Delete + Recreate?
## Why Versioned Agents?

We delete the old agent and create a fresh one on each deployment.
When delete fails (e.g., RBAC restrictions), the script falls back to updating the existing agent.
We create a new **version** of the agent on each deployment using `agents.create_version()`.
If the agent name doesn't exist yet, it creates the agent. If it already exists, it adds a new version with the updated config.

**Why not just update in place?**
**Why not delete and recreate?**

1. **Guarantees consistency** — the agent matches the code exactly
2. **No drift risk** — partial updates can leave agents in inconsistent states
3. **Simpler logic** — create is idempotent, update has edge cases
4. **Audit trail** — metadata tracks which git commit is deployed
1. **No downtime** — old version stays active until the new one is ready
2. **Stable identity** — agent name persists across deployments
3. **Audit trail** — metadata tracks which git commit is deployed per version
4. **Simpler logic** — `create_version()` handles both new and existing agents

**The trade-off:**

- Agent ID changes each deployment (use names, not IDs)
- Milliseconds of "downtime" during delete → create
- Conversation threads don't carry over (by design — new deploy, fresh start)
- Agent versions accumulate (use the teardown script to clean up)
- Must ensure consumers reference the correct version or latest
5 changes: 3 additions & 2 deletions docs-site/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ pip install -e ".[dev]"
### What API does the SDK call?

The Azure AI Agents API (based on the OpenAI Assistants API).
The key method is `client.agents.create()` (SDK v2). Model, instructions,
and tools are wrapped in a `PromptAgentDefinition` object.
The key method is `agents.create_version()` (SDK v2). Model, instructions,
and tools are wrapped in a `PromptAgentDefinition` object. The call creates
the agent if new, or adds a new version if it already exists.

### Does the SDK support other languages?

Expand Down
4 changes: 2 additions & 2 deletions docs-site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@

!!! warning "There is no artifact to promote"
Unlike containers or binaries, Foundry agents can't be exported and imported.
**CI/CD = recreate the agent from code** in each environment using the SDK.
**CI/CD = deploy the agent from code** in each environment using the SDK.

This is by design. There is no export/import mechanism — your code and config
**are** the deployment artifact. The SDK recreates the agent fresh each time.
**are** the deployment artifact. The SDK creates a new versioned agent each time.

## Before You Start

Expand Down
3 changes: 1 addition & 2 deletions docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ This script:
3. Resolves tool definitions from Python code
4. Builds a `PromptAgentDefinition` (SDK v2) with model, instructions, tools
5. Connects to the DEV Foundry project
6. Checks if the agent exists → deletes old version (or updates if delete fails)
7. Creates a new agent via `agents.create()`
6. Calls `agents.create_version()` — creates the agent if new, or adds a new version if it already exists

### 4c. Evaluate the Agent
```bash
Expand Down
2 changes: 1 addition & 1 deletion src/agent/agent_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AgentConfig:
def to_sdk_params(self) -> dict:
"""
Convert this config into the parameters that the
azure-ai-projects SDK v2 expects for agents.create().
azure-ai-projects SDK v2 expects for agents.create_version().

SDK v2 uses a PromptAgentDefinition object instead of flat params.
"""
Expand Down
Loading