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.
azure.yaml, and redeploy. Add an adapter when you bring your own code that doesn’t already implement the hosted agent runtime contract.
Prerequisites
- A hosted agent project. To create one, see Initialize a hosted agent project with the Azure Developer CLI.
- Python 3.10 or later, or .NET 8 or later.
- Your agent logic in a function you can call from a handler.
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 theprotocols field in the azure.ai.agent service in your azure.yaml:
Update your startup command
Make sure thestartupCommand in the azure.ai.agent service points to the entry point that starts the server:
Test locally and redeploy
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 theazure.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.