OpenAI Agents SDK booking tools that don't double-book.
Wrap AgentDraft in a single @function_tool and hand it to an OpenAI Agents SDK Agent. The agent checks availability and commits bookings through AgentDraft's storage-level conflict engine — so when two agents reach for the same slot, exactly one wins and the loser gets a plain-language message it can act on instead of a double-booked human.
Updated
pip install agentdraft openai-agents
Requires Python 3.9+. The OpenAI Agents SDK ships as the openai-agents package (imported as agents). Set AGENTDRAFT_API_KEY to an avs_live_… agent key from the dashboard, and OPENAI_API_KEY for the model.
from datetime import datetime from agents import Agent, Runner, function_tool from agentdraft import Client, Conflict client = Client() # reads AGENTDRAFT_API_KEY @function_tool def book_meeting(start: str, end: str, title: str) -> str: """Commit a booking. Returns the booking id, or a message to pick another slot if an agent won it first.""" try: booking = client.bookings.commit( start=datetime.fromisoformat(start), end=datetime.fromisoformat(end), idempotency_key=f"{start}-{title}", metadata={"title": title}, ) return f"booked {booking.booking_id} (status={booking.status})" except Conflict as e: return ( f"slot taken by agent {e.winning_agent_id} " f"(priority {e.winning_agent_priority}) — propose another time" ) agent = Agent( name="Scheduler", instructions="Book meetings. If a slot is taken, offer the next one.", tools=[book_meeting], ) Runner.run_sync(agent, "Book me a 30-min call tomorrow at 2pm UTC.")
The booking tool catches Conflict and returns text rather than raising, so a lost race becomes a normal observation the model reasons about — it reads the winner's priority and proposes the next slot. Add a second @function_tool wrapping client.availability.list(...) when you want the agent to look before it books.
| SDK call | Returns | Purpose |
|---|---|---|
| availability.list | list[Slot] | List the slots open to this agent between two times. |
| bookings.commit | Booking | Commit a booking. On a lost race, raises Conflict with the winner's identity and priority — catch it and return text so the model picks another slot. |
| bookings.hold | Booking | Place a short, auto-expiring hold while the agent confirms with a human before committing. |
The OpenAI Agents SDK gives one agent a clean loop of tool-calls — but it has no opinion about the other agents writing to the same human's calendar. If your booking tool calls Google Calendar or Calendly directly, two agents that both pass an availability check both succeed in writing, and the human gets overlapping events. The multi-agent calendar collision is the predictable result.
Routing the booking tool through AgentDraft moves the race from the calendar to the coordination layer. The conflict engine resolves it at the storage layer — a single TransactWriteItems with conditional writes per time bucket — so only the winner ever reaches the underlying calendar. Lost races surface as a typed 409 carrying the winner's identity, priority, and audit reference.
The Agents SDK tool above wraps the same agentdraft Python SDK every other surface uses, so the coordination guarantees are identical no matter how the agent reaches them:
- OpenAI Agents SDK — wrap client.bookings.commit in a @function_tool, as above.
- LangChain / LangGraph / CrewAI — install agentdraft-langchain for ready-made BaseTool subclasses.
- MCP clients — point Claude Desktop, Cursor, or Cline at the AgentDraft MCP server.
- No framework — call client.bookings.commit(...) directly, or hit the REST API from any language.
Frequently asked
Is there a dedicated AgentDraft package for the OpenAI Agents SDK?
No separate package is needed. The OpenAI Agents SDK turns any Python function into a tool with its @function_tool decorator, so you wrap the agentdraft SDK's bookings.commit and availability.list calls directly. That keeps the tool surface yours to shape and avoids a wrapper package that lags the base SDK.
What happens when two Agents SDK agents race for the same slot?
AgentDraft's conflict engine resolves the race at the storage layer via a single conditional write. Exactly one agent wins; the losing bookings.commit raises Conflict carrying the winner's id and priority. Catch it and return a string, and the model reads it as a signal to propose another time instead of an error.
Do I need a paid AgentDraft account to use it with the Agents SDK?
You need an AgentDraft account. Start free on the Developer tier (no card) — one agent, one mailbox, 50 bookings/month. Individual is $10/month for up to three agents; Team is $25/month when multiple agents need shared priority resolution.
- Why AI scheduling agents collide — and what a coordination layer looks like — the protocol-level case for AgentDraft.
- The LangChain integration — drop-in tools if your stack is built on langchain-core.
- Calendar API for AI agents — the underlying HTTP surface the tool calls.