|
| 1 | +# Agent Rules |
| 2 | + |
| 3 | +_Understanding Agent Rules configuration and behavior in Cube._ |
| 4 | + |
| 5 | +Agent Rules in Cube provide a powerful way to customize and control how AI agents behave within specific spaces. Rules act as contextual instructions that guide agents' responses and analysis, ensuring consistent behavior aligned with your business logic and domain expertise. |
| 6 | + |
| 7 | +## Rule Types |
| 8 | + |
| 9 | +### Always Rules |
| 10 | + |
| 11 | +**Always Rules** are automatically applied to every agent interaction within the space, regardless of the specific query or context. |
| 12 | + |
| 13 | +**Use Cases:** |
| 14 | +- Fundamental business definitions and context |
| 15 | +- Consistent calculation methods |
| 16 | +- Default analysis approaches |
| 17 | +- Domain-specific terminology |
| 18 | + |
| 19 | +**Example Always Rules:** |
| 20 | +``` |
| 21 | +Sales efficiency is deal size divided by sales cycle length |
| 22 | +``` |
| 23 | + |
| 24 | +``` |
| 25 | +When analyzing customer data, always consider seasonality patterns from our retail business |
| 26 | +``` |
| 27 | + |
| 28 | +``` |
| 29 | +Revenue should be calculated using our standard GAAP accounting principles |
| 30 | +``` |
| 31 | + |
| 32 | +### Agent Requested Rules |
| 33 | + |
| 34 | +**Agent Requested** rules are conditionally applied when the agent determines they are relevant to the current query or analysis. The agent intelligently selects which rules to use based on the context. |
| 35 | + |
| 36 | +**Use Cases:** |
| 37 | +- Specialized analysis techniques |
| 38 | +- Context-specific guidance |
| 39 | +- Advanced calculation methods |
| 40 | +- Scenario-specific instructions |
| 41 | + |
| 42 | +**Example Agent Requested Rules:** |
| 43 | +``` |
| 44 | +If you asked to analyze sales efficiency start with correlation to WSE |
| 45 | +``` |
| 46 | + |
| 47 | +``` |
| 48 | +For customer segmentation analysis, use RFM methodology (Recency, Frequency, Monetary) |
| 49 | +``` |
| 50 | + |
| 51 | +``` |
| 52 | +When analyzing marketing performance, compare against industry benchmarks where available |
| 53 | +``` |
| 54 | + |
| 55 | +## Best Practices |
| 56 | + |
| 57 | +### Rule Hierarchy and Organization |
| 58 | + |
| 59 | +- **Start with Always rules** for fundamental business context |
| 60 | +- **Use Agent Requested rules** for specialized scenarios |
| 61 | +- **Keep rules specific and actionable** rather than vague |
| 62 | +- **Test rules** with actual queries to ensure they work as expected |
| 63 | + |
| 64 | +### Writing Effective Rules |
| 65 | + |
| 66 | +✅ **Good Rule Examples:** |
| 67 | +- "Customer churn rate should be calculated as customers lost / total customers at start of period" |
| 68 | +- "When analyzing quarterly performance, always compare against same quarter previous year" |
| 69 | +- "For financial analysis, use our fiscal year starting in October" |
| 70 | + |
| 71 | +❌ **Poor Rule Examples:** |
| 72 | +- "Be helpful" (too vague) |
| 73 | +- "Always be accurate" (redundant) |
| 74 | +- "Consider all factors" (too broad) |
| 75 | + |
| 76 | +### Domain-Specific Rules |
| 77 | + |
| 78 | +**E-commerce Example:** |
| 79 | +``` |
| 80 | +Always Rule: "Customer lifetime value equals average order value × purchase frequency × customer lifespan" |
| 81 | +Agent Requested: "For cart abandonment analysis, segment by device type and traffic source" |
| 82 | +``` |
| 83 | + |
| 84 | +**SaaS Example:** |
| 85 | +``` |
| 86 | +Always Rule: "MRR growth rate should exclude one-time charges and setup fees" |
| 87 | +Agent Requested: "When analyzing churn, differentiate between voluntary and involuntary churn" |
| 88 | +``` |
| 89 | + |
| 90 | +### Contextual Guidance |
| 91 | + |
| 92 | +Rules should provide context that agents might not inherently understand about your business: |
| 93 | + |
| 94 | +``` |
| 95 | +Always Rule: "Our peak season is Q4, with 40% of annual revenue typically occurring in December" |
| 96 | +Agent Requested: "For inventory analysis, consider our 6-week lead time for international suppliers" |
| 97 | +``` |
| 98 | + |
| 99 | +## Rule Conflicts and Resolution |
| 100 | + |
| 101 | +### How Cube Handles Conflicting Rules |
| 102 | + |
| 103 | +Based on the rule configuration system, when multiple rules could apply to the same query, the conflict resolution strategy would likely include: |
| 104 | + |
| 105 | +1. **Rule type hierarchy** (specific behavior needs verification) |
| 106 | +2. **Rule specificity** - more specific rules typically override general ones |
| 107 | +3. **Rule order** - the system may consider rule creation order or explicit priority |
| 108 | +4. **Agent decision-making** for complementary vs conflicting guidance |
| 109 | + |
| 110 | +### Example Conflict Scenarios |
| 111 | + |
| 112 | +**Scenario 1: Direct Contradiction** |
| 113 | +``` |
| 114 | +Rule A (Always): "Revenue recognition follows monthly billing cycles" |
| 115 | +Rule B (Always): "Revenue should be recognized quarterly" |
| 116 | +
|
| 117 | +Resolution: The agent will flag this conflict and may ask for clarification |
| 118 | +``` |
| 119 | + |
| 120 | +**Scenario 2: Complementary Rules** |
| 121 | +``` |
| 122 | +Rule A (Always): "Sales efficiency is deal size divided by sales cycle length" |
| 123 | +Rule B (Agent Requested): "When analyzing sales efficiency, include pipeline velocity metrics" |
| 124 | +
|
| 125 | +Resolution: Both rules work together - B provides additional context to A |
| 126 | +``` |
| 127 | + |
| 128 | +**Scenario 3: Specificity Override** |
| 129 | +``` |
| 130 | +Rule A (Always): "Use standard deviation for all variance calculations" |
| 131 | +Rule B (Agent Requested): "For customer behavior analysis, use median absolute deviation instead of standard deviation" |
| 132 | +
|
| 133 | +Resolution: Rule B takes precedence for customer behavior queries due to higher specificity |
| 134 | +``` |
| 135 | + |
| 136 | +### Best Practices for Avoiding Conflicts |
| 137 | + |
| 138 | +1. **Review existing rules** before adding new ones |
| 139 | +2. **Use specific triggers** in Agent Requested rules |
| 140 | +3. **Test rule combinations** with sample queries |
| 141 | +4. **Document rule intentions** clearly |
| 142 | +5. **Regular rule audits** to identify and resolve conflicts |
| 143 | + |
| 144 | +## Current Limitations |
| 145 | + |
| 146 | +### Current State: Space-Level Rules Only, Always Rules Only |
| 147 | + |
| 148 | +- Rules are currently configured at the **Space level** |
| 149 | +- All agents within a space inherit the same set of rules |
| 150 | +- Individual agent customization is not yet available |
| 151 | + |
| 152 | +## Getting Started |
| 153 | + |
| 154 | +1. **Assess Your Use Case**: Identify the key business context and calculations your agents need to understand |
| 155 | +2. **Start Simple**: Begin with 2-3 Always rules covering your most important business definitions |
| 156 | +3. **Add Specificity**: Implement Agent Requested rules for specialized scenarios |
| 157 | +4. **Test and Iterate**: Use real queries to validate rule effectiveness |
| 158 | +5. **Scale Gradually**: Add more rules based on actual usage patterns and feedback |
0 commit comments