Skip to main content

jep-openai-agents-middleware

JEP middleware for the OpenAI Agents SDK: portable and replayable AI judgment verification.

This package adds portable accountability semantics to OpenAI agent execution without forking the OpenAI Agents SDK and without changing SDK core semantics. It observes lifecycle hooks and wraps local tool callables to write deterministic, append-only JEP events.

What is recorded

The middleware automatically generates:

  • Judgment events for agent starts, LLM calls, tool starts/ends/errors, approval-required execution, and other local execution decisions.
  • Delegation events for handoffs and explicit sub-agent delegation.
  • Termination events when an agent produces final output.

Each event can include:

  • Agent lineage.
  • Tool execution metadata.
  • Authority scope.
  • Execution replay chain metadata.
  • Deterministic payload hashes instead of raw sensitive arguments/results.

Core APIs

  • JEPMiddleware — high-level facade for archive, hook, agent instrumentation, explicit delegation, and replay verification.
  • AgentExecutionHook — run-wide OpenAI Agents SDK lifecycle hook compatible with Runner.run(..., hooks=...).
  • ToolInvocationWrapper — sync/async callable wrapper for local tool execution events.
  • DelegationTracker — tracks lineage and handoff/sub-agent edges.
  • VerificationRuntime — appends events and verifies deterministic replay hash chains.

Basic usage with OpenAI Agents SDK

from agents import Agent, Runner, handoff
from jep_openai_agents_middleware import JEPMiddleware

middleware = JEPMiddleware("jep-archive.jsonl")

billing_agent = Agent(name="Billing agent")
refund_agent = Agent(name="Refund agent")
triage_agent = Agent(
    name="Triage agent",
    handoffs=[handoff(billing_agent), handoff(refund_agent)],
)

result = await Runner.run(
    triage_agent,
    "I was charged twice and need a refund.",
    hooks=middleware.hooks(),
)

assert middleware.verify_replay().valid

Wrapping local tools

from jep_openai_agents_middleware import JEPMiddleware

middleware = JEPMiddleware("jep-tools.jsonl")

def lookup_order(order_id: str) -> str:
    return "shipped"

lookup_order = middleware.wrap_tool(lookup_order, authority_scope="orders:read")
lookup_order("order_123")

Examples

  • examples/agent_handoff.py — OpenAI Agents SDK handoff accountability.
  • examples/multi_agent_collaboration.py — explicit multi-agent delegation tracking.
  • examples/approval_required_execution.py — approval-required tool execution recording.

Verification model

Events are stored as JSON Lines. The archive is append-only: new events receive a monotonically increasing sequence number and the previous event hash. Hashes are SHA-256 over canonical JSON, so replay verification can detect tampering, missing events, or reordered events.

Runtime and verification notes

See HARDENING.md for supported behavior, regression checks, and compatibility boundaries.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jep_openai_agents_middleware-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jep_openai_agents_middleware-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file jep_openai_agents_middleware-0.1.1.tar.gz.

File metadata

File hashes

Hashes for jep_openai_agents_middleware-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4e1cb9fd9546ad2befa4c41ff5bf3f0a440f2eea31e5d13c923fadb279ba6ed2
MD5 7acdec830848ecfcd67307a6e15137d7
BLAKE2b-256 106a0aa23bcb8c3b337ddf07e22179d255d7be44d790e9a15fc85c24d0b32d71

See more details on using hashes here.

Provenance

The following attestation bundles were made for jep_openai_agents_middleware-0.1.1.tar.gz:

Publisher: release.yml on hjs-spec/jep-openai-agents-middleware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jep_openai_agents_middleware-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jep_openai_agents_middleware-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e28226bf60c8b1f140da516490ea5e4da34885743aae6f1b6d8acb7dc8e0bf61
MD5 39679f4e4d8b895881dae791a0276f1c
BLAKE2b-256 564736ec2fb3ef7fc1026e2a5661b22627de770b698d917947262fa79c4585f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jep_openai_agents_middleware-0.1.1-py3-none-any.whl:

Publisher: release.yml on hjs-spec/jep-openai-agents-middleware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page