Skip to main content

Dialog Rails

Dialog rails execute during multi-turn conversations to enforce flow logic, steer dialogs, and apply policies across the entire interaction. Unlike input/output rails that check individual messages, dialog rails manage the conversation state and structure.

When Dialog Rails Execute

Dialog rails run throughout the conversation lifecycle:
Dialog rails use Colang flows to define conversation patterns, topic boundaries, and state management.

Key Concepts

Conversation Flows

Flows define the allowed patterns of interaction:

Topic Control

Restrict conversations to allowed topics:

Disallowed Topics

Block specific conversation topics:

Built-in Dialog Rails

Flow Management

Control the progression of conversations:

State Management

Track conversation state across turns:

Policy Enforcement

Apply business rules throughout the conversation:

Common Patterns

Guided Conversations

Lead users through structured interactions:

Context Tracking

Maintain conversation context:

Conditional Flows

Adapt based on conversation state:

Advanced Dialog Rails

Subflows

Reusable conversation components:

Event Handling

Respond to system events:

Multi-Intent Handling

Manage complex user inputs:

Integration with Other Rails

Conditional Input Rails

Apply input rails based on dialog state:

Conditional Output Rails

Validate outputs based on topic:

Real-World Examples

Customer Support Flow

Educational Tutoring

Compliance Enforcement

Configuration

Enable Dialog Rails

Dialog rails are enabled by defining flows in .co files:

Flow Priority

Control which flows take precedence:

Best Practices

  1. Keep flows focused - Each flow should handle a single conversation pattern
  2. Use subflows for reusability - Extract common patterns into reusable subflows
  3. Handle edge cases - Always provide fallback flows for unexpected inputs
  4. Track important state - Use variables to maintain conversation context
  5. Test flow coverage - Ensure all user intents have corresponding flows
  6. Document flow logic - Add comments explaining complex flow decisions

Limitations

Dialog Rails and Reasoning Models: Using advanced reasoning models (like OpenAI o1) with dialog rails is not currently supported. Reasoning models may not follow Colang flow patterns reliably.

Performance Considerations

  • Flow matching overhead - Complex flow definitions add latency
  • State management - Tracking many variables increases memory usage
  • Intent recognition - LLM calls for intent matching add cost
Optimizations:

Debugging Dialog Rails

Enable verbose logging:
This shows:
  • Flow matching decisions
  • State variable changes
  • Event triggers

See Also