Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AI Shell Team Aish Degraded Sandbox Handling

From Leeroopedia
Knowledge Sources
Domains Security, Sandboxing, Error_Handling
Last Updated 2026-10-29 00:00 GMT

Overview

Pattern for handling sandbox unavailability by falling back to policy rule matching or applying a configurable action (allow/confirm/block) based on the failure reason.

Description

Degraded Sandbox Handling is the mechanism that determines what to do when the sandbox cannot run a command. The analyze_sandbox_degraded function categorizes the failure reason and routes to the appropriate fallback:

  • Sandbox disabled by policy/unavailable IPC: fall back to the FallbackRuleEngine for policy-based assessment; if no rule matches, apply the policy's sandbox_off_action
  • Sandbox execution/timeout/protocol errors: force confirmation (medium risk) regardless of the policy's sandbox_off_action
  • Environment issues (CWD outside repo, mount failures): apply the policy's sandbox_off_action

The sandbox_off_action is a policy-level setting that determines the default behavior when the sandbox is off: allow (fail-open), confirm (cautious), or block (fail-closed).

This pattern solves the problem of graceful degradation when the sandbox infrastructure is unavailable: the security pipeline must still make a decision, and the decision should reflect the reason for the degradation.

Usage

Use this principle when a sandbox may be unavailable and the security pipeline must still produce a decision. The failure reason should determine the fallback strategy, not a single blanket policy.

Theoretical Basis

The handling is a reason-routed fallback:

# Abstract algorithm (NOT real implementation)
def analyze_sandbox_degraded(policy, fallback_engine, command, reason, details):
    if reason in [Disabled, DisabledByPolicy, IpcUnavailable]:
        # Try fallback rules first, then sandbox_off_action
        assessment = fallback_engine.assess(command)
        if assessment:
            return analysis_from_fallback(assessment)
        return analyze_with_action(policy.sandbox_off_action, reason)

    if reason in [BadRequest, Timeout, ProtocolError, ExecuteFailed]:
        return analyze_with_action(Confirm, reason)  # always confirm

    if reason in [Unavailable, CwdOutsideRepo, MountFailed]:
        return analyze_with_action(policy.sandbox_off_action, reason)

Key design ideas:

  • Reason-routed: the failure reason determines the fallback, not a single default
  • Fallback to rules: when sandbox is off, the fallback rule engine is tried first
  • sandbox_off_action: the policy's configurable default (allow/confirm/block) for when the sandbox is off
  • Forced confirmation: execution errors always force confirmation, overriding the policy

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment