docs/Docs/Configuration
Reference

Configuration Reference

Bastion is configured via environment variables and a .env.local file. All variables use the BASTION_ prefix. Settings are loaded by pydantic-settings with OS env vars taking highest priority.

bash
# .env.local (gitignored — never commit real credentials)
BASTION_CONN="postgresql://user:pass@host:26257/bastion?sslmode=verify-full"
BASTION_API_KEY="bastion-your-api-key-here"
BASTION_MOCK=false

Core Settings

Connection

VariableDefaultRequiredDescription
BASTION_CONN—YesCockroachDB PostgreSQL connection string (sslmode=verify-full)
BASTION_MOCKfalseNoEnable mock mode — no database required, in-memory storage only
BASTION_API_KEY—ProdAPI key for MCP/A2A authentication. Disabled when empty.
BASTION_AGENT_IDbastion-a2aNoAgent identity for A2A server

Embedding Pipeline

VariableDefaultRequiredDescription
BASTION_EMBED_MODEL_IDBAAI/bge-large-en-v1.5NoHuggingFace model ID for embedding generation
BASTION_EMBED_DIM1024NoEmbedding dimensions (must match model output)
HF_TOKEN—NoHuggingFace API token for embedding API access
BASTION_EMBED_READ_TIMEOUT30NoTimeout (seconds) for embedding API reads
BASTION_EMBED_CONNECT_TIMEOUT10NoTimeout (seconds) for embedding API connections

Server Settings

MCP Server

VariableDefaultRequiredDescription
BASTION_MCP_API_KEYS—NoComma-separated list of valid API keys (multi-key mode)
BASTION_TRUST_PROXYfalseNoTrust X-Forwarded-For headers (for reverse proxy deployments)
BASTION_MCP_OAUTH_CLIENT_ID—NoPre-registered OAuth client ID for MCP auth
BASTION_MCP_OAUTH_CLIENT_SECRET—NoPre-registered OAuth client secret
BASTION_MCP_OAUTH_REDIRECT_URI—NoOAuth redirect URI

A2A Server

VariableDefaultRequiredDescription
A2A_PORT9998NoA2A server listen port
A2A_HOST0.0.0.0NoA2A server bind address
A2A_URLhttp://0.0.0.0:9998NoPublic A2A URL for agent card
BASTION_A2A_PRIVATE_KEY—NoBase64-encoded Ed25519 private key for agent card signing
BASTION_A2A_STRICTtrueNoStrict A2A auth mode (reject unsigned cards)
BASTION_A2A_TRUSTED_KEYS—NoComma-separated SHA-256 fingerprints of trusted keys
BASTION_A2A_ROLEadminNoDefault role for single-key mode
BASTION_A2A_ROLES—NoPer-key role mapping: key1:writer,key2:reader,default:admin
A2A_CLEANUP_INTERVAL3600NoSeconds between task cleanup cycles
A2A_TASK_MAX_AGE86400NoMax age (seconds) for completed tasks before cleanup

Bridge (MCP↔A2A)

VariableDefaultRequiredDescription
BASTION_BRIDGE_ALLOW_LOOPBACKfalseNoAllow bridge to forward to localhost (dev mode)

Connection Pool & Resilience

Pool Settings

VariableDefaultRequiredDescription
BASTION_POOL_MIN_SIZE5NoMinimum idle connections in pool
BASTION_POOL_MAX_SIZE20NoMaximum connections in pool
BASTION_POOL_MAX_IDLE_SECONDS300NoMax idle time before connection is closed

Circuit Breaker

VariableDefaultRequiredDescription
BASTION_CIRCUIT_BREAKER_FAILURE_THRESHOLD5NoConsecutive failures before circuit opens
BASTION_CIRCUIT_BREAKER_RECOVERY_TIMEOUT30NoSeconds before circuit tries half-open
BASTION_CIRCUIT_BREAKER_SUCCESS_THRESHOLD2NoSuccesses in half-open to close circuit

Retry

VariableDefaultRequiredDescription
BASTION_RETRY_MAX_RETRIES5NoMaximum retry attempts
BASTION_RETRY_BASE_DELAY_MS10NoBase delay (ms) for exponential backoff
BASTION_RETRY_MAX_DELAY_MS2000NoMaximum delay (ms) between retries
BASTION_RETRY_JITTER_FACTOR0.5NoJitter factor to prevent thundering herd

Rate Limiter

VariableDefaultRequiredDescription
BASTION_LIMITER_MAX_CONCURRENT10NoMax concurrent requests
BASTION_LIMITER_MAX_QUEUE100NoMax queued requests when at capacity
BASTION_LIMITER_TIMEOUT_SECONDS30NoSeconds before queued request times out

Guard (OWASP ASI06)

VariableDefaultRequiredDescription
BASTION_GUARD_MAX_CONTENT100000NoMax content length (chars) before block
BASTION_GUARD_BLOCK_SEVERITYhighNoMinimum severity to block: low, medium, high, critical
BASTION_LLM_GUARDfalseNoEnable LLM-powered semantic classification (requires Groq)
GROQ_API_KEY—ConditionalGroq API key (required when BASTION_LLM_GUARD=true)
GROQ_MODELopenai/gpt-oss-120bNoGroq model for LLM guard classification

Search & Memory

VariableDefaultRequiredDescription
BASTION_SEARCH_DEFAULT_K5NoDefault number of results for memory_search
BASTION_SEARCH_DEFAULT_THRESHOLD0.8NoDefault similarity threshold (0-1)
BASTION_CACHE_DEFAULT_THRESHOLD0.97NoL1 cache promotion threshold
BASTION_DECAY_RATE0.01NoCognitive decay rate for importance scores
BASTION_REINFORCE_BOOST1.0NoImportance boost when memory is accessed

Encryption (KMS)

VariableDefaultRequiredDescription
BASTION_KMS_KEY—NoHex-encoded 256-bit key for local encryption
BASTION_KMS_KEY_FILE—NoPath to file containing hex-encoded key
BASTION_KMS_GENERATEfalseNoAuto-generate and persist a new key
BASTION_AWS_KMS_KEY_ARN—NoAWS KMS key ARN for CMEK encryption
BASTION_GCP_KMS_RESOURCE—NoGCP KMS resource name for CMEK
AWS_REGIONus-east-1NoAWS region for KMS operations

Logging & Compliance

VariableDefaultRequiredDescription
BASTION_LOG_LEVELINFONoPython log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_JSONfalseNoEnable JSON structured logging
BASTION_COMPLIANCE_MODE—NoCompliance mode: e.g., 'eu_ai_act', 'soc2'

Storage

VariableDefaultRequiredDescription
BASTION_S3_BUCKETbastion-memory-archivesNoS3 bucket for memory archives
BASTION_PROJECT_URLhttps://bastion-self.vercel.appNoProject URL for agent card
BASTION_DOCS_URLhttps://github.com/dgboy-ai/BastionNoDocumentation URL for agent card

Query Limits

VariableDefaultRequiredDescription
AUDIT_LIMIT100NoMax rows returned by memory_audit
ANOMALY_LIMIT50NoMax rows returned by anomaly detection
SEARCH_RESULT_LIMIT500NoMax rows returned by search queries
DBA_SLOW_QUERY_LIMIT10NoMax slow queries returned by DBA tools
LOCALITY_LIMIT10NoMax rows for locality analysis

Example Configurations

Development (Mock Mode)

bash
# Minimal config — no database needed
BASTION_MOCK=true
BASTION_API_KEY=test-key

Production (CockroachDB)

bash
# Full production config
BASTION_CONN="postgresql://user:pass@your-cluster:26257/bastion?sslmode=verify-full"
BASTION_MOCK=false
BASTION_API_KEY="bastion-prod-api-key"
BASTION_A2A_PRIVATE_KEY="base64-encoded-ed25519-key"
BASTION_POOL_MAX_SIZE=20
BASTION_GUARD_BLOCK_SEVERITY=medium
BASTION_LOG_LEVEL=INFO

Docker

yaml
# docker-compose.yml environment section
environment:
  BASTION_CONN: ${BASTION_CONN}
  BASTION_API_KEY: ${BASTION_API_KEY}
  BASTION_MOCK: "false"
  BASTION_POOL_MAX_SIZE: "20"
Ready to deploy?
Follow the Setup Guide for step-by-step deployment.
Setup Guide →