OpenProgram Docs

Gating implementation

Gate sites

Each gate runs where the model is about to see the extension.

ExtensionSeen whenGateOn rejection
Skill/skill X injects SKILL.md_skill_gate_error in interfaces/server/ws_actions/chat/turn_skill.py, calling gate()skill_blocked, "Skill blocked: reason"; body not expanded
Toolresolve_tools() builds the turn's toolsruntime/conversation/model_tools.pyFiltered out
MCPSame pipeline, names <server>__<tool>_apply_profile_gates, inner to resolve_tools, on every return pathFiltered by server. A missing required raises RequiredMcpUnavailable

No single earlier chokepoint: skills arrive as objects with a category, tools as bare names, MCP tools as namespaced names. Only the input shape differs.

Shared helpers

openprogram/extensions/gating.py: pure functions, importable from any layer.

FunctionReturns
match_any(name, patterns)Whether any fnmatchcase pattern matches; empty patterns give false
gate(*, name, category="", disabled=(), allowed=(), categories=())None if it passes, otherwise a reason string
check_required(installed, required)Required patterns nothing matches

Schema

AgentSpec in runtime/agent_registry/manager.py. Each block is a plain dict.

BlockDefault
skills{"disabled": [], "allowed": [], "categories": []}
tools{"mode": "automatic"}
mcp{"disabled": [], "allowed": [], "required": []}

resolve_tools

A per-turn override beats profile.tools.

WantedResult
Noneagent_tools(source=…, only_available=True)
[], mode: noneNo tools
mode: automatic, or a dict with no enabled, toolset, preset, allowedFull toolset minus disabled
mode: selected or presetThose names minus disabled; adds tool_search when any is deferred
enabled listExactly those names; beats allowed
toolsetThat set, filtered by both pattern lists
Other dictDEFAULT_TOOLS filtered by both pattern lists
List of namesExactly those, resident unless tool_search is present

Profile MCP gates apply on every path, including per-turn lists. web_search is overlaid separately by its own boolean. required is checked after filtering, before provider execution.

Compatibility

skills, tools and mcp must be objects. AgentSpec.from_dict passes them through dict(), so legacy lists such as skills: ["pdf", "drawio"] raise ValueError on load and are not migrated. A tools dict holding only empty lists counts as automatic.

Testing

No dedicated unit tests: match_any is fnmatchcase plus iteration. openprogram doctor checks that skills load and MCP configs read, not gating. Add tests if semantics diverge from fnmatchcase, such as ** support.

Last updated · 2026-11-25