Sunglasses is a filter that sits ahead of your OpenAI Agents SDK run. Always ON. Every user input, tool response, or handoff message — the filter scans first. This page walks through the OpenAI Agents SDK wiring.
Who this page is for
Developers using OpenAI's Agents SDK (Swarm's successor) to build multi-turn, tool-using agents. Drop Sunglasses in the agent's input and tool-response pipeline. Filter stays mandatory on every run.
The command
# Wrap Runner.run() input with engine.scan(): from sunglasses.engine import SunglassesEngine from agents import Agent, Runner engine = SunglassesEngine() async def safe_run(agent, user_input): result = engine.scan(user_input) if result.decision == "block": return f"Blocked by Sunglasses: {result.findings[0]['category']}" return await Runner.run(agent, user_input)
Filter every OpenAI Agents SDK run. Scan the user input before Runner.run(). If blocked, refuse. Otherwise hand off to the agent. Same pattern works for tool-response scanning via on_tool_use callbacks.
Benefit: OpenAI Agents SDK is where provider-native multi-turn agents live. Sunglasses drops into that pipeline with a 3-line guard — no framework patching required.
Install Sunglasses first
If you haven't installed Sunglasses on your machine yet, do this first in a fresh terminal:
python3 -m venv sunglasses-env
source sunglasses-env/bin/activate
pip install --upgrade sunglasses
On modern macOS and many Linux systems, your system Python may block direct installs. A small virtual environment keeps the install clean. Windows: replace source sunglasses-env/bin/activate with sunglasses-env\Scripts\activate.
Full walkthrough in progress. The core command and identity are ready. Detailed step-by-step screenshots, real-world attack examples, and troubleshooting are being added.
FAQ
How do I secure an OpenAI Agents SDK agent against prompt injection?
Wrap Runner.run() with a guard that calls engine.scan() on the user input first. If decision is block, refuse before the agent ever sees the input.
Does this work with the old Swarm SDK?
Yes. Swarm and Agents SDK share the same Runner.run() pattern — the guard works identically.
Can I filter tool outputs too?
Yes. Scan tool response strings with engine.scan(text, channel='api_response') before returning them to the agent. If blocked, short-circuit with a safe error message.
Is the filter synchronous or async?
Sunglasses engine is synchronous and fast (0.26ms). You can call it inside async handlers without blocking the event loop meaningfully.
Does this require an OpenAI API key change?
No. Sunglasses doesn't touch your OpenAI credentials. It's a local filter that sits in front of whatever LLM provider you're using.
Where this wiring fits
Sunglasses is one filter with many wiring options. This page covers OpenAI Agents SDK. Other wiring paths:
- Claude Code / Claude Desktop
- Cursor
- Cline (VS Code)
- Windsurf
- Zed
- Warp terminal
- Hermes-Agent (Nous)
- LangChain
- CrewAI
- Microsoft AutoGen
- Custom Python agent
Same filter underneath. Different wiring based on your stack.