Skip to content
Merged
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
00f733c
ADR for create/get agent API
dmytrostruk Dec 4, 2025
cd815aa
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 4, 2025
9095e18
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 4, 2025
4a97abe
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 5, 2025
8212dd6
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 6, 2025
8dfb988
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 8, 2025
29faa12
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 9, 2025
5cada6e
Updated ADR with implementation options
dmytrostruk Dec 12, 2025
e8907b0
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 12, 2025
0b9bef4
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 16, 2025
a50bbbf
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 16, 2025
21bb03f
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 29, 2025
9f97e4e
Merge branch 'main' into create-agent-updates
dmytrostruk Dec 30, 2025
bda731f
Small updates
dmytrostruk Dec 30, 2025
238b631
Merge branch 'create-agent-updates' of https://github.com/dmytrostruk…
dmytrostruk Dec 30, 2025
7fbcc08
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 5, 2026
950fc37
Updated decision outcome section
dmytrostruk Jan 5, 2026
f87fcc6
Updated broken links
dmytrostruk Jan 5, 2026
933ab5b
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 6, 2026
7da1a6b
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 7, 2026
2a78424
Small updates
dmytrostruk Jan 7, 2026
ee9d4d1
Fixed merge conflicts
dmytrostruk Jan 7, 2026
02ae9d6
Small fix
dmytrostruk Jan 7, 2026
4413b6e
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 8, 2026
86efe5b
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 11, 2026
de31d11
Updated decision outcome section
dmytrostruk Jan 12, 2026
d1fa6f6
Small fixes
dmytrostruk Jan 12, 2026
0d0636c
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 12, 2026
cf7f96c
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 12, 2026
c020b78
Updated provider naming based on client SDK
dmytrostruk Jan 12, 2026
a985c59
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 12, 2026
58d6a6c
Merge branch 'main' into create-agent-updates
dmytrostruk Jan 13, 2026
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
91 changes: 91 additions & 0 deletions docs/decisions/0011-create-get-agent-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
status: proposed
contact: dmytrostruk
date: 2025-12-03
deciders: dmytrostruk, markwallace-microsoft, eavanvalkenburg, giles17
---

# Create/Get Agent API

## Context and Problem Statement

There is a misalignment between the create/get agent API in the .NET and Python implementations.

In .NET, the `CreateAIAgent` method can create either a local instance of an agent or a remote instance if the backend provider supports it. For remote agents, once the agent is created, you can retrieve an existing remote agent by using the `GetAIAgent` method. If a backend provider doesn't support remote agents, `CreateAIAgent` just initializes a new local agent instance and `GetAIAgent` is not available. There is also a `BuildAIAgent` method, which is an extension for the `ChatClientBuilder` class from `Microsoft.Extensions.AI`. It builds pipelines of `IChatClient` instances with an `IServiceProvider`. This functionality does not exist in Python, so `BuildAIAgent` is out of scope.

In Python, there is only one `create_agent` method, which always creates a local instance of the agent. If the backend provider supports remote agents, the remote agent is created only on the first `agent.run()` invocation.

Below is a short summary of different providers and their APIs in .NET:

| Package | Method | Behavior | Python support |
|---|---|---|---|
| Microsoft.Agents.AI | `CreateAIAgent` (based on `IChatClient`) | Creates a local instance of `ChatClientAgent`. | Yes (`create_agent` in `BaseChatClient`). |
| Microsoft.Agents.AI.Anthropic | `CreateAIAgent` (based on `IBetaService` and `IAnthropicClient`) | Creates a local instance of `ChatClientAgent`. | Yes (`AnthropicClient` inherits `BaseChatClient`, which exposes `create_agent`). |
| Microsoft.Agents.AI.AzureAI (V2) | `GetAIAgent` (based on `AIProjectClient` with `AgentReference`) | Creates a local instance of `ChatClientAgent`. | Partial (Python uses `create_agent` from `BaseChatClient`). |
| Microsoft.Agents.AI.AzureAI (V2) | `GetAIAgent`/`GetAIAgentAsync` (with `Name`/`ChatClientAgentOptions`) | Fetches `AgentRecord` via HTTP, then creates a local `ChatClientAgent` instance. | No |
| Microsoft.Agents.AI.AzureAI (V2) | `CreateAIAgent`/`CreateAIAgentAsync` (based on `AIProjectClient`) | Creates a remote agent first, then wraps it into a local `ChatClientAgent` instance. | No |
| Microsoft.Agents.AI.AzureAI.Persistent (V1) | `GetAIAgent` (based on `PersistentAgentsClient` with `PersistentAgent`) | Creates a local instance of `ChatClientAgent`. | Partial (Python uses `create_agent` from `BaseChatClient`). |
| Microsoft.Agents.AI.AzureAI.Persistent (V1) | `GetAIAgent`/`GetAIAgentAsync` (with `AgentId`) | Fetches `PersistentAgent` via HTTP, then creates a local `ChatClientAgent` instance. | No |
| Microsoft.Agents.AI.AzureAI.Persistent (V1) | `CreateAIAgent`/`CreateAIAgentAsync` | Creates a remote agent first, then wraps it into a local `ChatClientAgent` instance. | No |
| Microsoft.Agents.AI.OpenAI | `GetAIAgent` (based on `AssistantClient` with `Assistant`) | Creates a local instance of `ChatClientAgent`. | Partial (Python uses `create_agent` from `BaseChatClient`). |
| Microsoft.Agents.AI.OpenAI | `GetAIAgent`/`GetAIAgentAsync` (with `AgentId`) | Fetches `Assistant` via HTTP, then creates a local `ChatClientAgent` instance. | No |
| Microsoft.Agents.AI.OpenAI | `CreateAIAgent`/`CreateAIAgentAsync` (based on `AssistantClient`) | Creates a remote agent first, then wraps it into a local `ChatClientAgent` instance. | No |
Comment thread
dmytrostruk marked this conversation as resolved.
| Microsoft.Agents.AI.OpenAI | `CreateAIAgent` (based on `ChatClient`) | Creates a local instance of `ChatClientAgent`. | Yes (`create_agent` in `BaseChatClient`). |
| Microsoft.Agents.AI.OpenAI | `CreateAIAgent` (based on `OpenAIResponseClient`) | Creates a local instance of `ChatClientAgent`. | Yes (`create_agent` in `BaseChatClient`). |

## Decision Drivers

- API should be aligned between .NET and Python.
- API should be intuitive and consistent between backend providers in .NET and Python.

## Considered Options

Add missing implementations on the Python side. This should include the following:

### agent-framework-azure-ai (both V1 and V2)

- Add a `get_agent` method that accepts an underlying SDK agent instance and creates a local instance of `ChatAgent`.
Comment thread
dmytrostruk marked this conversation as resolved.
- Add a `get_agent` method that accepts an agent identifier, performs an additional HTTP request to fetch agent data, and then creates a local instance of `ChatAgent`.
- Override the `create_agent` method from `BaseChatClient` to create a remote agent instance and wrap it into a local `ChatAgent`.

.NET:

```csharp
var agent1 = new AIProjectClient(...).GetAIAgent(agentSdkInstance); // Creates a local ChatClientAgent instance
var agent2 = new AIProjectClient(...).GetAIAgent(agentName); // Fetches agent data, creates a local ChatClientAgent instance
var agent3 = new AIProjectClient(...).CreateAIAgent(...); // Creates a remote agent, returns a local ChatClientAgent instance
```

Python:

```python
agent1 = AIProjectClient(...).get_agent(agent_sdk_instance) # Creates a local ChatAgent instance
Comment thread
dmytrostruk marked this conversation as resolved.
Outdated
agent2 = AIProjectClient(...).get_agent(agent_name) # Fetches agent data, creates a local ChatAgent instance
agent3 = AIProjectClient(...).create_agent(...) # Creates a remote agent, returns a local ChatAgent instance
Comment thread
dmytrostruk marked this conversation as resolved.
Outdated
```

### agent-framework-core (OpenAI Assistants)

- Add a `get_agent` method that accepts an underlying SDK agent instance and creates a local instance of `ChatAgent`.
- Add a `get_agent` method that accepts an agent name, performs an additional HTTP request to fetch agent data, and then creates a local instance of `ChatAgent`.
- Override the `create_agent` method from `BaseChatClient` to create a remote agent instance and wrap it into a local `ChatAgent`.

.NET:

```csharp
var agent1 = new AssistantClient(...).GetAIAgent(agentSdkInstance); // Creates a local ChatClientAgent instance
var agent2 = new AssistantClient(...).GetAIAgent(agentId); // Fetches agent data, creates a local ChatClientAgent instance
var agent3 = new AssistantClient(...).CreateAIAgent(...); // Creates a remote agent, returns a local ChatClientAgent instance
```

Python:

```python
agent1 = OpenAIAssistantsClient(...).get_agent(agent_sdk_instance) # Creates a local ChatAgent instance
agent2 = OpenAIAssistantsClient(...).get_agent(agent_name) # Fetches agent data, creates a local ChatAgent instance
agent3 = OpenAIAssistantsClient(...).create_agent(...) # Creates a remote agent, returns a local ChatAgent instance
```

## Decision Outcome

TBD
Comment thread
dmytrostruk marked this conversation as resolved.
Outdated