Skip to main content
The Decision Pipeline is OrcBot’s safety and quality control layer. It sits between the LLM’s raw output and skill execution, applying guardrails to prevent loops, duplicates, unsafe operations, and premature task termination.

Architecture

1. Parser Layer

Purpose: Extract structured decisions from messy LLM output. Implementation: ParserLayer.ts (lines 14-539)

3-Tier Fallback Strategy

StandardResponse Schema

Parser Examples

Clean JSON (Tier 2): LLM Output:
Parsed Output (Tier 2):
Messy Output (Tier 3): LLM Output:
Parsed Output:

2. Deduplication Guard

Purpose: Prevent repeated identical tool calls within the same action. Implementation: DecisionPipeline.ts (lines 45-120)

Strategy

Tracks recently executed tools using a sliding window:

Exemptions

Sequential UI components are exempt from deduplication (they’re intentionally called multiple times in sequence):

Example Block

3. Loop Detection

Purpose: Prevent infinite cycles of the same tool or tool sequences. Implementation: DecisionPipeline.ts (lines 121-180)

Patterns Detected

1. Same-tool loops (3+ in a row):
Example:
2. Alternating tool loops (A→B→A→B):
Example:
3. Search thrashing (multiple failed searches):
Example:

Loop Recovery Suggestions

When a loop is detected, the pipeline injects recovery guidance:

4. Channel Policy Guard

Purpose: Enforce cross-channel isolation and autonomy delivery rules. Implementation: Agent.ts (lines 878-906)

Rules

1. Cross-channel send blocking (non-admin):
Exemptions: send_email (intentionally cross-channel for “email this” requests) 2. Channel configuration check:
3. Autonomy delivery policy:

Example Block

5. Safety Checks

Purpose: Prevent dangerous operations in safe mode and validate tool arguments. Implementation: DecisionPipeline.ts (lines 181-250)

Safe Mode Blocks

Argument Validation

Restricted Path Access

6. Termination Review

Purpose: Prevent premature task completion before delivering substantive results. Implementation: BlockReviewer.ts (lines 52-797)

Review Trigger

Runs when LLM sets completed: true:

Audit Codes

Audit Logic

Example Block

Prompt Helpers (PromptRouter)

Purpose: Modular, task-aware prompt assembly that activates only relevant guidance. Implementation: PromptRouter.ts (lines 45-797) + src/core/prompts/ (8 helpers)

Active Helpers

The PromptRouter analyzes the task and selectively activates helpers:

Token Savings

By only including relevant helpers, the router saves ~2,000-4,000 tokens per step:

Helper Example: ResearchHelper

Autopilot Mode

Purpose: Suppress clarification requests for fully autonomous operation. Configuration:
Effect:

Skill Routing Rules

Purpose: Intent-based skill selection for better tool matching. Configuration:
Effect: When the task matches an intent, the preferred skills are highlighted in the prompt:

Information Boundaries

Purpose: Prevent cross-user information leakage in multi-tenant deployments. Rules:
Effect: Non-admin tasks only see their own short-term memory + thread context. No cross-user data leakage.

Performance Metrics

Pipeline overhead per step:
  • Parser: ~10-50ms
  • Deduplication: ~1-5ms
  • Loop detection: ~2-10ms
  • Channel policy: ~1-5ms
  • Safety checks: ~2-10ms
  • Termination review: ~500-2,000ms (LLM call)
  • Total: ~520-2,080ms per step
Token costs:
  • System prompt helpers: ~2,500-4,500 tokens (depends on task)
  • Feedback injections: ~100-300 tokens per block
  • Termination review prompt: ~500-1,000 tokens

Debugging Pipeline Blocks

1. Enable pipeline logs:
2. Grep for blocks:
3. Inspect action memories:
4. Test termination review:

Configuration Reference

Further Reading