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 withRunner.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jep_openai_agents_middleware-0.1.1.tar.gz.
File metadata
- Download URL: jep_openai_agents_middleware-0.1.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e1cb9fd9546ad2befa4c41ff5bf3f0a440f2eea31e5d13c923fadb279ba6ed2
|
|
| MD5 |
7acdec830848ecfcd67307a6e15137d7
|
|
| BLAKE2b-256 |
106a0aa23bcb8c3b337ddf07e22179d255d7be44d790e9a15fc85c24d0b32d71
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jep_openai_agents_middleware-0.1.1.tar.gz -
Subject digest:
4e1cb9fd9546ad2befa4c41ff5bf3f0a440f2eea31e5d13c923fadb279ba6ed2 - Sigstore transparency entry: 2814063859
- Sigstore integration time:
-
Permalink:
hjs-spec/jep-openai-agents-middleware@1553ecf82d6651f211b2bb3ff2a6f60495dd494e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hjs-spec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1553ecf82d6651f211b2bb3ff2a6f60495dd494e -
Trigger Event:
push
-
Statement type:
File details
Details for the file jep_openai_agents_middleware-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jep_openai_agents_middleware-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e28226bf60c8b1f140da516490ea5e4da34885743aae6f1b6d8acb7dc8e0bf61
|
|
| MD5 |
39679f4e4d8b895881dae791a0276f1c
|
|
| BLAKE2b-256 |
564736ec2fb3ef7fc1026e2a5661b22627de770b698d917947262fa79c4585f5
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jep_openai_agents_middleware-0.1.1-py3-none-any.whl -
Subject digest:
e28226bf60c8b1f140da516490ea5e4da34885743aae6f1b6d8acb7dc8e0bf61 - Sigstore transparency entry: 2814063861
- Sigstore integration time:
-
Permalink:
hjs-spec/jep-openai-agents-middleware@1553ecf82d6651f211b2bb3ff2a6f60495dd494e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hjs-spec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1553ecf82d6651f211b2bb3ff2a6f60495dd494e -
Trigger Event:
push
-
Statement type: