Logic

Define how to calculate, interpret, and reason about your data.

Overview

Logic definitions teach your agents domain-specific knowledge. When you ask "which contracts are high-risk?", basic RAG returns documents containing the word "risk"—but it has no idea what "high-risk" actually means in your organization.

Logic definitions solve this by encoding your organization's:

  • Metrics: How to calculate KPIs and measurements
  • Terms: What concepts and terminology mean
  • Rules: How to behave or categorize data

Definition Types

Metrics

Metrics define mathematical calculations and KPIs. Use metrics when you need to:

  • Calculate aggregate values
  • Define formulas
  • Specify measurement methodologies

Examples:

Monthly Recurring Revenue (MRR) Sum of all active monthly subscription values Customer Lifetime Value (CLV) Average revenue per customer × Average customer lifespan Churn Rate (Customers lost in period / Customers at start of period) × 100

Terms

Terms define what concepts mean in your organization's context. Use terms when you need to:

  • Define business terminology
  • Establish categorizations
  • Clarify ambiguous language

Examples:

Strategic Account A customer with ARR greater than $100K or identified as having significant growth potential Active User A user who has logged in at least once in the past 30 days Enterprise Customer An organization with more than 500 employees or annual revenue exceeding $50M

Rules

Rules define how to behave, process, or categorize data. Use rules when you need to:

  • Establish conditional logic
  • Define thresholds and criteria
  • Specify decision frameworks

Examples:

High-Risk Contract A contract with liability exceeding $1M OR containing a termination amendment OR with a payment term greater than 90 days Escalation Required Any support ticket that has been open for more than 48 hours OR has been reopened more than twice Qualified Lead A prospect who has: completed a demo, has budget authority, and has a timeline within 6 months

Creating Definitions

Using the Dashboard

  1. Navigate to Logic in the sidebar
  2. Click Create Definition
  3. Fill in the definition details:
    • Name: Clear, descriptive name
    • Type: Select Metric, Term, or Rule
    • Definition: The full explanation
  4. Choose the scope (see below)
  5. Click Create

Using the API

javascript
1// Create a Rule
2const rule = await client.definitions.create({
3 name: 'High-risk contract',
4 definition_type: 'rule',
5 definition: 'A contract with liability exceeding $1M OR containing a termination amendment',
6});
7
8// Create a Term
9const term = await client.definitions.create({
10 name: 'Strategic account',
11 definition_type: 'term',
12 definition: 'A customer with ARR greater than $100K',
13});
14
15// Create a Metric
16const metric = await client.definitions.create({
17 name: 'Monthly Recurring Revenue',
18 definition_type: 'metric',
19 definition: 'Sum of all active monthly subscription values',
20});

Scope

Logic definitions can be scoped to different levels:

Workspace-level (All Agents)

Definitions available to all agents in your workspace. Use for:

  • Organization-wide terminology
  • Standard metrics and KPIs
  • Universal business rules
javascript
1await client.definitions.create({
2 name: 'Enterprise customer',
3 definition_type: 'term',
4 definition: 'Organization with >500 employees',
5 // No datastore_id = workspace-level
6});

Datastore-specific

Definitions only available when querying a specific datastore. Use for:

  • Domain-specific terminology
  • Context-dependent rules
  • Specialized metrics
javascript
1await client.definitions.create({
2 name: 'Compliant document',
3 definition_type: 'rule',
4 definition: 'Document reviewed within last 12 months with no outstanding issues',
5 datastore_id: 'ds_legal123', // Scoped to legal datastore
6});

Versioning

Logic definitions support versioning to track changes over time.

Viewing Version History

In the dashboard, click on a definition to view its version history. Each version shows:

  • Version number: Sequential identifier
  • Modified by: Who made the change
  • Modified at: When the change was made
  • Definition content: The definition at that version

Reverting to a Previous Version

javascript
1// Get version history
2const versions = await client.definitions.getVersions('def_abc123');
3
4// Revert to a specific version
5await client.definitions.revert('def_abc123', {
6 version: 2,
7});

Best Practices

Writing Effective Definitions

  1. Be specific: Avoid vague language; include concrete thresholds and criteria
  2. Use examples: Reference real scenarios when helpful
  3. Keep it concise: Definitions should be clear, not exhaustive
  4. Test with queries: Verify definitions produce expected results

Good Definition Example

High-value opportunity An opportunity is high-value when ALL of the following are true: - Deal size exceeds $50,000 - Decision timeline is within 90 days - Champion identified within the organization - Budget has been confirmed

Poor Definition Example

High-value opportunity A really important deal that we should focus on.

Organizing Definitions

  • Group related definitions by domain (Sales, Legal, HR, etc.)
  • Use consistent naming conventions
  • Document the rationale for thresholds
  • Review and update definitions periodically

Next Steps