Documentation Index
Fetch the complete documentation index at: https://docs.tensorcost.com/llms.txt
Use this file to discover all available pages before exploring further.
Feature flags
TensorCost gates every non-trivial new behavior behind a feature flag. Flags let us roll out per tenant, per plan tier, or per environment without a code push, A/B-test recommenders, and recover quickly when a launch goes sideways.How it works
Both the backend (@tensorcost/feature-flags) and the frontend (mf-sdk/context.tsx’s useFeature() hook) evaluate flags through LaunchDarkly, with environment-variable fallbacks for local dev and self-hosted installs.
Every evaluation passes a tenant context (tenantId, plan, region, customerType) and the deployment environment, so the same flag can evaluate differently across customers.
Frontend pattern
Microfrontends consumeuseFeature() from @tensorcost/mf-sdk:
GET /v1/tenant/feature-flags. The context refreshes every 5 minutes; routes and sidebar entries gated by a flag appear / disappear without a page reload.
Backend pattern
Live flag inventory
This is the public-facing summary; admins can see the full list under Settings → Feature flags.| Flag | Category | Default | Purpose |
|---|---|---|---|
grpc-enabled | services | ON | Long-lived agent gRPC stream. Disabling forces HTTPS sync fallback. |
anomaly-detection-enabled | services | ON | Statistical anomaly detection on GPU + inference metrics. |
alert-rules-enabled | services | ON | Custom alert-rule evaluation engine. |
escalation-enabled | services | ON | Multi-level escalation chains. |
burn-rate-alerts-enabled | services | OFF (rolling) | 50 / 80 / 100 % burn-rate alerts on budgets. |
runaway-loop-detector | services | ON | Per-agent loop / retry-storm detection. |
auto-scaling-enabled | services | OFF | Auto-scaling orchestrator that acts on recommendations. |
data-retention-enabled | jobs | ON | Nightly data cleanup within configured retention. |
aggregation-enabled | jobs | ON | Hourly metric + cost rollups. |
cost-forecast-enabled | jobs | ON | Daily cost forecasting + budget breach prediction. |
tenant-cleanup-enabled | jobs | ON | Soft-deleted tenant purge after retention window. |
bedrock-recommenders-enabled | recommenders | ON | The four MVP Bedrock recommenders (routing, cache, provisioned-throughput, runaway-loop). |
azure-openai-recommenders-enabled | recommenders | OFF (rolling) | Azure OpenAI counterparts. |
vertex-recommenders-enabled | recommenders | OFF | Vertex counterparts. |
mcp-write-tools-enabled | experimental | OFF | MCP write surface for the few customers that have granted write scope. |
ml-enabled | experimental | OFF | Second-layer ML anomaly detection. |
tanstack-query-migration | platform | OFF | Per-MF migration off RTK Query onto TanStack Query. |
services flags toggle long-running components. jobs flags toggle scheduled tasks. recommenders flags toggle individual recommendation engines per provider. experimental flags are typically gated to specific tenants in private beta.
Reading flag state
Admins call:source is launchdarkly (live evaluation) or env (env-var fallback in self-hosted).
Plan-tier gating
Plan tiers (free, growth, enterprise) are part of the LaunchDarkly context. Common patterns:
mcp-write-tools-enabledtargeted toplan in ['enterprise']and a specific tenant allow-list.bedrock-recommenders-enabledopen to all plans;azure-openai-recommenders-enabledrolling out by percentage.- Experimental flags targeted to specific
tenant.keyvalues for design partners.
Self-hosted deployments
Self-hosted instances skip LaunchDarkly. Each flag has a matching upper-snake-case env var:false disables the corresponding capability at startup.
Stale-flag quarterly cleanup ritual
Every flag is technical debt waiting to happen. We hold a 30–45 minute cleanup ritual on the first Monday of March, June, September, and December:Pull the live flag list
Pull the LaunchDarkly project flag list and join it against
grep -r 'useFeature\\|isEnabled' apps-new/.Tag each flag
Each flag gets one of: Live & owned (keep), Permanent gate (rename to
is-feature-x and document), Stale (no usage in 90 days), Orphan (no code reference).Delete stale and orphan flags
Stale flags: archive in LaunchDarkly, leave the env-var fallback in code for one quarter, then remove. Orphans: delete immediately.
When to reach for a flag vs configuration
- Feature flag — runtime toggle, varies per tenant, safe to flip without a deploy, typically binary.
- Configuration — static setting, set via env var or admin UI at deploy time, varies by environment not tenant.