Skip to main content
A migration tool is available to help automate migration from the Assistants API to Agents.
Foundry Agent Service provides an upgraded developer experience for building intelligent agents that are easy to build, version, operate, and observe. The new agents API introduces a modernized SDK, new enterprise-grade capabilities, and preserves the identity, governance, and observability features you rely on today.

Prerequisites

  • An Azure subscription. Create one for free.
  • A Microsoft Foundry project.
  • The Foundry Agent Service SDK for your language, and corresponding identity package for authentication. Install the packages for your language and sign in with az login or use DefaultAzureCredential:
  • Existing agents or assistants code that you want to migrate.
The following code initializes the clients used throughout this guide:
Use project for agent creation and versioning. Use openai (or the equivalent in your language) for conversations and responses.

Key benefits

The new agents provide the following benefits: Developer productivity
  • More models. Generate responses by using any Foundry model either in your agent or directly as a response generation call.
  • More features. Web Search, File Search, Code Interpreter, MCP tool calling, image generation, and reasoning summaries.
  • Modern API primitive. Built on the Responses API instead of the older Assistants API.
  • Background mode. Support for long-running tools (like image-generation), and durable streams (supports disconnect/reconnect scenarios)
  • Future-proof. New features and model support are only added to the new agents.
  • New agent types. Create prompt-based agents and Hosted agents.
Enterprise readiness
  • Single-tenant storage. Use single-tenant storage, with the option to bring your own Azure Cosmos DB to store state and keep your data secure.
  • Enhanced security. Control who can run or modify agent definitions.
  • Separation of duties. Define agents once and execute them with various inputs.
  • Deployable agents. Agents can be exposed as individual endpoints.
API modernization
  • Improved state management. Uses conversations instead of threads and messages.
  • Stateful context. Automatically retains context across calls.
  • Superset of Responses API. Builds on the Responses API and adds more capabilities.
  • Single or multi-agent workflows. Easily chain agents for complex workflows.

Key changes

The following table summarizes the main API changes between the previous and current agent experience.

Agent tool availability

The following table compares agent tools available in classic agents and the new Foundry Agent Service. Use it to identify which tools carry over directly, which have changed, and which are exclusive to the new experience.
In the new API, the conversations and responses APIs use the OpenAI client (or its language equivalent). In Python, call project.get_openai_client(). In C#, use projectClient.ProjectOpenAIClient.GetProjectResponsesClientForAgent(). In JavaScript, call projectClient.getOpenAIClient(). In Java, use AgentsClientBuilder to build a ResponsesClient. Agent creation and versioning remain on the project client. The examples in each section show which client to use.

Migrate threads to conversations

Threads stored messages on the server side. A conversation can store items, including messages, tool calls, tool outputs, and other data.

Requests

The following examples compare thread creation (previous) with conversation creation (current). The current approach uses the OpenAI client obtained from project.get_openai_client(). Previous - threads
Current - conversations

Responses

The JSON responses show the structural differences between thread objects and conversation objects. Previous - threads
Current - conversations

Add items to an existing conversation

After you create a conversation, use conversations.items.create() to add subsequent messages. This pattern replaces adding messages to threads with client.agents.messages.create(). Previous - add a message to a thread
Current - add items to a conversation

Migrate runs to responses

Runs were asynchronous processes that executed against threads. Responses are simpler: provide a set of input items to execute and get a list of output items back. Responses can be used alone, or with conversation objects for storing context. The responses API uses the OpenAI client.

Requests

The following examples compare how you invoke agent logic. The previous approach used asynchronous runs with polling. The current approach calls responses.create() on the OpenAI client. Previous - runs
Current - responses

Responses

Previous - runs
Current - responses

Migrate classic agents to new agents

If you use the client.agents.create_agent() method from earlier SDK versions, migrate to client.agents.create_version(). The new method introduces structured agent definitions with explicit kind, model, and instructions fields.

Requests

Previous
Current

Responses

The following JSON examples compare the response objects returned by the previous and current agent creation methods. Previous
Current

Migrate assistants to new agents

If your code uses the OpenAI Assistants API (client.beta.assistants.create()), migrate to the Foundry Agent Service by using client.agents.create_version(). The following examples show the structural differences. Previous - assistants
Current - new agents

Run the migration tool

A migration tool is available on GitHub to help automate the migration of your agents and assistants. The tool migrates code constructs such as agent definitions, thread creation, message creation, and run creation. It doesn’t migrate state data like past runs, threads, or messages. After migration, you can run the new code, and any new state data is created in the updated format. The following example shows a complete before-and-after comparison. Notice that the current code uses both project for agent creation and openai for conversations and responses. Previous
Current

Verify your migration

After you migrate your code, confirm that everything works correctly:
  1. Run the updated code and verify that it executes without errors.
  2. Check agent creation by confirming that create_version() returns an object with an id and version field.
  3. Test a conversation by creating a conversation, sending a response, and verifying that output items are returned.
  4. Confirm context retention by sending multiple responses to the same conversation and checking that the agent remembers earlier messages.

Troubleshoot common issues