OpenAI Agents SDK
Two pieces in adapters/openai_agents/vigil_tracing.py, both built on vigil-sdk:
VigilTracingProcessor: aTracingProcessorthat emits onon_span_end. Agent spans becomeoutput_generated(content_lengthof the output when the span has one). Function (tool) spans becomefile_operationwhen the tool name says it moves data (write,copy,move,delete,transfer,rm,mv,cp) andoutput_generatedotherwise. Every event issource: platform_hook,actor: agent:<agent_id>. Emission failures go toon_errorand never interrupt the run; every gate goes toon_gateandprocessor.last_gate.vigil_gate_guardrail(client, agent_id): an output guardrail that emitsoutput_generatedfor the final output and trips the tripwire onhold,alertorcollapse, so the Agents SDK raisesOutputGuardrailTripwireTriggeredinstead of returning the output. Works withVigilorAsyncVigil.
openai-agents is imported lazily: the module imports and the tests run without it.
Wire it
import os
from agents import Agent, Runner, add_trace_processor
from vigil import Vigil
from adapters.openai_agents.vigil_tracing import VigilTracingProcessor, vigil_gate_guardrail
vg = Vigil(api_key=os.environ["VIGIL_API_KEY"])
vg.register_agent("triage", "Triage", exist_ok=True)
add_trace_processor(VigilTracingProcessor(vg, agent_id="triage"))
agent = Agent(
name="Triage",
instructions="Route the request.",
output_guardrails=[vigil_gate_guardrail(vg, agent_id="triage")],
)
result = await Runner.run(agent, "Hello")
Try it
adapters/openai_agents/example.py drives the processor with synthetic spans (an agent span, a copy_file tool span, a get_weather tool span) and calls the guardrail directly against VIGIL_API_URL, so it runs with only a VIGIL key. With openai-agents and OPENAI_API_KEY present it also runs a real agent.
VIGIL_API_KEY=vg_... python -m adapters.openai_agents.example
The two events the processor sends for the copy_file and get_weather spans, as raw HTTP:
curl -sf -X POST "$VIGIL_URL/agents/" -H "Authorization: Bearer $VIGIL_KEY" -H "Content-Type: application/json" \
-d '{"agent_id":"docs-openai-agents","name":"Docs OpenAI Agents"}' > /dev/null || true
curl -sf -X POST "$VIGIL_URL/events/" -H "Authorization: Bearer $VIGIL_KEY" -H "Content-Type: application/json" \
-d '{"agent_id":"docs-openai-agents","event_type":"file_operation","source":"platform_hook","actor":"agent:docs-openai-agents",
"payload":{"operation":"copy","tool_name":"copy_file","asset_type":"data"}}'
curl -sf -X POST "$VIGIL_URL/events/" -H "Authorization: Bearer $VIGIL_KEY" -H "Content-Type: application/json" \
-d '{"agent_id":"docs-openai-agents","event_type":"output_generated","source":"platform_hook","actor":"agent:docs-openai-agents",
"payload":{"tool_name":"get_weather","content_length":13}}'