APF Supervisor Middleware for OpenShell
APF’s supervisor middleware returns APF’s decision for each egress request that a sandbox policy routes to it. OpenShell’s sandbox supervisor calls it after Layer 1 checks and before credential injection, then enforces the result. It runs inside apf-policy-gateway and implements OpenShell’s supervisor middleware service.
Manifest
APF returns this manifest from Describe:
APF does not bind HTTP responses or WebSocket messages. A WebSocket session request returns UNIMPLEMENTED with apf-content-policy does not inspect WebSocket sessions.
RPCs and Callers
Refer to Identity and Delegation for how callers are recognized.
Request Handling
APF parses the request, detects an MCP tools/call from its JSON-RPC body, builds an evaluation input, and runs the annotator, Cedar, and effect stages against the active policy. It then applies any body replacement, body patches, and header mutations, and returns the result. Refer to Request Evaluation for every step.
Results
Deny Reason Codes
Limits
Configure your gRPC client and the OpenShell registration to allow at least these sizes.
Failure Behavior
Audit
Every decision writes one authorization record to apf-policy-gateway-middleware-audit.jsonl, with reason_code middleware.<code>, or middleware.allowed and middleware.allowed_with_findings for allows. The record’s correlation_id is OpenShell’s request ID, so it joins to the supervisor’s log. Refer to Understand Decisions and Findings.
Next Steps
- To register the middleware, refer to Add APF to OpenShell.
- To write the policies it evaluates, refer to Content Controls.