Skip to main content

Approvals and Guardrails

OpenBox evaluates governed LangChain middleware boundaries and returns verdicts that the SDK enforces at runtime.

Verdicts

VerdictMeaningRuntime effect
ALLOWContinue normallyExecution proceeds
REQUIRE_APPROVALHuman review requiredThe SDK waits for approval or raises if approval is rejected or expires
BLOCKOperation must not continueExecution raises GovernanceBlockedError
HALTAgent run must stopExecution raises GovernanceHaltError

Enforcement Model

For model calls:

  1. LLMStarted is evaluated before the model provider is called
  2. Prompt-side guardrails may apply
  3. The model call executes
  4. LLMCompleted is evaluated
  5. Output-side guardrails may apply
  6. Approval may be required on either side

For tool calls:

  1. ToolStarted is evaluated before the tool executes
  2. Input-side guardrails may apply
  3. The tool executes
  4. ToolCompleted is evaluated
  5. Output-side guardrails may apply
  6. Approval may be required on either side

For agent runs:

  • WorkflowStarted can stop execution early
  • SignalReceived(user_prompt) records the initiating prompt
  • WorkflowCompleted records final output context

Important Live-Run Behavior

In a standard OpenBox deployment, policy evaluates before guardrails for a given event.

Operational consequence:

  • If policy returns a non-ALLOW verdict such as REQUIRE_APPROVAL, BLOCK, or HALT, guardrails for that event may not run.
  • If a guardrail UI test passes but the live run shows no guardrail result, inspect the policy verdict first.

Guardrail Field Selection

Recommended fields:

EventField to checkExample use
LLMStartedpromptPrompt-side PII, jailbreak, or restricted-topic checks
LLMCompletedcompletionResponse-side safety and sensitive output checks
ToolStartedactivity_inputTool input restrictions before execution
ToolCompletedactivity_outputTool output restrictions after execution

Important:

  • Agent prompts are also emitted as SignalReceived(user_prompt).
  • For live tool guardrails, match on ToolStarted whenever possible.

Approval Handling

When OpenBox returns REQUIRE_APPROVAL, the SDK uses the shared OpenBox governance approval flow.

Typical behavior:

  • OpenBox creates an approval request
  • The request appears in the OpenBox dashboard
  • A human reviewer approves, rejects, or lets the request expire
  • The SDK continues only after approval is granted

Timeout or rejection raises a governance error.

In the standard LangChain middleware path, approval rejection or expiry raises GovernanceHaltError. The lower-level ApprovalRejectedError and ApprovalExpiredError classes are still exported for direct approval polling integrations.

Output-Time Approval

Approval is not limited to the requested action. LLMCompleted and ToolCompleted can also return REQUIRE_APPROVAL, which is useful when policy needs to review actual output instead of just the requested operation.

Runtime Errors You Should Expect

ErrorMeaning
GovernanceBlockedErrorOpenBox returned a BLOCK verdict
GovernanceHaltErrorOpenBox returned a HALT verdict, or approval rejection/expiry halted execution
GuardrailsValidationErrorGuardrail validation failed
ApprovalRejectedErrorLower-level direct approval polling received a rejection
ApprovalExpiredErrorLower-level direct approval polling expired before resolution

Production Recommendations

  1. Keep approval policy focused on business boundaries.
  2. Use ToolStarted selectors for tool-input guardrails.
  3. Use LLMStarted and LLMCompleted for prompt and response guardrails.
  4. Test live guardrails only after confirming policy returns ALLOW for that event.