/nextjs-ai-skills:openai-agents-sdkfrom nextjs-ai-skills
Guides development with the openai-agents Python SDK: building AI agents, multi-agent handoffs, function tools, guardrails, sessions, streaming, and tracing. Covers Runner usage, @function_tool, AgentOutputSchema, SQLiteSession, and Azure OpenAI via LiteLLM.
Ships in nextjs-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill for openai-agents / agents, not the TypeScript SDK.
Resolve the installed package and its provider integrations before implementing
an API. Current SDK documentation
and a matching source tag take precedence over static examples.
Choose a model from the current OpenAI model catalog and model-selection guide. Check the selected model's tools, reasoning settings and provider availability; an SDK fallback or a demo ID is not a permanent recommendation.
The wheel ships no docs. Offline, read the installed source: the version from
importlib.metadata.version("openai-agents"), public exports in
agents/__init__.py, docstrings and types in the package directory
(python -c "import agents; print(agents.__file__)"). The documentation
source is docs/ at repository tag v<version>.
Runner.run_sync raises inside a running event loop (async handlers and
notebooks); use await Runner.run(...). Runner.run_streamed(...) itself
is not awaited; consume its stream_events() async iterator to completion.
Checked with openai-agents 0.24.0; confirm names in the installed source for another version:
import asyncio
from pydantic import BaseModel
from agents import Agent, ModelSettings, Runner, SQLiteSession, function_tool
from openai.types.shared import Reasoning
class OrderAnswer(BaseModel):
order_id: str
status: str
reply: str
@function_tool
def get_order_status(order_id: str) -> str:
"""Return an order's shipping status.
Args:
order_id: Order ID given by the customer.
"""
return f"{order_id}: shipped" # authorize and read the app's data here
support = Agent(
name="Support",
instructions="Answer order questions. Use get_order_status for order data.",
model="gpt-6.1-sol", # example API ID; use the project's configured model
model_settings=ModelSettings(reasoning=Reasoning(effort="medium")),
tools=[get_order_status],
output_type=OrderAnswer,
)
# A manager keeps control with tools=[order_tool]; handoffs=[support] transfers it.
order_tool = support.as_tool("order_support", "Answer an order question.")
async def main() -> None:
session = SQLiteSession("user-123", "conversations.db") # ID owned by the signed-in user
result = await Runner.run(support, "Where is order A-17?", session=session)
answer: OrderAnswer = result.final_output # validated OrderAnswer instance
print(answer.status, answer.reply)
asyncio.run(main())
The example uses Responses (the SDK's default API). GPT-6.1 Sol
requires Responses for tool calling and does not support none or minimal
reasoning effort.
agent.as_tool() when the
manager should continue after delegated work. A fixed pipeline does not need
extra agents merely to implement ordinary control flow.Use the OpenAI Developer Docs MCP (https://developers.openai.com/mcp) if
available for current OpenAI API/provider behavior, or its plain-text index
https://developers.openai.com/api/docs/llms.txt; use the Python SDK's own
reference for SDK signatures. Read selected
official examples
from a compatible tag, not a copied catalog of demos.
Verify changed tools, multi-turn history, approval/denial and failure recovery.
Use installed agents.testing (verified in 0.24.0) for offline orchestration:
ScriptedModel, ModelStep, assistant_message, function_call and
model.assert_complete(), with RunConfig(tracing_disabled=True); assigning
agent.model = ScriptedModel([...]) runs the core shape offline. Run the
project's checks; report missing provider access separately from verified SDK
behavior.
references/guardrails.md (opens in a new tab)references/handoffs.md (opens in a new tab)references/patterns.md (opens in a new tab)references/providers.md (opens in a new tab)references/sandbox.md (opens in a new tab)references/sessions.md (opens in a new tab)references/streaming.md (opens in a new tab)references/structured-output.md (opens in a new tab)references/tools.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
openai-agents, ai-agents, function-tools, agent-handoffs, python-sdk
npx claudepluginhub laguagu/claude-code-nextjs-skills --plugin nextjs-ai-skills24 skills in this plugin
/agent-harness-reviewReviews an agent harness or agent design against Anthropic's agent and model prompting guidance (Opus 5.5, Fable 5.2), Cognition's context principles and 2026 research on skill routing and skill-induced failures. Covers when subagents or parallel agents pay off, how to brief them, how many skills, plugins, MCP servers and hooks load every session, tool design and proportionate verification. Use when auditing a Claude Code or Codex setup, deciding whether to add subagents or a multi-agent workflow, trimming a skill library, or designing an agent loop in an app. For writing a new skill or measuring a skill's trigger rate with evals, use skill-creator./ai-appBuilds full-stack Next.js AI applications with the AI SDK and the shadcn/ui AI Elements patterns. Use when creating a chatbot, agent dashboard or custom AI application./ai-elementsMaintains AI chat UI built from elements.ai-sdk.dev AI Elements components already copied into the project. Use when changing or debugging those components (conversations, messages, prompt inputs, attachments, reasoning, tool output, sources). New chat UI uses the shadcn/ui AI Elements patterns (`shadcn` skill)./ai-sdkAnswer questions about the AI SDK and help build AI-powered features. Use when developers ask about Vercel AI SDK, generateText, streamText, ToolLoopAgent, useChat, AI SDK providers, tools, structured output, embeddings or streaming, or want to add AI features to a TypeScript or JavaScript app. First identify the installed major version and route version-specific work: use ai-sdk-7 for AI SDK 7 features/migrations such as WorkflowAgent, HarnessAgent, reasoning, runtime/tools context, toolApproval, telemetry, realtime, or v6-to-v7 upgrades; for v6 code read the docs shipped in the installed package./ai-sdk-6Vercel AI SDK v6 development, for projects already on ai@6. Use when building or maintaining AI agents, chatbots, tool integrations, streaming apps, or structured output in a v6 codebase. New projects and ai@7 code use ai-sdk-7; an unknown version goes through ai-sdk. Covers ToolLoopAgent, useChat, generateText, streamText, tool approval, provider tools, MCP integration, and Output patterns./ai-sdk-7Vercel AI SDK v7 development and migration. Use when building or upgrading AI SDK 7 apps, especially ToolLoopAgent, WorkflowAgent, HarnessAgent, Claude Code/Codex/Pi harnesses, runtimeContext, toolsContext, toolApproval, telemetry, reasoning, file or skill uploads, realtime, video generation, or v6-to-v7 breaking changes. For version discovery, v6 code and general doc lookup use ai-sdk.Other plugins' skills for the same job