Agent skill

Openai Agents

by kid-sid in kid-sid/claude-spellbook

A skill your agent uses when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating…

MITAuto-check passedAI & LLM Engineering

Install Openai Agents

skills CLI
$ npx skills add kid-sid/claude-spellbook --skill openai-agents -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install kid-sid/claude-spellbook openai-agents --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/kid-sid/claude-spellbook.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/openai-agents .claude/skills/openai-agents && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
openai-agents
GitHub stars
190
Token cost
~3.4k tokens
SKILL.md length
539 words
Files
1
Skills in repo
55
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating…

  • Debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs
  • SKILL.md covers When to Activate, Core Concepts, Minimal Agent and Defining Tools, plus 11 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Wiring typed context

What it does

Openai Agents is an agent skill from kid-sid/claude-spellbook. Use when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating with the Agentex ADK.

Its SKILL.md is about 3.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering LLM API integration and LLM guardrails. It works with OpenAI and OpenAI Agents SDK. The repository describes itself as: A curated collection of skills, prompts, and workflows that extend Claude's capabilities — your personal grimoire for AI-powered development. The licence is MIT.

When your agent uses it

  • Debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs
  • Wiring typed context
  • Streaming responses
  • Adding guardrails

Example prompts

  • “/openai-agents”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit a7c2ac9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Openai Agents loads about 3.4k tokens when it runs. Until then it costs about 54 tokens; SKILL.md has 539 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~3.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from kid-sid/claude-spellbook at commit a7c2ac9, republished under its MIT licence (© kid-sid). 539 words, ~3,351 tokens.

Download SKILL.mdSave it as .claude/skills/openai-agents/SKILL.md (or your agent's skills folder).
name
openai-agents
description
Use when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating with the Agentex ADK.

OpenAI Agents SDK Patterns

The OpenAI Agents SDK (openai-agents) orchestrates LLM agents with tools, handoffs, and tracing.

When to Activate

  • Defining agents with system prompts, tools, and handoffs
  • Writing @function_tool decorators and tool schemas
  • Running agents with Runner.run() or streaming with Runner.run_streamed()
  • Implementing multi-agent handoffs (triage → specialist)
  • Debugging tool call errors, context leaks, or infinite loops
  • Integrating with Agentex ADK via adk.providers.openai
  • Adding tracing spans for observability

Core Concepts

Agent
├── name, instructions (system prompt)
├── tools     — functions the agent can call
├── handoffs  — other agents it can delegate to
├── model     — LLM to use (default: gpt-4o)
└── output_type — structured Pydantic output (optional)

Runner
├── .run()          — async, returns final output
├── .run_streamed() — async generator, streams events
└── .run_sync()     — sync wrapper (testing/scripts)

Minimal Agent

python
from agents import Agent, Runner, function_tool

@function_tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"It's sunny and 72°F in {city}."

agent = Agent(
    name="Weather Agent",
    instructions="You help users check weather. Always use the get_weather tool.",
    tools=[get_weather],
    model="gpt-4o-mini",
)

# Run
result = await Runner.run(agent, "What's the weather in Tokyo?")
print(result.final_output)

Defining Tools

python
from agents import function_tool
from pydantic import BaseModel

# Simple tool — docstring becomes the tool description
@function_tool
def search_web(query: str) -> str:
    """Search the web for current information. Returns the top results."""
    return web_search_api(query)

# Tool with multiple typed params
# NOTE: `eval()` on a tool argument is RCE — the model can pass `__import__(...)`.
# Use a constrained evaluator like `simpleeval` (or `ast.literal_eval` for literals).
from simpleeval import simple_eval

@function_tool
def calculate(expression: str, precision: int = 2) -> str:
    """Evaluate a mathematical expression and return the result."""
    result = simple_eval(expression)
    return str(round(result, precision))

# Tool returning structured data
class SearchResult(BaseModel):
    title: str
    url: str
    snippet: str

@function_tool
def search_docs(query: str, limit: int = 5) -> list[SearchResult]:
    """Search the documentation. Returns matching articles."""
    return [SearchResult(...) for r in docs_search(query, limit)]

# Async tool
@function_tool
async def fetch_user(user_id: str) -> dict:
    """Fetch user profile from the database."""
    user = await db.get_user(user_id)
    return user.model_dump()

Tool naming: the function name becomes the tool name. Keep names short and action-oriented (search_web, not search_the_web_for_information).


Context (passing data to tools without LLM)

python
from agents import Agent, Runner, RunContextWrapper, function_tool
from dataclasses import dataclass

@dataclass
class AppContext:
    user_id: str
    db_session: AsyncSession

# Tools receive context as first param (not exposed to LLM)
@function_tool
async def get_my_orders(ctx: RunContextWrapper[AppContext]) -> list[dict]:
    """Get the current user's orders."""
    orders = await OrderCRUD(ctx.context.db_session).list_for_user(ctx.context.user_id)
    return [o.model_dump() for o in orders]

agent = Agent[AppContext](
    name="Order Agent",
    instructions="Help users check their orders.",
    tools=[get_my_orders],
)

context = AppContext(user_id="u-123", db_session=session)
result = await Runner.run(agent, "Show my recent orders", context=context)

Structured Output

python
from pydantic import BaseModel
from agents import Agent, Runner

class EmailDraft(BaseModel):
    subject: str
    body: str
    tone: Literal["formal", "casual", "urgent"]

agent = Agent(
    name="Email Writer",
    instructions="Draft professional emails based on user requests.",
    output_type=EmailDraft,   # forces structured JSON response
)

result = await Runner.run(agent, "Write a follow-up email for a job interview")
email: EmailDraft = result.final_output   # typed, validated by Pydantic
print(email.subject)

Handoffs (Multi-Agent)

Handoffs let one agent delegate to another specialized agent. The triage agent decides which specialist handles the task.

python
from agents import Agent, handoff, Runner

coding_agent = Agent(
    name="Coding Assistant",
    instructions="You solve programming problems. Write clean, working code.",
    tools=[search_docs, run_code],
)

writing_agent = Agent(
    name="Writing Assistant",
    instructions="You help with writing, editing, and proofreading.",
)

triage_agent = Agent(
    name="Triage",
    instructions="""Route the user to the right specialist:
    - For code/programming questions → coding_assistant
    - For writing/editing requests → writing_assistant
    - Handle simple questions yourself.""",
    handoffs=[coding_agent, writing_agent],
)

result = await Runner.run(triage_agent, "Fix this Python bug: ...")
# triage_agent may hand off to coding_agent, which runs to completion
print(result.final_output)

Customizing handoff behavior:

python
from agents import handoff

def on_handoff_to_billing(ctx: RunContextWrapper[AppContext]):
    # Called when handoff happens — log, update state, etc.
    logger.info(f"Handing off to billing for user {ctx.context.user_id}")

billing_agent = Agent(name="Billing", instructions="...")

triage_agent = Agent(
    handoffs=[
        handoff(billing_agent, on_handoff=on_handoff_to_billing),
    ]
)

Streaming

python
from agents import Runner
from agents.stream_events import RunItemStreamEvent, AgentUpdatedStreamEvent

async def stream_agent(agent, prompt: str):
    stream = Runner.run_streamed(agent, prompt)
    async for event in stream.stream_events():
        if isinstance(event, RunItemStreamEvent):
            # Each completed item (tool call, tool result, message)
            item = event.item
            if hasattr(item, "raw_item"):
                raw = item.raw_item
                if raw.get("type") == "response.output_text.delta":
                    print(raw["delta"], end="", flush=True)

    return await stream.get_final_output()

# FastAPI SSE endpoint
@router.get("/stream")
async def stream_response(prompt: str):
    async def generate():
        stream = Runner.run_streamed(agent, prompt)
        async for event in stream.stream_events():
            if isinstance(event, RunItemStreamEvent):
                item = event.item
                if hasattr(item, "raw_item"):
                    delta = item.raw_item.get("delta", "")
                    if delta:
                        yield f"data: {delta}\n\n"
    return StreamingResponse(generate(), media_type="text/event-stream")

Guardrails

Guardrails validate input/output before the agent processes or responds.

python
from agents import Agent, input_guardrail, output_guardrail, GuardrailFunctionOutput

@input_guardrail
async def no_pii(ctx, agent, input) -> GuardrailFunctionOutput:
    text = input if isinstance(input, str) else str(input)
    if contains_pii(text):
        return GuardrailFunctionOutput(
            output_info="PII detected",
            tripwire_triggered=True,    # stops the agent
        )
    return GuardrailFunctionOutput(output_info="clean", tripwire_triggered=False)

@output_guardrail
async def no_harmful_content(ctx, agent, output) -> GuardrailFunctionOutput:
    if is_harmful(str(output)):
        return GuardrailFunctionOutput(
            output_info="harmful content",
            tripwire_triggered=True,
        )
    return GuardrailFunctionOutput(output_info="safe", tripwire_triggered=False)

agent = Agent(
    name="Safe Agent",
    instructions="...",
    input_guardrails=[no_pii],
    output_guardrails=[no_harmful_content],
)

Tracing

python
from agents import Agent, Runner
from agents.tracing import trace, custom_span

# Runner automatically creates a root trace
result = await Runner.run(agent, "Hello", run_config=RunConfig(
    trace_id="my-trace-123",        # link to your own tracing system
    trace_metadata={"user_id": "u-123"},
))

# Add custom spans inside tools
@function_tool
async def complex_search(query: str) -> str:
    """Search across multiple sources."""
    with custom_span("db_search"):
        db_results = await db.search(query)
    with custom_span("web_search"):
        web_results = await web.search(query)
    return combine(db_results, web_results)

Agentex ADK Integration

In Agentex Temporal agents, use adk.providers.openai instead of calling Runner directly — it handles message streaming to the UI automatically.

python
from agentex.lib import adk
from agents import Agent, function_tool

@function_tool
async def search_web(query: str) -> str:
    """Search the web for information."""
    return await web_search(query)

agent = Agent(
    name="Research Agent",
    instructions="Research topics thoroughly using web search.",
    tools=[search_web],
    model="gpt-4o",
)

# In a Temporal activity:
async def run_research_agent(params: AgentParams) -> str:
    result = await adk.providers.openai.run_agent_streamed_auto_send(
        agent=agent,
        task_id=params.task_id,
        input=params.user_message,
        # context=AppContext(...)  if using typed context
    )
    return result.final_output

# run_agent_streamed_auto_send:
# - streams each token to the Agentex UI via adk.messages
# - wraps Runner.run_streamed internally
# - handles tracing integration

RunConfig Options

python
from agents import RunConfig

result = await Runner.run(
    agent,
    "Hello",
    run_config=RunConfig(
        model="gpt-4o",                    # override agent's model
        model_settings=ModelSettings(
            temperature=0.2,
            max_tokens=2000,
        ),
        max_turns=10,                       # prevent infinite agent loops
        trace_id="req-abc-123",
        workflow_name="my-workflow",        # appears in traces
    ),
)

Common Errors

ErrorCauseFix
MaxTurnsExceededAgent looping (tool → agent → tool)Set max_turns, check for circular handoffs
Tool not calledWeak system promptBe explicit: "You MUST use X tool to answer"
Wrong handoffAmbiguous triage instructionsList exact conditions for each handoff
ValidationError in toolPydantic type mismatch in returnEnsure return type matches annotation
Context None in toolForgot to pass context= to RunnerPass context=your_context in Runner.run()

Red Flags

  • No max_turns set — without a turn limit an agent that calls a tool whose result triggers another tool call can loop indefinitely; always pass RunConfig(max_turns=N) to cap runaway execution
  • Passing app state (DB session, user ID) through the LLM — including session objects or sensitive IDs in the prompt or tool return values exposes them to the model and wastes tokens; use typed context (RunContextWrapper) so tools receive state without the LLM ever seeing it
  • Vague tool docstrings — the docstring is the only description the LLM sees; "Does stuff with the database" gives the model no signal on when to call it; write one sentence that says exactly what the tool returns and when to use it
  • Vague handoff instructions in the triage agent — "Route to the right agent" with no criteria leads to random or wrong handoffs; list the exact conditions for each handoff in the triage agent's instructions
  • Using Runner.run() directly inside an Agentex activity — Runner.run() doesn't stream tokens to the Agentex UI; use adk.providers.openai.run_agent_streamed_auto_send() which wraps Runner.run_streamed() and handles token delivery automatically
  • No input/output guardrails on user-facing agents — agents that handle user-supplied text without guardrails can be prompted to leak context, call wrong tools, or produce harmful output; add @input_guardrail and @output_guardrail for sensitive deployments
  • Tool names that are long or vague — the model uses the tool name as a primary signal; search_the_web_for_current_information is worse than search_web; keep tool names short, lowercase, and verb-noun
Show full SKILL.md (73 more words)Show less

Checklist

  • Tool docstrings are clear — they become the LLM-facing description
  • Context used for app state (DB session, user ID) — not passed through LLM
  • output_type set for structured outputs — avoids parsing LLM text
  • max_turns set to prevent runaway agent loops
  • Handoff instructions are specific — vague routing leads to wrong agent
  • run_agent_streamed_auto_send used in Agentex activities (not Runner directly)
  • Guardrails added for user-facing agents handling sensitive data
  • Tool names are short verb-noun: get_user, search_docs, send_email

© kid-sid, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/openai-agents of kid-sid/claude-spellbook.

Open the folder on GitHubat commit a7c2ac9

Compare with similar skills

Openai Agents next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Openai Agents compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Openai Agents this skillkid-sid/claude-spellbook190—~3.4kAutomated safety check: PassMIT
Migrating Openai Agents SDK To Pydantic AIpydantic/pydantic-ai20k—~1.8kAutomated safety check: PassMIT
Openai Agentscoco-research/coco503—~3.3kAutomated safety check: PassMIT
New Openai SDK Appsandgardenhq/sgai137—~3.9kAutomated safety check: NotesCustom licence
Scaffolding Openai Agentsaiskillstore/marketplace430—~3.3kAutomated safety check: PassNone
ModLens Image Vision Bridgeliustack/modlens4.2k—~1.3kAutomated safety check: NotesMIT

Similar skills

  • Official

    Migrate Python OpenAI Agents SDK applications to Pydantic AI and, when warranted, Pydantic AI Harness.

    20k GitHub stars~1.8k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Openai Agents

    coco-research/coco

    Build AI applications with OpenAI Agents SDK - text agents, voice agents, multi-agent handoffs, tools with Zod schemas, guardrails, and streaming.

    503 GitHub stars~3.3k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • New Openai SDK App

    sandgardenhq/sgai

    Create and setup a new OpenAI Agents SDK application with interactive guidance for language choice, agent type selection (Basic, Voice, Realtime), project setup, and automatic verification.

    137 GitHub stars~3.9k tokensUpdated 18 days ago
    AI & LLM EngineeringAuto-check: notes
  • Scaffolding Openai Agents

    aiskillstore/marketplace

    Builds AI agents using OpenAI Agents SDK with async/await patterns and multi-agent orchestration.

    430 GitHub stars~3.3k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Gives text-only models sight by running the modlens CLI on an image path or URL and returning structured JSON evidence with transcribed text, layout and semantics.

    4.2k GitHub stars~1.3k tokensUpdated 5 days ago
    AI & LLM EngineeringAuto-check: notes
  • Sets up access to the 9Router AI gateway, an OpenAI-compatible REST endpoint for chat, images, speech, embeddings, web search and web fetch, and indexes its capability skills.

    30k GitHub stars~744 tokensUpdated today
    AI & LLM EngineeringAuto-check passed

More from kid-sid/claude-spellbook

All 55 skills in this repo
  • Accessibility

    kid-sid/claude-spellbook

    A skill your agent uses when building or reviewing UI components for keyboard and screen reader compatibility, adding ARIA to custom widgets, auditing a page for WCAG AA conformance, or preparing…

    190 GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Agentex

    kid-sid/claude-spellbook

    A skill your agent uses when building, wiring, or debugging an Agentex agent — choosing agent type, configuring acp.py and manifest.yaml, using adk.messages or adk.state, or resolving…

    190 GitHub stars~2.2k tokensUpdated 2 mo ago
    Auto-check: notes
  • AI Engineer

    kid-sid/claude-spellbook

    A skill your agent uses when building production LLM applications — designing RAG pipelines, choosing vector databases, implementing agent orchestration, optimizing cost, or adding AI safety…

    190 GitHub stars~3.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Angular

    kid-sid/claude-spellbook

    A skill your agent uses when building or refactoring Angular applications — choosing between signals, RxJS, and NgRx for state, configuring routing with guards and lazy loading, optimizing change…

    190 GitHub stars~5k tokensUpdated 2 mo ago
    Auto-check passed
  • API Design

    kid-sid/claude-spellbook

    A skill your agent uses when designing new REST endpoints, reviewing an existing API contract, adding pagination or filtering, planning a versioning strategy, or building a public or partner-facing…

    190 GitHub stars~3.6k tokensUpdated 2 mo ago
    Auto-check passed
  • Auth

    kid-sid/claude-spellbook

    A skill your agent uses when implementing login flows, issuing or validating JWTs, setting up OAuth2/OIDC with a provider, designing role-based or attribute-based access control, securing API…

    190 GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed

Questions about Openai Agents

What does Openai Agents do?

A skill your agent uses when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating…. Openai Agents is an agent skill from kid-sid/claude-spellbook. Use when building or debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs, wiring typed context, streaming responses, adding guardrails, or integrating with the Agentex ADK.

When should I use Openai Agents?

Openai Agents fits situations like: debugging OpenAI Agents SDK workflows — defining agents with tools and handoffs; wiring typed context; streaming responses; adding guardrails.

How do I install Openai Agents in Claude Code?

Run `npx skills add kid-sid/claude-spellbook --skill openai-agents -a claude-code`. Or copy the skill folder (skills/openai-agents in kid-sid/claude-spellbook) into .claude/skills/openai-agents in your project. Claude Code loads it when a task matches its description.

How do I install Openai Agents in Codex?

Run `npx skills add kid-sid/claude-spellbook --skill openai-agents -a codex`. Or copy the skill folder (skills/openai-agents in kid-sid/claude-spellbook) into .agents/skills/openai-agents in your project. Codex loads it when a task matches its description.

Can I use Openai Agents in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add kid-sid/claude-spellbook --skill openai-agents -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/openai-agents, .gemini/skills/openai-agents, .github/skills/openai-agents and .opencode/skills/openai-agents in your project.

What does Openai Agents need to run?

SKILL.md names no scripts, command-line tools or credentials: Openai Agents is instructions for the agent only. Our summary lists: Python 3.

Does Openai Agents access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Openai Agents safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Openai Agents use?

Openai Agents is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Openai Agents use?

About 3.4k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Openai Agents?

Skills that share tags, products or a category with Openai Agents: Migrating Openai Agents SDK To Pydantic AI (pydantic/pydantic-ai, 20k stars), Openai Agents (coco-research/coco, 503 stars), New Openai SDK App (sandgardenhq/sgai, 137 stars) and Scaffolding Openai Agents (aiskillstore/marketplace, 430 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Openai Agents?

kid-sid (a GitHub user) maintains it in kid-sid/claude-spellbook, which has 190 GitHub stars. The repository holds 55 skills in this directory. The repository was last updated on August 5, 2026.

Source: kid-sid/claude-spellbook on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.