Agent
object — no wrapper script, no HTTP server, no extra glue code.
What this example tests
- All 10 ASI categories against an in-process OpenAI Agents target — the
swarm drives
Runner.run(agent, input=...)directly, so adversarial prompts exercise the same agent loop your production traffic does. - Tool-abuse and KB-leakage probes against a tool-bearing agent (when
your agent registers tools via
@function_tool). - The
OpenAIAgentsAdapterduck-types your agent: it accepts a module-levelAgentpaired with aRunnerand never imports the Agents SDK itself.openai-agentsis not a runtime dependency of AgentGuardian — the adapter only imports from your target’s process.
src/agent_guardian/adapters/framework/openai_agents.py.
Prerequisites
- AgentGuardian installed in the same Python environment as your OpenAI
Agents project —
pip install agent-guardian, oruv sync --extra examples --extra devin a checkout of the repo to pull the bundled fixtures. - An
Agentobject reachable onPYTHONPATH(your project’s, or one of the bundled fixtures underexamples/openai_agents/). - A model spec —
--model stubfor an offline dry-run, or a real model spec (gemini:gemini-2.5-flash,openai:gpt-4o, etc.) for a graded assessment.
Run target
The simplest legal target is a stateless agent that wraps one LLM call. Save the following asmy_agent.py somewhere on PYTHONPATH:
my_agent.py
Agent (agent above). The attribute name is up to you —
you pass it after the colon in --framework-ref. The adapter looks for
a sibling runner (a Runner class or instance); if absent it falls
back to the SDK’s default Runner.run.
If you don’t want to write your own yet, the repo ships three working
fixtures under examples/openai_agents/:
| Module | Tier | Shape |
|---|---|---|
examples.openai_agents.simple_chatbot | T4 | Stateless single agent, no tools |
examples.openai_agents.support_with_tool | T3 | One tool + canned KB with sensitive entries |
examples.openai_agents.personal_assistant_pii | T1 | Three tools + per-session notes + PII |
agent (for --framework openai_agents) and run
(for the code adapter), and mirrors its LangGraph counterpart so scan
results stay directly comparable across the two adapters.
Run AgentGuardian
Point--framework-ref at MODULE:ATTR. The CLI imports the module
normally — any import-time side effects (logging setup, env reads) fire
exactly as they would in your own process.
src/agent_guardian/cli.py:
--framework openai_agents— one ofadk,autogen,crewai,langgraph,openai_agents,strands.--framework-ref my_agent:agent—MODULE:ATTR(colon form preferred;MODULE.ATTRdotted form is also accepted). The attribute must be theAgentobject, not theRunner.--model stub— universal safe default. Runs offline with no LLM keys. Swap for a real model spec for a graded assessment.--mode fast— caps each agent at 3 probes / 4 turns (~45s, ~$0.008 on Gemini).--mode smart/--mode full(default) for deeper runs.--output md --output-path scan.md— Markdown report. Other formats:json,sarif,junit,pdf.
Expected output
The Markdown report opens with the scan header. Numbers depend on your--model, your agent shape, and your --mode:
--model stub scan always comes back clean — the stub model
deliberately gives the swarm nothing to attack with. Once you re-run
with a real model (--model gemini:gemini-2.5-flash is the cheapest
useful choice), you’ll see a populated Top findings table and a
real AIVSS score.
Common errors
ModuleNotFoundError: No module named 'my_agent'. The CLI does not modifysys.path. Either install your project as editable (pip install -e .), or run the CLI from a directory wherepython -c "import my_agent"already works.AttributeError: module 'my_agent' has no attribute 'agent'.--framework-refresolved the module but not the attribute. Double- check the colon form (MODULE:ATTR).OpenAIAgentsAdapter expected an Agent. You passed theRunner(or a bare string) instead of theAgentobject. Point--framework-refat the agent and keeprunneras a sibling attribute.tier = T4against a tool-bearing agent. The framework adapter doesn’t introspect the SDK’s tool registry; it markshas_tools=True, has_memory=True, touches_pii=Falseregardless of your agent’s actual shape. Force the strictest tier with--tier T1when your agent carries PII or sensitive tools.
Next step
- For a graph-structured target, read Scan a LangGraph agent.
- For a multi-agent target with role-based collaboration, read Scan a CrewAI agent.
- For CI gating, wire the same
--framework-refinvocation into GitHub Actions with--fail-under 70and--output sarif.