OpenProgram Docs

Permission decision and refusals

Owner
authority_tier == "owner" and principal_id == owner_principal_id(). Whether someone is watching is not part of it.
Can approve
can_approve(req): owner, speaker_kind == "owner", interaction == "interactive", capability approval.request; or a foreground helper whose request carries asks_through, asked on its caller's card (agent collaboration)
Bypass permissions
The mode stored and sent as bypass; the default

The decision path

permission_decision(tool, req, args) in openprogram/runtime/permissions/policy.py is the only function that decides whether a well-formed call runs. The first match ends it.

Check, in orderResult
1. Identity (identity.py, decide). Never fires for the owner's own turns: capability (decide_tool_authority), scope, page script in work a non-owner started; dangerous read paths in an always-on check-in; page scripts and destructive deletes in a handoff chain or an automatic Goal's turns, and in the sub-agents, nested programs and notice turns they startdeny: AUTHORITY_*, IDENTITY_SCOPE, IDENTITY_PAGE_SCRIPT, IDENTITY_CHECK_IN_READ, IDENTITY_OUTSIDE_TEXT
2. Owner deny ruledeny: RULE_DENY
3. Plan selected, tool marked unsafe_in plandeny: PLAN_MODE_DENY, so a saved bash(git:*) cannot break Plan's read-only promise
4. Owner ask ruleask: RULE_ASK
5. Agent with hold_outbound, sending toolask: RULE_OUTBOUND_HOLD, an implicit ask rule; see Outbound hold
6. Owner allow ruleallow: RULE_ALLOW
7. Bypass permissionsallow: MODE_UNRESTRICTED
8. Plan, tool is exit_plan_modeask: PLAN_EXIT
9. Call needs no decisionallow: SURFACE_GRANT, SESSION_POLL, APP_GRANT_FREE, SCHEDULED_MEMORY, SAFE_TOOL (reads, plans, and replies to the turn's own conversation; send_file is one, because attaching a file there is replying, so Auto never sends it to review; see Chat attachments)
10. Accept edits, safe edit inside the working directoriesallow: SAFE_EDIT
11. Autoallow: AUTO_APP_GRANT, when an earlier review held the same screen; otherwise model review: AUTO_CLASSIFY
12. Everything elseask: MODE_APPROVAL

Rules are empty by default and merge global, project and the execution branch (permissions/rule.py); deny beats ask beats allow, and source order matters only inside one behaviour.

Conversation branches share current files. Switching branches introduces no workspace-alignment permission gate; only an explicit Rewind requests file recovery.

Every ask goes through _ask_or_nobody: if can_approve(req) is false the outcome is deny with NO_ONE_TO_APPROVE, or HELPER_CANNOT_ASK for a helper Agent started by another. No card is published for a turn that would be refused at execution; APPROVAL_LOCAL_OWNER_REQUIRED remains a defensive assertion at resume.

The Decision value
FieldMeaning
outcomeallow, ask, auto or deny
codeThe stable reason code
layeridentity, rule, mode, or setting for a gate driven by a setting
refusalA Refusal, set when the outcome is deny
ruleThe rule text that decided, if any
authorityStructured evidence for an identity denial
Calls that are not well-formed, and Pages

A malformed call never reaches the decision. call_problem(name, args) in openprogram/programs/_authoring/prechecks.py combines guides.missing_required (GUIDE_REQUIRED) and prechecks.problem (INVALID_ARGUMENTS); permissions/approvals/approval.py calls it first:

CallerOn a problem
_permission_preflight, _interaction_manifestReturn None: no review, no card
_gated_executeOrdinary tool error: is_error=True, no denied flag, no mark_refused

Being in the wrapper, not the agent loop, it also covers Python-program inner tools and the MCP server.

Whether a turn may use Pages is surface_grant_applies(name, req, args), a separate question. runtime_attach.py captures the Page snapshot when the decision for a call on the target that holds the conversation's Pages (page_surface_call()) is allow and surface_grant_applies holds, so a Program started under Bypass permissions still receives its Pages.

Modes

Stored valueLabelBehaviour
bypassBypass permissionsEverything well-formed runs
autoAutoFree calls run; the rest go to model review. Review errors fail closed; 3 consecutive or 20 total blocks fall back to a card if someone can approve.
askManualFree calls run; the rest ask. App access asks on first touch and can be allowed for the conversation.
planPlanAs Manual, and tools marked unsafe_in plan are refused and hidden
acceptEditsAccept editsUnused option, still valid so stored conversations keep working

Where each kind of limit lives

KindExamplesPlace
IdentityCapabilities, non-owner scope, page scripts, framework operations, cited memorypermissions/identity.py, tool_authority.py, Refused from the tool
RulesDeny, ask and allow rules, hold outbound, hookspermissions/rule.py, runtime/events/tool_gate.py
ModeThe table above_mode_decision
SandboxPaths and network outside the sandbox, only when Sandbox is onhost/sandbox/, programs/_host/execution.py
CorrectnessArgument checks, read before write, a file changed under an approval, a stale reviewTool code, returned to the model as an error or a retry

auto machinery, attended.py (removes ask_user_question from unattended turns) and state.py are not on the decision path.

Refusal contract

permissions/refusal.py is the single producer. The model receives one line:

[blocked by <layer>] <what> did not run: <why>. To change this: <change>.
Refusal
layer, code, what (the call, in plain words), why (the reason, quoting the rule or naming the mode), change (where the owner changes this)
Refused
What tool code raises; wraps a Refusal and is built only through this module's constructors. _execute_bound in programs/_host/runtime.py, _gated_execute and the agent loop turn it into the standard result, so an AgentTool call never raises it. A plain Python call of a tool's implementation does.
Result details
denied: true, reason_code, layer, rule, mode, outcome: "not_started", execution_started: false. The existing tool row displays the text.
CodeLayerwhychange
AUTHORITY_*identity<speaker> is not the owner and may not <capability>Channels account access, or MCP server exposed tools; in a group room, channels accounts group-users add with --access full, or sender_access owner for the account
IDENTITY_SCOPEidentitywork started by <source> may not <action>The owner must start this work
IDENTITY_CHECK_IN_READidentityan always-on check-in may not read this: <reason>Report what you need and let the owner look in a normal turn
IDENTITY_PAGE_SCRIPTidentitypage scripts run only in work the owner startedUse the page actions, or have the owner start this
IDENTITY_OUTSIDE_TEXTidentitythis work came from text the owner did not writeSay what was wanted in the report or final message, so the owner can do it
IDENTITY_FRAMEWORKidentityframework operations are the owner'sThe owner must start this work
RULE_DENYruleyour deny rule "<rule>" matchesPermission rules in global, project or conversation
HELPER_CANNOT_ASKrule, mode or sandboxthis needs approval (<rule or mode>), and a sub-agent running in the background has no one to askThe helper continues without that step and names in its final reply what it needed; the caller does it or asks
NO_ONE_TO_APPROVErule, mode or sandboxthis needs approval (<rule or mode>) and this <source> turn has no one to approve itDepends on what wanted the approval. Hold outbound: put the full draft in the final message or report; the owner can untick the hold on the Agent's Always-on tab. Ask rule: the owner edits or removes the named rule. Leaving the sandbox: set the mode at the bottom to Bypass permissions, or turn the Sandbox switch off. Otherwise: set the mode at the bottom to Bypass permissions, or add the named allow rule
PLAN_MODE_DENYmodethe conversation is in Plan mode, which only readsThe mode selector at the bottom of the message box
TOOL_UNAVAILABLEsetting<why this turn cannot use it>. Not an approval: a tool the conversation's tools array keeps for the epoch that this turn cannot use (no channel, nobody to answer, memory off). The section beside the message lists them; see the cache-prefix designCarry on without it
APPROVAL_DENIEDmode or ruleyou declined it, plus the note if anyAsk again, or change the mode
AUTO_CLASSIFIER_*, AUTO_HISTORY_UNAVAILABLEmodeAuto review <blocked / could not run>: <reason>The mode selector, or an allow rule
SANDBOX_* and sandbox policysandboxSandbox is on and <path or network> is outside itThe Sandbox switch for this conversation, or sandbox settings
HOOK_DENIEDhooka hook blocked it: <message>Hooks in Settings
AGENT_BUDGETsettingthis chain has reached <limit> <generations, messages or agents>Settings > Agent > <label> (agent.<key>)
COMPUTER_USE_REFUSED_APPsetting<app> is on the refused listSettings > computer_use.refused_apps
COMPUTER_USE_OWN_WINDOWmodein <mode> the Agent may not operate OpenProgram's own window, where approval cards appearThe mode selector at the bottom of the message box
COMPUTER_USE_PASSWORD_FIELDsettingtyping into password fields is turned offSettings > computer_use.refuse_password_fields
Stale state, MCP text, and the enforcing test
ItemBehaviour
Stale statePERMISSION_REVIEW_STALE, APPROVAL_FILE_CHANGED and wait resume mismatches come back as a retry instruction through refusal.stale(...), not as a block
MCP serverIts model-facing text, keyed by decision code, comes from refusal.py (MCP_GATE_REFUSALS), so _trusted_approval_denial recognises the same strings the gate produces
Single source testtests/unit/security/test_refusal_single_source.py walks openprogram/programs/, openprogram/runtime/permissions/, openprogram/runtime/agent/loop/ and openprogram/extensions/mcp/server/. It fails on a bracketed denial literal, "denied": True in a dict or details=, a "sandbox policy:" literal, or raise PermissionError( outside refusal.py. Each exception is on an explicit allowlist with its reason.

Implementation status

The decision path, call_problem, identity.py, refusal.py, Refused, the MCP table, the default mode and the selector are in place. Open:

  • _DELEGATED_SOURCES still marks delegated risky calls for audit.
  • A hook denial carries the hook's message but not its name.
Last updated · 2026-11-25