Open Agent Loops
API Reference

permissionGate

@open-agent-loops/core


function permissionGate(store, prompter): (batch) => Promise<GateDecision[]>;

Defined in: permissions/permission-gate.ts:50

Build a gateToolCalls hook from a permission store and an approval prompter.

Parameters

ParameterTypeDescription
storePermissionStoreThe PermissionStore consulted for each call's policy.
prompterApprovalPrompterThe ApprovalPrompter asked about "ask" calls.

Returns

A function suitable for hooks.gateToolCalls: maps a batch of ToolGateRequests to index-aligned GateDecisions.

(batch) => Promise<GateDecision[]>

Remarks

The returned function evaluates a batch of pending calls: PermissionPolicy.Allow and PermissionPolicy.Deny resolve silently, while PermissionPolicy.Ask calls are collected and sent to the prompter in a single round-trip. "Always" choices (ApprovalChoice.AllowAlways / ApprovalChoice.DenyAlways) are persisted back to the store via PermissionStore.set. A missing choice defaults to ApprovalChoice.DenyOnce (fail closed).

Example

const store = new InMemoryPermissionStore({ fallback: PermissionPolicy.Ask });
const gate = permissionGate(store, cliPrompter);
const decisions = await runLoop(messages, model, tools, {
  hooks: { gateToolCalls: gate },
});

See

PermissionStore and ApprovalPrompter for the two seams.

On this page