headroom/docs/content/docs
Shubham Srivastava f9f3162d38
docs(proxy): document HEADROOM_SAVINGS_PROFILE and correct --mode default (#2031) (#2040)
## Description

`HEADROOM_SAVINGS_PROFILE` is an implemented env var
(`headroom/agent_savings.py`) that selects a named profile bundling
Headroom's whole compression posture (proxy mode, keep-ratio, which
messages are compressed, `force_kompress`, etc.) at proxy startup. It
was entirely undocumented — `grep` over `docs/` found zero mentions.

Related, the proxy docs were **misleading about the default optimization
mode**: `docs/content/docs/proxy.mdx` stated `--mode` defaults to
`token`, but the code default is `cache`:

```python
# headroom/cli/proxy.py — the Click option has no default
@click.option("--mode", default=None, ...)
# ... mode resolution (default is CACHE):
effective_mode = normalize_proxy_mode(mode or os.environ.get("HEADROOM_MODE") or PROXY_MODE_CACHE)
```

A bare `headroom proxy` (no `--mode`, no `HEADROOM_MODE`) runs in
**cache** mode, and the default `coding` savings profile also sets
`proxy_mode="cache"` — which is exactly what the issue reporter found
confusing.

This documents `HEADROOM_SAVINGS_PROFILE` and corrects the `--mode`
default rows so the doc is accurate and internally consistent.

Closes #2031

## Type of Change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

`docs/content/docs/proxy.mdx` only:

- Corrected the `--mode` default in the Core-options table and the
Context-management table (`token` → `cache`), each pointing to the new
Savings profiles section for the reason.
- Added a `### Savings profiles` section documenting: the
`HEADROOM_SAVINGS_PROFILE` env var; a table of the four built-in
profiles (`coding` default, `balanced` fallback, `agent-90`, `general`)
with target savings, mode, and `force_kompress`; the unset→`coding`
default; the unknown-value→`balanced` warning-and-fallback (proxy never
fails to start); and the mode precedence (explicit `--mode` >
`HEADROOM_MODE` seeded by a profile > `cache` default), with an example.

No code change. Every documented value is pinned to
`headroom/agent_savings.py` (profile definitions) and
`headroom/cli/proxy.py` (default-mode resolution).

## Testing

- [x] Unit tests not run; docs-only source verification performed
- [x] Linting not run; docs-only MDX/source verification performed
- [x] Type checking not applicable; no Python code changed
- [x] New tests not applicable; documentation-only correction
- [x] Manual testing performed

### Test Output

Docs-only change; verification is cross-checking every documented value
against the source of truth:

```text
$ grep -n "DEFAULT_PROFILE = \|FALLBACK_PROFILE = " headroom/agent_savings.py
14:FALLBACK_PROFILE = "balanced"
18:DEFAULT_PROFILE = "coding"

# profile modes / knobs (agent_savings.py):
#   coding   → proxy_mode="cache",  force_kompress=False, target_ratio=None (emergent)
#   balanced → proxy_mode="token",  force_kompress=False, target_ratio=0.30
#   agent-90 → proxy_mode="token",  force_kompress=True,  target_ratio=0.10
#   general  → proxy_mode="token",  force_kompress=False, target_ratio=None (emergent)

$ grep -n "effective_mode\|PROXY_MODE_CACHE" headroom/cli/proxy.py
# effective_mode = normalize_proxy_mode(mode or os.environ.get("HEADROOM_MODE") or PROXY_MODE_CACHE)
# → confirms the real default optimization mode is cache, not token
```

MDX sanity: code fences balance (even count) and the `### Savings
profiles` heading slugifies to `#savings-profiles`, matching the two
in-page anchor links added to the mode rows.

## Real Behavior Proof

- **Environment:** Windows 11; docs source inspected against the working
tree at the current `main` base.
- **Exact command / steps:** Each documented fact is grounded in code —
profile names, modes, `force_kompress`, and target ratios come from
`headroom/agent_savings.py:_PROFILES`; the default profile (`coding`)
from the `os.environ.get("HEADROOM_SAVINGS_PROFILE") or "coding"` reads
in `headroom/cli/proxy.py` and `headroom/proxy/server.py`; the `cache`
default mode from `headroom/cli/proxy.py`'s `mode or HEADROOM_MODE or
PROXY_MODE_CACHE`; the unknown-value fallback from
`get_agent_savings_profile` (`agent_savings.py`).
- **Observed result:** The new section's table and prose match those
sources exactly, and the previously-wrong `--mode` default rows now
state `cache`.
- **Not tested:** A live render of the Fumadocs/Next.js docs site (no
local docs build run here) — the change is MDX-syntax-valid (balanced
fences, well-formed table, standard heading-anchor slug).

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] Code comments not applicable; documentation-only change
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] Tests not applicable; docs-only facts verified against source
- [x] New and existing unit tests pass locally with my changes
- [x] CHANGELOG not applicable; documentation-only correction

## Screenshots (if applicable)

N/A (docs prose/table addition; a rendered screenshot can be added if
the docs site is built for preview).

## Additional Notes

- Test/tests-added checklist items are N/A — this is a
documentation-only change.
- Out of scope (intentionally): the `--mode` Click **help text** in
`headroom/cli/proxy.py` also says "default: token" and is likewise
inaccurate, but correcting Python help text is a code change beyond this
docs issue — noted as a possible follow-up.

---------

Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
2026-07-14 14:10:28 -04:00
..
agent-orchestration.mdx docs(orchestration): guide repeated agent wakes with CCR (#1871) 2026-07-08 08:37:24 -05:00
agno.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
anthropic-sdk.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
api-reference.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
architecture.mdx docs(orchestration): guide repeated agent wakes with CCR (#1871) 2026-07-08 08:37:24 -05:00
benchmarks.mdx [codex] Document local LLM prefill benchmarking (#1396) 2026-07-09 21:47:59 -05:00
cache-optimization.mdx docs(orchestration): guide repeated agent wakes with CCR (#1871) 2026-07-08 08:37:24 -05:00
ccr.mdx docs: qualify CCR auto-resolution support for Gemini (#2044) 2026-07-14 11:59:08 -04:00
ci-cd-flows.mdx docs(ci): add CI/CD flow diagrams (#1062) 2026-06-16 23:05:15 -07:00
claude-code-azure-foundry.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
claude-code-vertex.mdx docs: use headroom-ai package name in install commands (#1014) (#1257) 2026-06-22 19:25:00 -05:00
code-compression.mdx fix: align docs and prune dead compatibility surfaces 2026-05-09 14:07:59 -07:00
community-savings.mdx fix(telemetry): switch anonymous telemetry to opt-in (off by default) (#1223) 2026-06-20 21:26:04 -07:00
configuration.mdx fix(core): load ONNX Runtime dynamically so headroom._core imports on non-AVX2 x86-64 (#1715) 2026-07-14 13:25:41 -04:00
context-management.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
docker-install.mdx fix(dashboard): distinguish unavailable RTK from zero stats in Docker (#1901) 2026-07-09 09:39:16 -04:00
errors.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
failure-learning.mdx feat: add first-class OpenCode support (wrap, learn, mcp install) (#559) 2026-06-25 13:38:58 -05:00
filesystem-contract.mdx feat: add lean-ctx context tool support 2026-05-11 17:54:17 -04:00
how-compression-works.mdx docs(orchestration): guide repeated agent wakes with CCR (#1871) 2026-07-08 08:37:24 -05:00
image-compression.mdx fix: align docs and prune dead compatibility surfaces 2026-05-09 14:07:59 -07:00
index.mdx docs: fix stale API references, retired class imports, and incorrect examples 2026-06-02 19:19:19 -04:00
installation.mdx docs: retire IntelligentContext from README and installation guide (#1445) 2026-07-08 09:16:11 -05:00
langchain.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
limitations.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
litellm.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
local-llm-prefill.mdx [codex] Document local LLM prefill benchmarking (#1396) 2026-07-09 21:47:59 -05:00
mcp.mdx feat(mcp): add streamable HTTP MCP transport (#1773) 2026-07-14 13:25:45 -04:00
memory.mdx feat(memory): add opt-in Apple-GPU (MPS) embedding runtime (#766) 2026-06-11 12:59:20 -05:00
meta.json [codex] Document local LLM prefill benchmarking (#1396) 2026-07-09 21:47:59 -05:00
metrics.mdx fix(proxy): expose persistent savings metrics (#1647) 2026-07-01 23:28:12 -05:00
openai-sdk.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
opencode.mdx fix(opencode): use local MCP config (#1383) 2026-07-06 06:22:15 -07:00
persistent-installs.mdx docs: document Claude VSCode deferred-tool rendering caveat (#2045) 2026-07-14 11:53:01 -04:00
pipeline-extensions.mdx docs: add pipeline-extension recipe and x-headroom-base-url routing docs (#1712) 2026-07-07 12:45:16 -05:00
proxy.mdx docs(proxy): document HEADROOM_SAVINGS_PROFILE and correct --mode default (#2031) (#2040) 2026-07-14 14:10:28 -04:00
quickstart.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
releases.mdx docs(ci): add CI/CD flow diagrams (#1062) 2026-06-16 23:05:15 -07:00
savings.mdx feat(savings): durable savings ledger + headroom savings command (#1127) 2026-06-22 18:47:57 -05:00
shared-context.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
simulation.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
smart-crusher.mdx docs: fix stale API references, retired class imports, and incorrect examples 2026-06-02 19:19:19 -04:00
strands.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
text-and-logs.mdx fix: align docs and prune dead compatibility surfaces 2026-05-09 14:07:59 -07:00
troubleshooting.mdx docs: document Claude VSCode deferred-tool rendering caveat (#2045) 2026-07-14 11:53:01 -04:00
vercel-ai-sdk.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00