nexi-safety-gate

Documents Nexi's two defense-in-depth safety gates for generated code scanning and tool approval.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill nexi-safety-gate-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nexi-safety-gate
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/.opencode/skills/nexi-safety-gate
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill nexi-safety-gate-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When modifying Nexi's assistant engine, developers risk weakening two critical security boundaries: the AST scanner that vets Forge-generated code before execution, and the approval-token stripping that prevents a model from self-authorizing gated tool calls. This Skill explains exactly how both gates work so changes preserve them instead of relaxing them. ## Core Features & Use Cases - Forge code-generation gate: Explains how engine/forge/safety_scan.py AST-walks generated code, allowlists pure-compute stdlib modules, blocks dangerous calls and reflection primitives, and flags any dunder access to close sandbox-escape paths. - Tool-execution approval gate: Documents how execute_tool strips model-supplied approval tokens and why the only legitimate confirmation path is approval_queue.approve() with a private sentinel. - Debugging checklist: Guides diagnosis when the scanner rejects seemingly safe code or when a tool executes without approval across the ReAct and direct command.py dispatch paths. - Use Case: Before adding a new high-safety tool to _TOOLS or editing safety_scan.py, consult this Skill to route approval through approval_queue rather than inventing a new confirmation flag. ## Quick Start Ask the assistant to review the Nexi safety gates before modifying engine/forge/safety_scan.py or engine/tool_registry.py.

Frequently Asked Questions about nexi-safety-gate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new approval-gated tool in Nexi?

Mark the tool with safety="high" in _TOOLS and route its approval through approval_queue.approve(). Do not invent a new confirmation flag, because execute_tool strips any model-supplied approval or confirmed slots before execution.

How does Nexi scan AI-generated code before execution?

The scan() function in engine/forge/safety_scan.py AST-walks generated code before it runs, allowlisting pure-compute stdlib modules and blocking dangerous calls like eval, exec, open, and reflection primitives such as getattr and globals.

Why does the Nexi safety scan flag all dunder attribute access?

Any dunder reference like __class__ or __builtins__ is flagged because pure-compute code has no legitimate need for them, and this single rule closes the whole sandbox-escape family. Narrowing it to a specific dunder list is how the gate was previously bypassed.

Why did a Nexi tool execute without user approval?

Check that execute_tool actually calls _strip_reserved_arguments on the dispatch path being debugged, since both the ReAct planner and the direct command.py path must strip reserved slots. Only approval_queue.approve() can re-invoke with the private sentinel.

Can a model confirm its own tool call in Nexi?

No. A model writing "confirmed": true in its own tool arguments has that claim stripped before anything reads it. Real confirmation comes only from the explicit confirmed kwarg that Nexi itself sets via the approval queue.