Skip to main content
Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
A protocol adapter is a lightweight SDK wrapper that lets your agent code speak one of the Microsoft Foundry hosted agent protocols. In this article, you install the SDK adapter package, wire up a handler, declare the protocol in azure.yaml, and redeploy. Add an adapter when you bring your own code that doesn’t already implement the hosted agent runtime contract.

Prerequisites

Choose a protocol

For the full contract details, see Hosted agent runtime contract.

Install the SDK package

Implement a handler

The patterns below are abridged from the bring-your-own samples in the foundry-samples repository. Use them as a starting point and copy the full sample for production code.

Responses protocol

Invocations protocol

Declare the protocol in azure.yaml

Add or update the protocols field in the azure.ai.agent service in your azure.yaml:
For invocations, use the following protocol:

Update your startup command

Make sure the startupCommand in the azure.ai.agent service points to the entry point that starts the server:

Test locally and redeploy

For the invocations protocol, use --input-file to send your custom payload:

Add a second protocol

An agent can support multiple protocols. To add a second one, install the additional SDK package, register both handlers in your entry point, and add both protocols to the azure.ai.agent service in azure.yaml:
When an agent supports multiple protocols, azd ai agent invoke uses the responses protocol by default. Pass -p/--protocol to select responses or invocations explicitly.