localmTUTS
FollowFollowSubscribe
💻Video + Code Examples·4 mins

A2A with OpenAI Agents SDK

Build a loan validation agent using the OpenAI Agents SDK with @function_tool decorators, Agent class, and Runner.run() execution. Configured for Azure-hosted models via set_default_openai_client — proving the SDK is not locked to OpenAI.

A2A with OpenAI Agents SDK · 4 mins
Instructor:Welcome back to LocalM Tuts. I am Nilay Parikh. This is Lesson 12 of 16, A2A with OpenAI Agents SDK. If you're watching this as a standalone video, you can find the full playlist in the description below. Also you have example GitHub repository link and interactive page link in description. Open the lesson folder and follow along. Loan validation agent with 3 tool functions. The OpenAI Agents SDK class is minimal: model, instructions, and tools. Runner handles the execution loop and we wrap the standard Agent
Instructor:Executor. The OpenAI SDK is the most minimal framework. Agent, tools, Runner, that's it. Handoffs let you route between multiple agents inside the SDK, but externally A2A handles cross-framework routing. Let's see this in action. Install dependencies, set your credentials, and start the server on 10005. Watch the OpenAI runner loop through the calls automatically. Pause the video and try it yourself. Lesson 12. A2A server wrapping with OpenAI Agents SDK. Same architecture as previous ones.
Instructor:Using loan data validation rules. Running a server on 10005 which I managed to get it up and couple of environment variables. Server using A2A. And orchestrator using OpenAI Agents SDK. And it validates, and the client using A2A. So lets. By so, it's using the loan application pre-screening as we send and keeping it simple.
Instructor:It's generating most like only hopefully this particular. Output. If you do not have immediate access to visit through your code or models, you can always use our interactive web page where we have highlighted important code pieces and also some of the good question and answer. It will help you if you are preparing for any interviews. And the step by step setup and running. Let's try this as well. See it works pretty well. It works, compensating factor reasoning, It provided pretty decent outcome.
Instructor:Bob is declined, which he should be. Penter someone has keep it here, let it run and. frameworks down, one to go. Your loan validation agent works very well with a Kimi-K2-Thinking via Azure. It speaks through A2A. The orchestrator can call alongside ADK, LangGraph, and CrewAI agents. Thanks for watching this lesson on LocalM Tuts. Next we will complete the framework tour with the Claude Agent SDK: conversation memory, structured tools, etc. You find the next video in the A2A Protocol
Instructor:course playlist available in this description. See you there.
Learning Objectives5
  • Define tools with @function_tool decorator in the Agents SDK
  • Create an Agent with tools, instructions, and ModelSettings
  • Execute agent tasks with Runner.run() and extract final_output
  • Configure the SDK for Azure-hosted models via set_default_openai_client
  • Wrap the Agents SDK agent as an A2A server with the standard AgentExecutor pattern

Run the Lesson 12 Example

0/5

Clone the examples

git clone https://github.com/nilayparikh/tuts-agentic-ai-examples.git
cd tuts-agentic-ai-examples/a2a/lessons/12-openai-agents-sdk

Set up virtual environment

cd ../../
python -m venv .venv
.venv/Scripts/Activate.ps1
pip install -r requirements.txt

Configure credentials

# _examples/.env
AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com
AZURE_AI_API_KEY=<your-key>

Start the A2A server

cd lessons/12-openai-agents-sdk/src
python server.py

Run the A2A client

cd lessons/12-openai-agents-sdk/src
python client.py
nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/12-openai-agents-sdkGitHub

Complete source code for this lesson.

github.com/nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/12-openai-agents-sdk
Q&A

Q & A

Q

Can the OpenAI Agents SDK really work with non-OpenAI models?

Yes. set_default_openai_client() accepts any OpenAI-compatible client — AsyncAzureOpenAI, local Ollama, or any provider implementing the chat completions API.

Q

What is the difference between handoffs and A2A delegation?

Handoffs route between agents within the same SDK process. A2A delegates to agents in separate processes, potentially running different frameworks. Handoffs are intra-SDK; A2A is inter-framework.

Q

Why is Runner.run() enough — don't you need a loop?

Runner.run() IS the loop. It sends to the model, checks for tool_calls, executes them, appends results, and repeats until done. result.final_output gives you the last text response.

Q

How does @function_tool differ from other tool decorators?

All tool decorators generate JSON schemas from type hints and docstrings. The difference is cosmetic — OpenAI generates OpenAI-format schemas; LangChain generates its own. The end result for the LLM is equivalent.