Skip to main content

Configuration Guide

rag_control is configured using YAML files that define policies, governance rules, filters, and organizations.

Configuration Structure

policies:
# Policy definitions
- name: policy_name
# ... policy config

filters:
# Filter definitions
- name: filter_name
# ... filter config

orgs:
# Organization definitions
- org_id: org_id
# ... org config

Policies

Policies control LLM generation behavior and enforce constraints.

Policy Fields

policies:
- name: strict_citations
description: Strict policy requiring citations

generation:
# Control LLM generation
reasoning_level: limited # none, limited, or full
allow_external_knowledge: false
require_citations: true
fallback: strict # strict or soft
temperature: 0.0 # 0.0 to 2.0

enforcement:
# Runtime enforcement checks
validate_citations: true
block_on_missing_citations: true
enforce_strict_fallback: true
prevent_external_knowledge: true
max_output_tokens: 512

logging:
# Audit logging level
level: full # full or minimal

Generation Parameters

ParameterTypeValuesDefaultDescription
reasoning_levelstringnone, limited, fulllimitedControls how much reasoning the LLM shows: none = no reasoning, limited = brief steps, full = detailed reasoning
allow_external_knowledgebooleantrue or falsefalseWhether LLM can use knowledge beyond retrieved documents
require_citationsbooleantrue or falsetrueWhether LLM must include citations for claims
fallbackstringstrict or softstrictstrict = fail if constraints can't be satisfied, soft = relax constraints gracefully
temperaturefloat0.0 - 2.00.0Response creativity: 0.0 = deterministic, 2.0 = creative

Enforcement Parameters

ParameterTypeDefaultDescription
validate_citationsbooleantrueVerify citations actually exist in retrieved documents
block_on_missing_citationsbooleantrueBlock response if citations are missing
enforce_strict_fallbackbooleantrueEnforce the fallback strategy (strict or soft) at runtime
prevent_external_knowledgebooleantrueBlock responses with claims not in retrieved documents
max_output_tokensinteger or nullnullMaximum tokens in response; null = no limit

Learn more: See Policies concept guide for detailed policy behavior and examples.

Filters

Filters control document retrieval based on data classification and metadata.

Filter Definition

filters:
- name: enterprise_only
condition:
field: org_tier # User field to check
operator: equals # equals, contains, in, etc.
value: enterprise # Expected value
source: user # user or documents

- name: public_documents_only
condition:
field: metadata.classification
operator: equals
value: public
source: documents
document_match: any # any or all

Filter Operators

OperatorSupported ValuesDescription
equalsAnyExact match of field value
inListField value is in provided list
ltNumberField value is less than
lteNumberField value is less than or equal to
gtNumberField value is greater than
gteNumberField value is greater than or equal to
intersectsListField array intersects with provided list
existsN/AField exists (no value needed)

Filter Sources

SourceDescription
userCheck fields from user context or request metadata
documentsCheck fields from retrieved documents. Use with document_match

Filter Logic

Filters support nested AND/OR logic:

filters:
- name: complex_filter
or:
- and:
- condition:
field: metadata.classification
operator: equals
value: public
source: documents
- condition:
field: metadata.retention_days
operator: gte
value: 365
source: documents
- condition:
field: user_role
operator: in
value: [admin, analyst]
source: user

Learn more: See Filters concept guide for advanced filter patterns and use cases.

Document Policy

Document policies control document retrieval behavior for organizations.

Document Policy Definition

document_policy:
top_k: 5 # Number of documents to retrieve (required, must be > 0)
filter_name: null # Optional: filter to apply to document retrieval
ParameterTypeDefaultDescription
top_kinteger5Number of documents to retrieve. Must be greater than 0
filter_namestring or nullnullOptional filter name to apply to document retrieval. Must exist in filters section

Learn more: See Filters concept guide for information about document filtering and selection.

Policy Rules

Policy rules enable dynamic policy selection and request blocking based on conditions.

Policy Rule Definition

policy_rules:
- name: rule_name
description: Rule description
priority: 100 # Higher = evaluated first (must be unique, > 0)
effect: allow # allow or deny
apply_policy: policy_name # (optional) Policy to apply when rule matches
when:
all: # All conditions must match (AND logic)
- field: field_name
operator: equals # equals, lt, lte, gt, gte, intersects, exists
value: some_value # (not needed for 'exists')
source: user # user or documents
document_match: any # any or all (documents only)

Policy Rule Parameters

ParameterTypeRequiredDescription
namestringYesUnique name for the rule
descriptionstringNoHuman-readable description
priorityintegerYesEvaluation order: higher = first. Must be unique and > 0
effectstringYesallow (permit) or deny (block)
apply_policystringNoPolicy to apply when rule matches. Used with allow effect
whenobjectYesConditions that trigger the rule

Rule Condition Parameters

ParameterTypeDescription
fieldstringField to check (supports dot notation: metadata.classification)
operatorstringComparison operator (see Rule Operators below)
valueanyExpected value. Not needed for exists operator
sourcestringuser (context fields) or documents (document metadata)
document_matchstringany (match any doc) or all (match all docs). Only for documents source

Rule Operators

OperatorSupported ValuesDescription
equalsAnyExact match
ltNumberLess than
lteNumberLess than or equal to
gtNumberGreater than
gteNumberGreater than or equal to
intersectsListField array intersects with provided list
existsN/AField exists (no value needed)

Rule Evaluation

  • Rules are evaluated in priority order (highest first)
  • First matching rule determines the action
  • All conditions in all must be true (AND)
  • Any condition in any can be true (OR)
  • Use document_match: any when applying conditions to documents (matches if any doc meets the condition)
  • Use document_match: all to require all documents to meet the condition

Learn more: See Governance concept guide for policy rule strategies and enforcement patterns.

Organizations

Organizations apply organization-specific rules and settings.

Organization Definition

orgs:
- org_id: acme_corp
description: Acme Corporation
default_policy: strict_citations

# Document retrieval settings
document_policy:
top_k: 8 # Number of documents to retrieve
filter_name: enterprise_only # Optional: filter applied to all requests

# Policy rules for organization-specific governance
policy_rules: [] # Can be empty if no additional rules needed

Organization Parameters

ParameterTypeRequiredDescription
org_idstringYesUnique organization identifier
descriptionstringNoHuman-readable organization description
default_policystringYesDefault policy name (must exist in policies)
document_policyobjectYesDocument retrieval configuration (see Document Policy section)
policy_ruleslistYesList of policy rules (can be empty)

Example Organization Structure

orgs:
- org_id: acme_corp
description: Acme Corporation
default_policy: strict_citations

# Document retrieval settings
document_policy:
top_k: 5

# Organization-specific policy rules
policy_rules:
- name: deny_untrusted_sources
description: Deny untrusted sources
priority: 60 # Higher priority = evaluated first
effect: deny # deny to block, allow to permit
when:
any: # Match any condition
- field: metadata.source
operator: equals
value: public-web
source: documents
document_match: any

- name: apply_strict_citations
description: Apply strict citations policy
priority: 50
effect: allow
apply_policy: strict_citations
when:
all: # Match all conditions
- field: org_tier
operator: equals
value: enterprise
source: user

Rule Effects

EffectDescription
denyBlock the request with a denial error. Stops processing immediately
allowPermit the request. If apply_policy specified, apply that policy

Rule Conditions

Rules use when clauses with:

  • any: Match if any condition is true (OR)
  • all: Match if all conditions are true (AND)

Learn more: See Governance concept guide for multi-tenant setup and organization-level policy rules.

Example Configurations

Development Configuration

policies:
- name: development
description: Permissive development environment
generation:
reasoning_level: full
allow_external_knowledge: true
require_citations: false
fallback: soft
temperature: 0.7
enforcement:
validate_citations: false
block_on_missing_citations: false
enforce_strict_fallback: false
prevent_external_knowledge: false
max_output_tokens: 2048
logging:
level: full

orgs:
- org_id: dev
description: Development organization
default_policy: development
document_policy:
top_k: 10
policy_rules: []

Production Configuration

policies:
- name: production
generation:
reasoning_level: limited
allow_external_knowledge: false
require_citations: true
temperature: 0.1
enforcement:
validate_citations: true
block_on_missing_citations: true
enforce_strict_fallback: true
prevent_external_knowledge: true
max_output_tokens: 512
logging:
level: full

filters:
- name: sensitive_only
condition:
field: metadata.classification
operator: in
value: [sensitive, confidential]
source: documents

orgs:
- org_id: production
default_policy: production
document_policy:
top_k: 5
filter_name: sensitive_only
policy_rules:
- name: block_external_knowledge
priority: 100
effect: deny
when:
all:
- field: metadata.is_external
operator: equals
value: true
source: documents
document_match: any

Multi-Organization Setup

policies:
- name: strict
# ... strict config

- name: moderate
# ... moderate config

filters:
- name: acme_filter
# ... acme-specific filter

orgs:
- org_id: acme_corp
default_policy: strict
document_policy:
top_k: 5
filter_name: acme_filter
policy_rules:
- name: acme_specific_rule
priority: 50
effect: allow
apply_policy: strict
when:
all:
- field: org_id
operator: equals
value: acme_corp
source: user

- org_id: standard_org
default_policy: moderate
document_policy:
top_k: 10

Validation

rag_control validates configurations on startup:

from rag_control.core.engine import RAGControl

try:
engine = RAGControl(
llm=llm_adapter,
query_embedding=embedding_adapter,
vector_store=vector_store_adapter,
config_path="policy_config.yaml"
)
except Exception as e:
print(f"Configuration error: {e}")

Configuration Best Practices

  1. Start Simple: Begin with one policy and one organization
  2. Use Meaningful Names: Policy and filter names should describe their purpose
  3. Document Rules: Use descriptions for all rules and policies
  4. Test Thoroughly: Verify policies work with your adapters
  5. Version Control: Keep configurations in git
  6. Separate Environments: Use different configs for dev, staging, production

Configuration Reference

The control plane configuration is fully documented in the Configuration Guide.

Next Steps