Skip to main content
By using multi-agent orchestration, a model can create and coordinate subagents in parallel, then combine their work into a final response. Use it for complex tasks that benefit from independent workstreams, such as code review, research, documentation, and implementation. This feature is in preview and is available with GPT-5.6 models.

Prerequisites

  • An Azure OpenAI resource in a region that supports the Responses API.
  • A GPT-5.6 model deployment. Check model availability before you create the deployment.
  • Python 3.10 or later.
  • For Microsoft Entra ID authentication, the Cognitive Services OpenAI User role assigned to your identity.
  • For REST requests, cURL and the Azure CLI signed in to your Azure subscription.
  • The latest OpenAI and Azure Identity packages:

Choose when to use multi-agent orchestration

Use multi-agent orchestration when a task can be divided into concrete, independent workstreams. Adding subagents can increase token usage. It might not improve tasks that require an ordered chain of reasoning, frequent writes to shared state, or one slow external operation.

Create a multi-agent response

Use the beta Responses client with api-version=preview. Set multi_agent.enabled to true to let the root agent create subagents. In Azure OpenAI requests, model contains your deployment name, which doesn’t have to match the underlying model name. The following example asks three subagents to evaluate separate disaster-recovery proposals. Each proposal includes enough information for a subagent to work independently, and the root agent reconciles their findings against shared requirements.
  1. Replace YOUR-RESOURCE-NAME with your Azure OpenAI resource name.
  2. If your deployment name isn’t gpt-5.6-sol, replace the value of model with your deployment name.
  3. Run the code, and confirm that the output contains one consolidated review from /root.
Reference: Azure OpenAI v1 API authentication | Use the Azure OpenAI Responses API The output contains the root agent’s comparison and recommendation. Response wording can vary, but the result should identify Beta as the only proposal that meets all stated recovery and budget requirements.
To use an Azure OpenAI API key instead, set AZURE_OPENAI_API_KEY, and create the client as follows:
Reference: Azure OpenAI v1 API authentication

Send a REST request

For REST requests, use the Azure OpenAI v1 endpoint and add api-version=preview.

Microsoft Entra ID

Set AZURE_OPENAI_AUTH_TOKEN to an access token for the Azure AI audience:
Reference: Azure OpenAI v1 API authentication
Reference: Use the Azure OpenAI Responses API

API key

Set AZURE_OPENAI_API_KEY to a key from your Azure OpenAI resource:
Reference: Use the Azure OpenAI Responses API max_concurrent_subagents limits how many subagents can be active at the same time across the entire agent tree. The limit includes children, grandchildren, and deeper descendants, but excludes the root agent. The default is 3, which is recommended for most workloads.

Control delegation

The model decides whether delegation is useful. Make the workstreams explicit in the input when the task requires parallel work. Add developer instructions to control when the root model delegates. For example:
  • Do not create subagents unless the user explicitly asks for delegation or parallel work.
  • Use subagents when parallel work would materially improve speed or quality.
These instructions supplement the orchestration instructions that the service provides to the root agent and subagents.

Understand agent coordination

The agent that receives the original request is the root agent and is named /root. Subagents use hierarchical names that show their position in the agent tree:
The root agent delegates work, waits for results, reconciles findings, and produces the final answer. Subagents use the same model and have access to the tools configured in the original request. The service provides hosted collaboration actions. They appear in a response as multi_agent_call items. Your application must not execute these actions or submit outputs for them.

Handle function calls

Any agent can call developer-defined functions included in the request. Execute every returned function_call, and submit a matching function_call_output. Don’t handle hosted multi_agent_call items as developer-defined functions because the service manages them. With HTTP, a response completes after every active agent finishes or pauses for a client-executed function call. Run all pending function calls, preserve the output items, and submit their outputs in the next request so the paused agents can continue. For the base tool execution pattern, see Function calling.

Inspect multi-agent output

Multi-agent responses can include these additional output item types:
  • multi_agent_call: A hosted collaboration action, such as spawn_agent.
  • multi_agent_call_output: The result of a hosted collaboration action.
  • agent_message: An encrypted message sent from one agent to another.
The call_id field links each multi_agent_call to its corresponding multi_agent_call_output. Each item also has an agent property. For an agent_message, use author and recipient to trace the message direction.
Preserve these items when you manually replay conversation state or collect orchestration traces. Don’t expose encrypted agent messages as user-visible content.

Choose HTTP or WebSocket mode

HTTP and WebSocket transports support the same multi-agent orchestration capabilities, but their function-call behavior differs. In WebSocket mode, send a response.inject event for each function output:
Continue reading events until the response completes and each injection returns either response.inject.created or response.inject.failed. If an injection fails with response_already_completed, send the returned input in a new response that continues from the completed response. For connection and recovery guidance, see Use the Responses API in WebSocket mode.

Apply security controls

Every agent in the tree has access to the tools configured in the original request. Apply the same controls to calls from subagents that you apply to calls from the root agent.
  • Grant tools and calling identities only the permissions required for the task.
  • Validate function arguments and authorize each action in application code.
  • Require user approval before write, destructive, financial, or other high-impact actions.
  • Treat content returned by external tools as untrusted input, and protect against prompt injection.
  • Log the agent name, tool name, arguments, approval decision, and result for auditing.
  • Bound delegated work, and monitor token usage because subagents can increase consumption.

Review limitations

  • The /responses/compact endpoint isn’t supported when multi-agent orchestration is enabled.
  • Automatic server-side compaction is enabled when multi_agent.enabled is true, even if the request doesn’t define context_management. Compaction runs independently for the root agent and each subagent.
  • You can override the compaction threshold by setting context_management.compact_threshold.
  • reasoning.summary isn’t supported when multi-agent orchestration is enabled.
  • max_tool_calls isn’t supported when multi-agent orchestration is enabled.
  • max_concurrent_subagents defaults to 3, which is recommended for most workloads.
  • Multi-agent orchestration has no fixed limit on tree depth or the total number of subagents created during a run. Control concurrency and bound delegated work to manage latency and token usage.

Troubleshoot multi-agent requests