Context Engine — Feature Flags
All feature flags are Redis keys under the ff:context: prefix. Precedence
is most specific wins: agent > org > global. Flags are read on every
request with sub-millisecond overhead (Redis is already in the hot path).
Engine mode
Controls whether the full assembly pipeline runs, only retrieval runs, or the request is passed through to the caller unmodified.
| Key | Values | Effect |
|---|---|---|
ff:context:mode:global | full, retrieval_only, passthrough | Global engine mode (default: full). |
ff:context:mode:{org_id} | full, retrieval_only, passthrough | Per-org override. |
ff:context:mode:{org_id}:{agent_id} | full, retrieval_only, passthrough | Per-agent override. |
Modes:
full— Steps 1–9 of the LLD #7 §2.3 pipeline run as designed.retrieval_only— Steps 1, 3, 6, 7, 8 only. Skips pinned loading, compaction checks, and metrics emission. Used as a circuit-breaker when the pipeline is misbehaving in prod.passthrough— The Context Engine returns the caller's prompt unchanged plus the L1–L4 immutable layers. Emergency fallback only.
Sampling tier override
Overrides the adaptive sampler tier for a given org. Useful when an org needs higher-fidelity data for debugging or when a low-value org should be down-sampled aggressively to protect the $1K/mo metrics ceiling (founder decision #3).
| Key | Values | Effect |
|---|---|---|
ff:context:sampling:pin:{org_id} | T0, T1, T2, T3, T4 | Pin this org's sampling tier. Unset the key to return control to the adaptive sampler. |
Tier rates: T0=100%, T1=50%, T2=20%, T3=5%, T4=2%.
Compaction toggle
| Key | Values | Effect |
|---|---|---|
ff:context:compaction:enabled | true, false | Global compaction toggle (default: true). Disabling stops the sliding-window summarizer and skips the compaction step in assembly. Use only if compaction quality has regressed. |
Runbook: flipping a flag safely
-
Check current state
redis-cli -u "$REDIS_URL" get "ff:context:mode:global" -
Set the flag (example: put an org in retrieval_only mode)
redis-cli -u "$REDIS_URL" set "ff:context:mode:org_abc123" "retrieval_only" -
Verify the change landed
- Grafana → Context Engine Overview → filter
org_id=org_abc123 - Expect
context_engine_assembly_duration_secondsto drop (fewer steps) - Expect
context_engine_savings_ratioto change (different pipeline shape)
- Grafana → Context Engine Overview → filter
-
Audit trail Every flag flip must be accompanied by a GitHub issue with label
feature-flagdocumenting the reason, the operator, and the rollback plan. Flag state is source-of-truth in Redis but the decision log is on GitHub. -
Rollback
redis-cli -u "$REDIS_URL" del "ff:context:mode:org_abc123"The precedence chain falls back to the org's nearest ancestor, ultimately hitting
ff:context:mode:global.
Defaults at process startup
If none of the Redis keys are set:
| Flag | Default |
|---|---|
| mode | full |
| sampling tier | adaptive (no pin) |
| compaction | true |
These defaults are baked into the Context Engine binary (not read from the ConfigMap) so that a Redis outage does not disable the engine.