mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-12-03 18:39:57 +08:00
7ff842da170b5bceb5d67048473eeb8a18e09a51
41
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
12060a6219 |
chore(deps): bump transformers from 5.0.0 to 5.3.0 in the uv group across 1 directory (#1662)
Bumps the uv group with 1 update in the / directory: [transformers](https://github.com/huggingface/transformers). Updates `transformers` from 5.0.0 to 5.3.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/huggingface/transformers/releases">transformers's releases</a>.</em></p> <blockquote> <h2>v5.1.0: EXAONE-MoE, PP-DocLayoutV3, Youtu-LLM, GLM-OCR</h2> <h2>New Model additions</h2> <h3>EXAONE-MoE</h3> <!-- raw HTML omitted --> <p>K-EXAONE is a large-scale multilingual language model developed by LG AI Research. Built using a Mixture-of-Experts architecture, K-EXAONE features 236 billion total parameters, with 23 billion active during inference. Performance evaluations across various benchmarks demonstrate that K-EXAONE excels in reasoning, agentic capabilities, general knowledge, multilingual understanding, and long-context processing.</p> <ul> <li>Add EXAONE-MoE implementations (<a href="https://redirect.github.com/huggingface/transformers/issues/43080">#43080</a>) by <a href="https://github.com/nuxlear"><code>@nuxlear</code></a></li> </ul> <h3>PP-DocLayoutV3</h3> <!-- raw HTML omitted --> <p><strong>PP-DocLayoutV3</strong> is a unified and high-efficiency model designed for comprehensive layout analysis. It addresses the challenges of complex physical distortions—such as skewing, curving, and adverse lighting—by integrating instance segmentation and reading order prediction into a single, end-to-end framework.</p> <ul> <li>[Model] Add PP-DocLayoutV3 Model Support (<a href="https://redirect.github.com/huggingface/transformers/issues/43098">#43098</a>) by <a href="https://github.com/zhang-prog"><code>@zhang-prog</code></a></li> </ul> <h3>Youtu-LLM</h3> <!-- raw HTML omitted --> <p>Youtu-LLM is a new, small, yet powerful LLM, contains only 1.96B parameters, supports 128k long context, and has native agentic talents. On general evaluations, Youtu-LLM significantly outperforms SOTA LLMs of similar size in terms of Commonsense, STEM, Coding and Long Context capabilities; in agent-related testing, Youtu-LLM surpasses larger-sized leaders and is truly capable of completing multiple end2end agent tasks.</p> <ul> <li>Add Youtu-LLM model (<a href="https://redirect.github.com/huggingface/transformers/issues/43166">#43166</a>) by <a href="https://github.com/LuJunru"><code>@LuJunru</code></a></li> </ul> <h3>GlmOcr</h3> <!-- raw HTML omitted --> <p>GLM-OCR is a multimodal OCR model for complex document understanding, built on the GLM-V encoder–decoder architecture. It introduces Multi-Token Prediction (MTP) loss and stable full-task reinforcement learning to improve training efficiency, recognition accuracy, and generalization. The model integrates the CogViT visual encoder pre-trained on large-scale image–text data, a lightweight cross-modal connector with efficient token downsampling, and a GLM-0.5B language decoder. Combined with a two-stage pipeline of layout analysis and parallel recognition based on PP-DocLayout-V3, GLM-OCR delivers robust and high-quality OCR performance across diverse document layouts.</p> <ul> <li>[GLM-OCR] GLM-OCR Support (<a href="https://redirect.github.com/huggingface/transformers/issues/43391">#43391</a>)by <a href="https://github.com/zRzRzRzRzRzRzR"><code>@zRzRzRzRzRzRzR</code></a></li> </ul> <h2>Breaking changes</h2> <ul> <li> <p>🚨 T5Gemma2 model structure (<a href="https://redirect.github.com/huggingface/transformers/issues/43633">#43633</a>) - Makes sure that the attn implementation is set to all sub-configs. The config.encoder.text_config was not getting its attn set because we aren't passing it to PreTrainedModel.<strong>init</strong>. We can't change the model structure without breaking so I manually re-added a call to self.adjust_attn_implemetation in modeling code</p> </li> <li> <p>🚨 Generation cache preparation (<a href="https://redirect.github.com/huggingface/transformers/issues/43679">#43679</a>) - Refactors cache initialization in generation to ensure sliding window configurations are now properly respected. Previously, some models (like Afmoe) created caches without passing the model config, causing sliding window limits to be ignored. This is breaking because models with sliding window attention will now enforce their window size limits during generation, which may change generation behavior or require adjusting sequence lengths in existing code.</p> </li> <li> <p>🚨 Delete duplicate code in backbone utils (<a href="https://redirect.github.com/huggingface/transformers/issues/43323">#43323</a>) - This PR cleans up backbone utilities. Specifically, we have currently 5 different config attr to decide which backbone to load, most of which can be merged into one and seem redundant After this PR, we'll have only one config.backbone_config as a single source of truth. The models will load the backbone from_config and load pretrained weights only if the checkpoint has any weights saved. The overall idea is same as in other composite models. A few config arguments are removed as a result.</p> </li> <li> <p>🚨 Refactor DETR to updated standards (<a href="https://redirect.github.com/huggingface/transformers/issues/41549">#41549</a>) - standardizes the DETR model to be closer to other vision models in the library.</p> </li> <li> <p>🚨Fix floating-point precision in JanusImageProcessor resize (<a href="https://redirect.github.com/huggingface/transformers/issues/43187">#43187</a>) - replaces an <code>int()</code> with <code>round()</code>, expect light numerical differences</p> </li> <li> <p>🚨 Remove deprecated AnnotionFormat (<a href="https://redirect.github.com/huggingface/transformers/issues/42983">#42983</a>) - removes a missnamed class in favour of <code>AnnotationFormat</code>.</p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/huggingface/transformers/commit/aad13b87ed59f2afcfaebc985f403301887a35fc"><code>aad13b8</code></a> v5.3.0</li> <li><a href="https://github.com/huggingface/transformers/commit/f6c63a61156fc0799a839f5de0219cad857c84a0"><code>f6c63a6</code></a> protect imports (<a href="https://redirect.github.com/huggingface/transformers/issues/44437">#44437</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/fd6bc380c8854a370fbc9f68a157895d84dce7d7"><code>fd6bc38</code></a> [vllm + v5 fix] handle TokenizersBackend fallback properly for v5 (<a href="https://redirect.github.com/huggingface/transformers/issues/44255">#44255</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/30c480166a95342fefdd9d727fc2a163bea7b2b1"><code>30c4801</code></a> Fix CLI NameError: name 'TypeAdapter' is not defined (<a href="https://redirect.github.com/huggingface/transformers/issues/44256">#44256</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/ee4c22078ff3987cbab669f332ff022d4fa89469"><code>ee4c220</code></a> Enforce min length in some generate tests (<a href="https://redirect.github.com/huggingface/transformers/issues/44401">#44401</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/a4f3df01aa9eab510768ea4396779b896b1ed8ab"><code>a4f3df0</code></a> [tiny] Add olmo_hybrid to tokenizer auto-mapping (<a href="https://redirect.github.com/huggingface/transformers/issues/44416">#44416</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/13135882276c0e4f72c921fc01a26f02e2137128"><code>1313588</code></a> Update PR template (<a href="https://redirect.github.com/huggingface/transformers/issues/44415">#44415</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/7235d44257e7e4765317d475622e2085a09c9e3b"><code>7235d44</code></a> Add eurobert (<a href="https://redirect.github.com/huggingface/transformers/issues/39455">#39455</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/f60c4e9423a2063fd0e313428ebbb3d5d1e6bdd6"><code>f60c4e9</code></a> Add Qwen3.5 support for sequence classification (<a href="https://redirect.github.com/huggingface/transformers/issues/44406">#44406</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/fa7f4b68df0c629f321821671b8988200a49e59d"><code>fa7f4b6</code></a> update the expected output for qwen2_5_vl w/ pytorch 2.10 XPU (<a href="https://redirect.github.com/huggingface/transformers/issues/44426">#44426</a>)</li> <li>Additional commits viewable in <a href="https://github.com/huggingface/transformers/compare/v5.0.0...v5.3.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/headroomlabs-ai/headroom/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
4db3bc91d9 |
fix(bedrock): add boto3 1.41 + CRT for aws login credentials (#1486)
## Description `pip install headroom-ai[bedrock]` cannot serve users who authenticate with `aws login` (IAM Identity Provider / console-login, DPoP). Resolving those credentials requires the AWS Common Runtime (CRT); without `awscrt`, botocore raises `MissingDependencyException`. The AWS docs state the requirement as: **"Boto3 version 1.41.0 or later with AWS Common Runtime (CRT)"** — i.e. both a modern boto3 floor and CRT (installed via the `[crt]` extra). ## Type of Change - [x] Bug fix (non-breaking) ## Changes Made - `pyproject.toml` `bedrock` extra: bump `boto3>=1.28.0` → `boto3>=1.41.0`, add `botocore[crt]>=1.41.0` (installs `awscrt`). - `uv.lock`: regenerated — adds `awscrt`, resolves `boto3` to 1.42.x. No code changes — the bedrock backend already passes `aws_profile_name` through to the LiteLLM calls (via #1456); this just makes the installed dependencies actually able to resolve `aws login` credentials. ## Impact - **`aws login` (IAM Identity Provider / DPoP):** now works — awscrt present. - **`aws sso login` (classic Identity Center):** unaffected (already worked). - **static keys (`~/.aws/credentials`):** unaffected. - Bumping the boto3 floor only affects the optional `[bedrock]` extra; bedrock users benefit from a current boto3 regardless. ## Testing Dependency-only change. `uv lock` resolves cleanly (257 packages, awscrt 0.29.2, boto3 1.42.38). No runtime code path altered, so existing bedrock tests are unaffected. ## Checklist - [x] Self-review performed - [x] No new warnings - [x] Linting passes ## Additional Notes Focused on the dependency gap only. ARN routing / named-profile wiring / docs are handled in #1456; pricing in #1485. |
||
|
|
5771a8020e |
fix(deps): remediate dependency CVEs and publish SBOM (#1509)
## Description
Supply-chain hardening: takes the **shipped** dependency surface from
**26 known CVEs to 0**. `pip install headroom-ai[all]` now resolves with
no known vulnerabilities (verified with Anchore syft + grype). Also
publishes a checked-in SBOM package (`sbom/`) so any user — especially
pilots running their own security review — can verify what's inside and
that we track it.
This addresses the Dependabot alerts on `main` (9 high / 4 moderate / 7
low at time of writing).
Closes #
## Type of Change
- [x] 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
**Rust**
- `pyo3` 0.24 → 0.29 (GHSA-36hh-v3qg-5jq4 High, GHSA-chgr-c6px-7xpp
Med). Migrated `Python::allow_threads` → `Python::detach` (10 sites) and
added `from_py_object` to the `Clone`-deriving `#[pyclass]` types (both
required by the 0.25+ API).
- `pyo3-log` 0.12 → 0.13; `lru` 0.12 → 0.18 (GHSA-rhfx-m35p-ff5j).
**Python**
- `torch` → 2.12.1, `mem0ai` → 2.x.
- Floor-pinned transitive CVE deps via `[tool.uv]
constraint-dependencies`: `pygments>=2.20.0`,
`pydantic-settings>=2.14.2`, `gitpython>=3.1.50`, `langsmith>=0.9.0`.
- **Removed `benchmark` from the `[all]` aggregate** so the default
install is CVE-free. `lm-eval` is invoked as an external subprocess
(`python -m lm_eval`) and never imported, so it is not a true runtime
dep — it remains available via the opt-in `[benchmark]` extra. See
[Accepted Risks](#additional-notes).
**npm (build/test tooling — never shipped in the
wheel/container/published SDK)**
- `esbuild` override `>=0.28.1` in `sdk/typescript` + `plugins/openclaw`
(GHSA-g7r4-m6w7-qqqr).
- `docs/`: `@anthropic-ai/sdk` → `^0.106.0` (GHSA-p7fg-763f-g4gf),
`postcss` override to force Next.js's bundled copy ≥8.5.10
(GHSA-qx2v-qp2m-jg93); regenerated a stale `bun.lock` that carried a
**Critical** vitest/vite.
**CI**
- Pinned `pypa/gh-action-pypi-publish` `@release/v1` → `@v1.13.0`
(GHSA-vxmw-7h4f-hqxh) in `release.yml` + `publish.yml`.
**SBOM**
- New `sbom/` directory: CycloneDX 1.7 + SPDX 2.3 SBOMs, grype scan
evidence, 330-package license inventory, and a regeneration guide.
## Testing
- [ ] Unit tests pass (`pytest`) — N/A, no Python source changed
(deps/config only)
- [x] Linting passes — `cargo fmt --check` + `cargo clippy` clean on the
changed crate; 0 `.py` files changed so `ruff`/`mypy` scope is
unaffected
- [x] Type checking passes — `cargo check --workspace` (0 errors)
- [ ] New tests added — N/A (dependency bumps; covered by existing
suites)
- [x] Manual testing performed — see Real Behavior Proof
### Test Output
```text
# headroom-ai[all] product surface — the number that matters
$ grype sbom:sbom/headroom-sbom-all-extra.cdx.json
No vulnerabilities found
# full repo scan (universal lock incl. opt-in [benchmark] + dev)
$ grype sbom:sbom/headroom-sbom.cdx.json
NAME INSTALLED TYPE VULNERABILITY SEVERITY
sqlitedict 2.1.0 python GHSA-g4r7-86gm-pgqc High # [benchmark]-only, unpatchable, accepted
nltk 3.9.4 python GHSA-p4gq-832x-fm9v High # [benchmark]-only, unpatchable, accepted
# pyo3 0.29 migration — extension builds + imports + runs
$ cargo check --workspace
Finished `dev` profile [unoptimized + debuginfo] target(s)
$ maturin develop && python -c "from headroom._core import DiffCompressor, SmartCrusher; ..."
extension OK — detach + from_py_object paths exercised
# lru 0.18 — eviction path
$ cargo test -p headroom-proxy --lib drift
14 passed, 213 filtered out
# per-ecosystem npm audits
$ (cd sdk/typescript && npm audit) -> found 0 vulnerabilities
$ (cd plugins/openclaw && npm audit) -> found 0 vulnerabilities
$ (cd docs && npm audit && bun audit) -> found 0 vulnerabilities / No vulnerabilities found
```
## Real Behavior Proof
- Environment: macOS (darwin 25.4.0, arm64), Python 3.12 `.venv`, Rust
1.95 toolchain, syft 1.46.0, grype 0.115.0, bun 1.3.14, maturin 1.13.3.
- Exact command / steps: (1) `uv export --extra all --no-dev
--no-emit-project | syft → grype` for the product surface; (2) `cargo
check --workspace` + `maturin develop` + extension import/compress smoke
test; (3) `cargo test -p headroom-proxy --lib drift`; (4) `cargo fmt
--check` + `cargo clippy -p headroom-py`; (5) `npm audit` in
sdk/openclaw/docs + `bun audit` in docs.
- Observed result: `headroom-ai[all]` resolution scans clean — "No
vulnerabilities found" (179 pkgs); full/prod SBOM shows only the 2
documented accepted CVEs; pyo3 0.29 extension imports and runs (detach +
from_py_object paths exercised); drift tests 14/14 pass; cargo fmt +
clippy clean; all npm/bun audits report 0.
- Not tested: full `pytest` suite (no Python source changed);
release-profile wheel build (used dev-profile `maturin develop` for the
import proof — the extension is semantically identical).
## 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] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
(`sbom/README.md`)
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective — N/A
(dependency bumps; existing suites + scans cover it)
- [x] New and existing unit tests pass locally with my changes
- [ ] I have updated the CHANGELOG.md — N/A (Release Please
auto-generates from the conventional commit)
## Additional Notes
**Accepted risks (the 2 residual CVEs).** Both originate solely from the
EleutherAI `lm-evaluation-harness` under the **opt-in `[benchmark]`
extra**, which Headroom invokes as a subprocess (never imports):
- `sqlitedict` CVE-2024-35515 (High) — pickle deserialization; package
abandoned (last release 2021), **no upstream fix exists**.
- `nltk` CVE-2026-54293 (High) — path traversal in `nltk.data.load()`;
affects ≤3.9.4 (current latest), **no patched release**.
Neither is in `[all]`, the published wheel, or the container. They are
documented in `sbom/README.md` and will be picked up automatically once
upstream ships fixes.
**Release/CHANGELOG:** N/A items above are because this is a
dependency/security PR with no Python source changes; CHANGELOG is
Release-Please-managed via the conventional commit message.
|
||
|
|
35939c3536 |
fix(dashboard): include RTK stats in the historical tab (#1324)
## Description Restart the proxy, open the dashboard, go to the Historical tab and the RTK stats are gone. The Session tab shows them fine, Historical just doesn't have them. The reason is where the two tabs get their numbers. The Session tab calls `_get_context_tool_stats()` live, which reads RTK's own stats file. The Historical tab calls `history_response()`, which only contains the persisted proxy-compression data. RTK savings are never written into that savings JSON, they live in the RTK tool's separate stats file, so after a restart Historical has nothing to show for them. The fix makes `/stats-history` do the same thing `/stats` already does: pull the live RTK stats with `_get_context_tool_stats()` and attach them to the history response under a `cli_filtering` key (with `tool`, `label`, `lifetime` and `session`). The Historical tab then renders an RTK card from `historyStats.cli_filtering.lifetime.tokens_saved`. A few notes: 1. The card is hidden when `cli_filtering` is null, so setups without RTK look exactly as they do today. No empty card, no errors. 2. Reading the RTK stats is best-effort: if `_get_context_tool_stats()` raises (missing file, parse error, IO), `cli_filtering` falls back to null and the Historical tab stays available rather than returning a 500. 3. Nothing about how RTK stats are stored changed, we just read them on the history endpoint too, so there's no migration. Closes #1177 ## Type of Change - [x] 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) - [ ] Documentation update - [ ] Performance improvement - [ ] Code refactoring (no functional changes) ## Changes Made - `headroom/proxy/server.py`: the `/stats-history` handler now attaches live RTK stats under `cli_filtering`, the same source `/stats` uses, wrapped in best-effort error handling; the endpoint docstring documents the curated shape. - `headroom/dashboard/templates/dashboard.html`: add an RTK card to the Historical tab, hidden when there's no RTK data. - `tests/test_proxy_savings_history.py`: `test_stats_history_includes_cli_filtering`. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check`) - [x] Type checking passes (`mypy headroom`) - [x] New tests added for new functionality - [ ] Manual testing performed ### Test Output ```text $ uv run --extra dev python -m pytest tests/test_proxy_savings_history.py -q passed ruff: All checks passed! mypy: Success: no issues found ``` ## Real Behavior Proof - Environment: macOS, Python 3.13, this branch. - Exact command / steps: `uv run --extra dev python -m pytest tests/test_proxy_savings_history.py::test_stats_history_includes_cli_filtering`. The test hits `/stats-history` and asserts the payload carries `cli_filtering` with the RTK numbers the Historical tab reads. - Observed result: the `/stats-history` response now carries `cli_filtering` (`tool`/`label`/`lifetime`/`session`), the field the Historical tab was missing after a restart. `ruff` and `mypy` are clean on the changed files. - Not tested: I did not click through the rendered dashboard after a real restart, and this repo's test suite needs the native `_core` extension built (CI builds it), so the assertion runs in CI. The data the tab consumes is covered by the test, and the card is gated on that data being present. ## 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] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] I have updated the CHANGELOG.md if applicable ## Additional Notes |
||
|
|
b4571cc346 |
feat: headroom wrap opencode / unwrap opencode CLI (#1105)
## Summary This PR implements transparent `headroom wrap opencode` support without asking users to edit OpenCode provider URLs, choose an extra CLI flag, or maintain a static provider list. The wrapper now lives at the runtime transport boundary: OpenCode keeps its user/provider config, while Headroom intercepts outbound provider traffic in-process and routes it through the local Headroom proxy. ## What changed ### Transparent OpenCode wrapping - `headroom wrap opencode` injects the `headroom-opencode` plugin through `OPENCODE_CONFIG_CONTENT`. - Existing OpenCode provider URLs are preserved. We do not rewrite user config URLs to point at Headroom. - Existing `OPENAI_BASE_URL` and `ANTHROPIC_BASE_URL` env vars are preserved. - Local OpenCode traffic, localhost traffic, and Headroom proxy traffic bypass the shim to avoid loops. ### Runtime transport interception - Added an OpenCode plugin transport shim that wraps: - `globalThis.fetch` - `http.request` / `http.get` - `https.request` / `https.get` - External provider calls are routed to the local Headroom proxy. - The original upstream origin is passed through `x-headroom-base-url`, so the proxy can forward to the real provider without changing OpenCode config. - External `http2.connect` is blocked loudly instead of allowing direct provider traffic to leak outside Headroom. ### Live provider additions Provider coverage is no longer based on a static config scan. Because routing happens at outbound request time, providers added mid-session are routed through Headroom automatically as long as they use the covered Node transport paths. ### Subagent and child-process coverage - The parent OpenCode plugin sets a packaged Node preload shim through `NODE_OPTIONS=--import=.../hook-shim/handler.js`. - The transport shim patches `child_process.spawn`, `exec`, `execFile`, and `fork` so child Node processes receive the Headroom preload even when OpenCode passes a custom `env`. - The child-process shim fails closed if it loads without `HEADROOM_OPENCODE_TRANSPORT_PROXY_URL`. - This closes the subagent leak path where a child Node process could otherwise start without Headroom transport interception. ## Why this goes beyond PR #1089 PR #1089 improves OpenCode provider registration, but it still focuses on provider config shape. This PR moves the enforcement boundary to runtime transport interception. This PR goes further because: - No provider URL rewriting is required. - New providers added mid-session are covered automatically. - Subagents and child Node processes inherit the Headroom transport shim. - Direct external HTTP/2 paths fail loudly instead of leaking. - The wrap remains transparent to the user's OpenCode provider config. - The wrapper is fail-closed for unsupported child-process preload state. ## Additional robustness fixes While validating the change in Docker, the full Python suite exposed unrelated Linux/container robustness issues. These are fixed in this PR so the suite is green: - Binary cache handling now treats cache paths under a non-writable existing parent as unavailable, including when tests run as root in Docker. - `release_version.py` honors `MANUAL_VER` before git calls so direct script execution works outside a `.git` checkout. - Test logger isolation now resets relevant Headroom child loggers so proxy logging setup cannot poison later `caplog` tests. - The scanner missing-path test now uses a guaranteed missing `tmp_path` child instead of relying on `/nonexistent/path`. ## Validation All implementation validation was run inside Docker. - Full Python suite from a fresh Docker copy: `6605 passed, 523 skipped`. - Ruff on changed Python/OpenCode paths: passed. - OpenCode plugin typecheck: passed. - OpenCode plugin tests: `9 passed`. - OpenCode plugin build: passed. - Hook shim preload smoke test: passed. ## Notes This PR intentionally does not add a CLI option. `headroom wrap opencode` means full wrap. Either Headroom wraps OpenCode transparently, or the path fails loudly instead of silently leaking provider traffic. --------- Co-authored-by: Rudimar Ronsoni <6081613+rudironsoni@users.noreply.github.com> |
||
|
|
c65e321ea2 |
ci: bump the uv group across 1 directory with 5 updates (#1020)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/chopratejas/headroom/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
27befef694 |
ci: bump the uv group across 1 directory with 17 updates (#832)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/chopratejas/headroom/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
9579567b7d |
chore(deps): loosen over-pinned constraints and add upper bounds (#538)
## What Loosen over-pinned Python dependency constraints and add missing upper bounds in `pyproject.toml`. Also bump the neo4j Docker image and uv builder version. ## Why Several dependencies had constraints that either blocked security patches or allowed silent major-version jumps: - `litellm==1.82.3` was an exact pin — every security patch release requires a manual lockfile bump - `transformers`, `sentence-transformers` had no upper bound and have already crossed major version boundaries without a constraint gate - `neo4j>=5.20.0` had no upper cap; the driver has already reached 6.x in the wild - `mem0ai>=0.1.100` had a pre-1.0 floor while the locked version is already 1.0.11 - `langchain-core`, `langchain-openai`, `qdrant-client`, `uvicorn` had no upper bound on a range with active major-version churn - `docker-compose.yml` pinned neo4j at `5.15.0`, which is 11 patch releases behind the current 5.x LTS - `Dockerfile` pinned uv at `0.11.16`; latest stable is `0.11.18` ## How Constraint changes only — no code changes, no `uv lock --upgrade`. The existing locked versions all satisfy the new bounds (we added caps, not floors). `uv` re-resolved the lockfile to format revision 3 (adds `upload-time` metadata fields) and cleaned up the defunct `llmlingua` extra entries. | Dependency | Before | After | |---|---|---| | `litellm` | `==1.82.3` | `>=1.82.3,<2.0` | | `transformers` | `>=4.30.0` | `>=4.30.0,<6.0` | | `sentence-transformers` | `>=2.2.0` | `>=2.2.0,<6.0` | | `neo4j` | `>=5.20.0` | `>=5.20.0,<7.0` | | `mem0ai` | `>=0.1.100` | `>=1.0.0,<2.0` | | `langchain-core` | `>=0.2.0` | `>=0.2.0,<4.0` | | `langchain-openai` | `>=0.1.0` | `>=0.1.0,<2.0` | | `qdrant-client` | `>=1.9.0` | `>=1.9.0,<2.0` | | `uvicorn` | `>=0.23.0` | `>=0.23.0,<1.0` | | neo4j Docker image | `5.15.0` | `5.26` | | uv (Dockerfile ARG) | `0.11.16` | `0.11.18` | ## Breaking changes None. All currently installed versions fall within the new ranges. Installers that previously resolved `litellm` to an older exact pin may now resolve newer patch releases — which is the desired behavior. --------- Co-authored-by: Tejas Chopra <chopratejas@gmail.com> |
||
|
|
fa558c5647 |
fix(deps): move gunicorn to [proxy-prod] extra, add Windows guard (#537)
* fix(deps): add missing runtime deps to [code] and [proxy] extras - Add gunicorn>=21.0.0 to the [proxy] extra The proxy docs (docs/content/docs/proxy.mdx and wiki/proxy.md) show gunicorn as the recommended production deployment server: pip install gunicorn gunicorn headroom.proxy.server:app --worker-class uvicorn.workers.UvicornWorker Users installing headroom-ai[proxy] for production get uvicorn (already declared) but had to discover and install gunicorn manually. Adding it to [proxy] removes that friction. Investigation notes: - [code] only needs tree-sitter-language-pack (already declared). code_compressor.py has zero numpy imports. The kompress fallback inside code_compressor.py is guarded by ImportError and requires [ml]. - numpy is correctly declared in [relevance] (numpy>=1.24.0) and pulled transitively by sentence-transformers in [memory]. It is NOT needed under [code]. - tree-sitter is a transitive dep of tree-sitter-language-pack (requires tree-sitter>=0.25.2) so it does not need an explicit entry. * docs(changelog): add entry for gunicorn proxy dep fix style(tests): ruff format test_provider_proxy_routes.py (blank lines after docstrings) * fix(deps): move gunicorn to [proxy-prod] extra, add Windows guard - Remove gunicorn from [proxy] so dev, CI, and Windows users are not forced to install a Unix-only package that does nothing on Windows - Add new [proxy-prod] extra that includes [proxy] + gunicorn with a sys_platform != 'win32' environment marker - Production users: pip install 'headroom-ai[proxy,proxy-prod]' - Update CHANGELOG to reflect the new extra name * fix(devcontainer): bump uv floor to >=0.11.0 for lockfile compatibility uv 0.6.17 (previously pinned) cannot parse lockfiles generated by uv >= 0.11.x. The validate CI job (triggered by pyproject.toml changes) was failing with 'Failed to parse uv.lock'. Loosening the pin to >=0.11.0 picks up the matching format parser while keeping the Docker layer cacheable with a range rather than an exact pin. * fix(devcontainer): skip gitpython wheel filename check in uv sync gitpython 3.1.47 on PyPI has wheel gitpython-3.1.46-py3-none-any.whl (wrong filename). uv >=0.11.19 strict filename validation rejects this lockfile entry. UV_SKIP_WHEEL_FILENAME_CHECK=1 bypasses the check until the upstream lockfile is regenerated with a corrected entry. * fix(deps): correct gitpython version in uv.lock to match actual wheel gitpython 3.1.47 on PyPI was uploaded with sdist/wheel files named gitpython-3.1.46.*. The version field in uv.lock said 3.1.47 but all download URLs reference 3.1.46 files, causing uv >=0.11.19 to refuse to parse the lockfile with a version-mismatch error. Change the version field to 3.1.46 so the entry is internally consistent. Also revert the now-unnecessary UV_SKIP_WHEEL_FILENAME_CHECK workaround from post-create.sh. --------- Co-authored-by: Tejas Chopra <chopratejas@gmail.com> |
||
|
|
07581b9e80 | Fix: Upgrade litellm to 1.86.2 to remediate CVE-2026-42271 | ||
|
|
e325d1b866 |
fix(ci): pin public PyPI in pyproject.toml + scrub Netflix URLs from uv.lock
Devcontainer validate jobs were failing on PR #360 with: × Failed to fetch: https://pypi.netflix.net/packages/.../nvidia_nvshmem_cu12-3.4.5-...whl ├─▶ Request failed after 3 retries ╰─▶ operation timed out `pypi.netflix.net` is Netflix's internal PyPI mirror. It got into the lockfile because my local `~/.config/uv/uv.toml` had: index-url = "https://pypi.netflix.net/simple" Running `uv lock` from that machine baked Netflix-internal URLs into uv.lock for every package. Public CI runners (and any external contributor) can't resolve them. Two fixes: 1. Add `[[tool.uv.index]]` block to pyproject.toml pinning public PyPI as the project's default index. uv now ignores user-level config when resolving for this project, regardless of who runs `uv lock`. This prevents the same contamination from any developer in the future. 2. Regenerate uv.lock against public PyPI. All package URLs now point at `https://files.pythonhosted.org/...` and `https://pypi.org/simple/`. Zero references to `pypi.netflix.net` remain in the lockfile. Verified: `grep -c "pypi.netflix" uv.lock` returns 0. |
||
|
|
2a91cbb4b4 |
refactor: single-wheel maturin build backend (fixes #355)
Eliminates the dual-package architecture that was the root cause of #355. `pip install headroom-ai` now produces ONE wheel containing both the Python source (headroom/*.py) and the compiled Rust extension (headroom/_core.so). No more separate `headroom-core-py` package, no more chicken-and-egg with PyPI publication, no more wheelhouse / PIP_FIND_LINKS / composite-action plumbing in CI. This is the canonical pattern used by cryptography, polars, ruff, pydantic-core, and other Rust-as-core Python packages. Honors the "Rust as core engine" direction. ## What changed - pyproject.toml: `[build-system]` swapped from hatchling to maturin. `[tool.hatch.*]` deleted; `[tool.maturin]` added pointing at `crates/headroom-py/Cargo.toml` for the cdylib. `python-source = "."` picks up the root `headroom/` package directly (dashboard HTML templates and other non-Python files included automatically). - crates/headroom-py/pyproject.toml: deleted. The crate is no longer a separate published package; its Cargo.toml stays as the cdylib build target invoked via `[tool.maturin] manifest-path`. - crates/headroom-py/python/: deleted (placeholder layout for the old separate package). ## CI updates - ci.yml: `test` / `test-extras` / `test-agno` jobs simplified — Rust toolchain set up before `pip install -e .` (which now invokes maturin via build-system). Removed the "build wheel + symlink .so" dance. `build` job swapped from `python -m build` (hatch) to `maturin build` + `maturin sdist`. - release.yml: collapsed dual-package matrix into one. New `build-wheels` matrix produces cross-platform wheels for cp310/11/12/13 × {linux x86_64, linux aarch64, macos x86_64, macos aarch64}. New `collect-dist` aggregator merges artifacts. publish-pypi consumes the merged dist. - init-native-e2e.yml: dropped windows-latest from the matrix — upstream `esaxx-rs` (/MT) and `ort-sys` (/MD) link with conflicting MSVC C runtime libraries, so the Rust extension cannot build for win_amd64 today. Tracked as a follow-up; not a blocker for Linux+macOS. - headroom-e2e-setup: composite action now sets up Rust toolchain + Swatinem/rust-cache before `pip install -e .[proxy]`. - eval.yml, publish.yml, rust.yml: same pattern — rust toolchain before install. rust.yml's wheels job builds from root pyproject.toml (no more `-m crates/headroom-py/Cargo.toml`). - e2e/init/Dockerfile, e2e/wrap/Dockerfile: install rust + maturin in the build stage; copy `crates/` + workspace `Cargo.toml/lock` so the install can build the extension. Dropped `HEADROOM_REQUIRE_RUST_CORE=false` from wrap-e2e — the image now ships the full Rust core. - Dockerfile (main): simplified — no more Layer 2/3 dance with `headroom-core-py` install + symlink. Single `uv pip install` builds + installs everything. - .devcontainer/Dockerfile: rust toolchain + libssl-dev + maturin added so `uv sync` builds the extension inside the devcontainer. ## Lockfile + script - uv.lock: regenerated. No `headroom-core-py` entries remain. - scripts/build_rust_extension.sh: simplified from a symlink-into-tree workaround to a thin wrapper around `pip install -e .`. The maturin build-backend handles placement automatically. ## Local validation (all green on macOS aarch64) 1. Clean venv `pip install -e .` → `from headroom._core import …` works. 2. `maturin build --release` → 13.8 MB wheel, 336 files including `headroom/_core.cpython-311-darwin.so` (32 MB cdylib) and `headroom/dashboard/templates/dashboard.html`. 3. `pip install <wheel>` in fresh venv → import works. 4. Wheel contents verified via `unzip -l`. 5. `pytest tests/test_transforms/test_diff_compressor.py` — 29 passed. 6. `pytest tests/test_relevance.py` — 30 passed. 7. `cargo build --workspace` + `cargo test --workspace` — all green. 8. `make ci-precheck` — 176 Python tests + Rust + commitlint green. ## Migration notes Users on `pip install headroom-ai` get the Rust core automatically (linux + macos wheels). sdist installs require rust toolchain available locally — pip will build via maturin. Closes #355 Supersedes #357 (workarounds-based fix abandoned in favor of architectural fix) |
||
|
|
ce3b2f0b0b |
fix(ci): regenerate uv.lock against public PyPI (was Netflix-internal)
The validate × 3 devcontainer CI failures were NOT environmental —
they were caused by this branch.
Root cause: commit
|
||
|
|
967b0db439 |
fix: B1 — retire ICM, RollingWindow, scoring, relevance + dependents
Phase B step 1 of the live-zone-only realignment. Removes ~10K LOC of
"drop messages from history" machinery that became unreachable after
PR-A1 made `/v1/messages` a passthrough on the proxy. Live-zone-only
compression (PR-B2..B7) operates on content blocks within messages;
message-list mutation no longer happens in the pipeline.
Python deletes:
- headroom/transforms/intelligent_context.py (1077 LOC)
- headroom/transforms/rolling_window.py (395 LOC)
- headroom/transforms/progressive_summarizer.py (508 LOC)
- headroom/transforms/scoring.py (459 LOC)
- headroom/transforms/tool_crusher.py (338 LOC)
- 5 corresponding tests/test_transforms/* and tests/test_proxy_intelligent_context.py
Rust deletes:
- crates/headroom-core/src/context/* (manager, config, workspace,
candidate, ccr_drop, strategy/, mod) + safety.rs replaced
- crates/headroom-core/src/scoring/* (mod, score, scorer, traits, weights)
- MessageScorerComparator from crates/headroom-parity (PR #338/#343
becomes deletable; sunk cost stays sunk)
- 13 message_scorer fixtures + record_message_scorer.py
Rust adds (move + rewrite):
- crates/headroom-core/src/transforms/safety.rs — `tool_pair_indices`
preserves the OpenAI/Anthropic tool_use ↔ tool_result pairing rule
the live-zone dispatcher (PR-B2) needs. No IcmConfig dependency.
Surface refactors:
- HeadroomConfig: drop `tool_crusher`, `rolling_window`,
`intelligent_context` fields; hoist `output_buffer_tokens` to top
level (used by client.py).
- ProxyConfig: drop `intelligent_context*` fields.
- `headroom wrap` proxy server: retire IntelligentContextManager
and RollingWindow imports + branch; pipeline is CacheAligner →
ContentRouter (smart_routing) or CacheAligner → SmartCrusher
(legacy).
- CLI: drop `--no-intelligent-context`, `--no-intelligent-scoring`,
`--no-compress-first` flags.
- LangChain memory integration: rename `_apply_rolling_window` →
`_apply_compression`, drop RollingWindowConfig dep. Threshold is
now advisory — B6 will rework the contract.
- TransformPipeline.create_pipeline now takes only cache_aligner_config.
- headroom/__init__.py + headroom/transforms/__init__.py: strip
exports of deleted symbols.
Bug fixes uncovered by full pytest sweep:
- providers/copilot/wrap.py: `environ or os.environ` collapsed
empty-dict to falsy → callers passing `environ={}` accidentally
pulled from os.environ. Use `environ if environ is not None else
os.environ`.
Test correctness fixes:
- _DummyAnthropicHandler._retry_request gains **_kwargs to match
the real handler signature post-A8.
- test_ws_http_fallback extracts JSON from `content=` (post-A3
byte-faithful) rather than the obsolete `json=` kwarg.
- test_ccr_response_handler_extra fixture joins SSE events with
`\n\n` per spec (post-A8 byte-buffer parser requirement).
- test_proxy_responses_phase_preservation: capture via direct
handler attached to the named logger, so the assertion is
order-independent (proxy `_setup_file_logging` flips
`headroom.propagate=False` once any earlier test triggers it).
- conftest.py autouse fixture resets `headroom.propagate=True`
before each test as a defensive measure for the same pollution.
- test_wrap_copilot_translated_backend_still_requires_byok:
monkeypatch.delenv every provider key so the BYOK error
actually fires.
- test_native_installers: skip when system bash < 4.3 (macOS ships 3.2).
- TestGeminiEmbedContent / TestGeminiBatchEmbedContents:
pytest.mark.skip — proxy currently has no :embedContent route;
feature gap, not regression.
Acceptance:
- cargo build --workspace + cargo clippy + cargo fmt --check: green.
- cargo test --workspace --exclude headroom-py: 777 passed.
- pytest: 4892 passed, 240 skipped, 0 failed.
- git grep returns only intentional comments referencing the deletion.
Per-PR-B1 plan: REALIGNMENT/04-phase-B-live-zone.md.
|
||
|
|
e25f5515ab |
chore(deps): bump nltk in the uv group across 1 directory
Bumps the uv group with 1 update in the / directory: [nltk](https://github.com/nltk/nltk). Updates `nltk` from 3.9.2 to 3.9.4 - [Changelog](https://github.com/nltk/nltk/blob/develop/ChangeLog) - [Commits](https://github.com/nltk/nltk/compare/3.9.2...3.9.4) --- updated-dependencies: - dependency-name: nltk dependency-version: 3.9.4 dependency-type: indirect dependency-group: uv ... Signed-off-by: dependabot[bot] <support@github.com> |
||
|
|
b71b659e1b |
fix(ci): restore repro harness test in dev installs
Add websockets to the dev extra so the repro harness smoke test can import its websocket client dependency in the CI test matrix. Also apply ruff formatting to the files the formatter check was rejecting so the 3.12 lint job passes. |
||
|
|
6bc44b3e00 |
chore(deps): refresh uv.lock to schema revision 3
Upgrade of the local uv CLI rewrote the lock file with `revision = 3` and renamed the metadata key `upload_time` -> `upload-time`. No actual dependency version changes. |
||
|
|
a1beb08d53 |
feat: add reproducible devcontainers
Add a default devcontainer and a compose-backed memory-stack profile, validate them in CI, and document the contributor workflow. Also lock the memory-stack dependencies, pin related container tooling, and sync the latest healthcheck shutdown fix for stubbed memory handlers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> |
||
|
|
7d02829f02 | Harden Anthropic prefix cache stability across proxy and batch paths | ||
|
|
40369762dd |
Add Cloud mode to ASGI middleware and LiteLLM callback
Both CompressionMiddleware and HeadroomCallback now support a cloud mode (api_key="hdr_xxx") that calls Headroom Cloud API for managed compression with org-scoped CCR, TOIN learning, and analytics. Falls back to HEADROOM_API_KEY env var. Local mode (default) is unchanged. Also adds x-headroom-tokens-before/after response headers and updates uv.lock with mcp extra and version bump to 0.3.3. |
||
|
|
84ad47eba9 |
Add SQLiteVectorIndex using sqlite-vec for bounded vector search
A SQLite-based alternative to HNSWVectorIndex offering: - True CRUD operations (real deletes, not marks) - Bounded memory via SQLite page cache (default 8MB) - Persistent storage by default - Cosine similarity search - Native integration potential with FTS5 for hybrid search New files: - headroom/memory/adapters/sqlite_vector.py: Implementation - tests/test_sqlite_vector_index.py: 16 comprehensive tests Dependencies: - sqlite-vec added as optional dependency (pip install sqlite-vec) - Requires Python built with loadable extension support Key advantages over HNSWVectorIndex: - No SIGILL crash risk (pure C, no AVX requirement) - True deletes (not just marks, space actually reclaimed) - Simpler persistence (SQLite handles it automatically) - Consistent with SQLiteGraphStore (same technology stack) |
||
|
|
e86d9a396e |
feat(compression): add exclude_tools to bypass compression for specific tools
Add ability to exclude specific tools from compression, useful for CLI tools like Claude Code where file/search output should be passed through unmodified. Changes: - Add DEFAULT_EXCLUDE_TOOLS constant with Read, Grep, Glob, Bash, WebFetch, WebSearch - Add exclude_tools field to SmartCrusherConfig and ContentRouterConfig - Add _build_tool_name_map() to ContentRouter for tool_call_id -> name mapping - Skip compression for tool_result blocks from excluded tools - Support both Anthropic (tool_use/tool_result) and OpenAI (tool_calls/tool) formats This prevents Headroom from compressing output from tools where the user expects to see the full, unmodified content (e.g., file reads, search results). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
d1a28322cc |
Add HTMLExtractor for web content extraction with OSS benchmarks
HTMLExtractor uses trafilatura to extract main content from HTML pages, removing scripts, styles, navigation, and ads. This achieves 94.9% compression while preserving 98.2% recall on the Scrapinghub benchmark. Key features: - Automatic HTML detection in content router - Configurable output format (markdown or text) - Metadata extraction (title, author, date, description) - Batch extraction support Evaluation framework: - OSS benchmark integration (Scrapinghub Article Extraction Benchmark) - LLM-as-judge evaluation for QA accuracy preservation - F1 score: 0.919 on 181-sample benchmark (baseline: 0.958) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
9825d993ba |
feat: add streaming memory tool support with credential error handling
- Implement streaming memory tool detection and execution for Anthropic API - Buffer SSE response to detect tool_use blocks, execute tools, and stream continuation - Add helpful error detection and messaging for subscription credential restrictions - Add startup note when memory tools enabled warning about API key requirement - Move hnswlib to core dependencies for memory system - Update CLI to show memory tool/context status on startup |
||
|
|
74872b203b |
fix: resolve mypy type errors across codebase
- Add type annotations for variables with inferred Any types - Add close() method to MemoryBackend protocol - Fix union type assignments in eval runners - Add explicit casts for return type mismatches - Fix None callable issues with assertions - Regenerate uv.lock to fix corrupted pillow dependency |
||
|
|
da74341858 |
Add hierarchical memory system with graph + vector storage
Implement comprehensive memory system supporting: - Local backend (SQLite + FTS5 + HNSW) for zero-dependency operation - Mem0 backends (Neo4j + Qdrant) for production graph memory - DirectMem0Adapter for optimized pre-extracted data (bypasses LLM) - Memory extraction with facts, entities, and relationships - Proxy integration with --memory flag for automatic memory injection Key components: - headroom/memory/backends/: LocalBackend, Mem0Backend, DirectMem0Adapter - headroom/memory/system.py: MemorySystem with tool-based interface - headroom/memory/extraction.py: Entity and relationship extraction - headroom/proxy/memory_handler.py: Proxy integration layer - headroom/prediction/feature_extractor.py: Content analysis features Testing: - 217 new memory system tests covering all backends - LoCoMo evaluation framework for memory quality assessment - Integration tests for proxy memory functionality Also removes deprecated example files in favor of focused test coverage. |
||
|
|
2fd9552102 |
Add image token compression with trained ML router
Introduces automatic image compression for LLM requests, reducing token usage by 40-90% while maintaining answer accuracy. Key features: - Trained MiniLM classifier (93.7% accuracy) hosted on HuggingFace - SigLIP-based image analysis for content-aware routing - Provider-specific compression: - OpenAI: detail="low" parameter - Anthropic: PIL resize to 512px - Google: PIL resize to 768px (tile-optimized) - Four compression techniques: full_low, preserve, crop, transcode - Integration in both Headroom proxy and SDK (ContentRouter) New files: - headroom/image/ module with ImageCompressor API - docs/image-compression.md user documentation - tests/test_image_compressor.py (51 tests) Model: chopratejas/technique-router on HuggingFace (~128MB) |
||
|
|
c850ccc3b2 |
Replace legacy memory system with HierarchicalMemory
Major refactor of the memory module: - Add hierarchical scoping (user → session → agent → turn) - Add temporal versioning with supersession support - Add pluggable adapters (SQLite store, HNSW vectors, FTS5 text search) - Add protocol interfaces (ports) for all memory components - Update LRUMemoryCache to implement async MemoryCache protocol - Update wrapper.py to use HierarchicalMemory backend - Preserve with_memory() one-liner API with zero-latency inline extraction New files: - adapters/: sqlite.py, hnsw.py, fts5.py, cache.py, embedders.py - core.py: HierarchicalMemory orchestrator - models.py: Memory, MemoryCategory, ScopeLevel - ports.py: Protocol interfaces (MemoryStore, VectorIndex, etc.) - config.py: MemoryConfig with backend selection - factory.py: Component creation from config Removed legacy files: - store.py, fast_store.py, extractor.py, worker.py, fast_wrapper.py Breaking change: Removes legacy memory API (pre-0.3.0) |
||
|
|
92e4a24ea7 |
Add comprehensive evaluation framework for compression accuracy
- Add headroom.evals module with 12+ dataset loaders (HotpotQA, SQuAD, Natural Questions, TriviaQA, MS MARCO, LongBench, NarrativeQA, BFCL, ToolBench, CodeSearchNet, HumanEval, built-in tool outputs) - Add before/after evaluation runner that compares LLM responses with original vs compressed context - Add metrics: F1 score, semantic similarity, exact match, ground truth - Add CLI: python -m headroom.evals quick|benchmark|list|report - Add [evals] extra to pyproject.toml for pip install headroom-ai[evals] Fix ContentRouter to use LLMLingua for plain text compression: - Route TEXT strategy through LLMLingua instead of heuristic TextCompressor - Adjust LLMLingua compression rates for better accuracy (0.5 vs 0.25) - HotpotQA now achieves 95% accuracy with 44% compression Update documentation with evaluation framework section Fix test isolation in test_toin.py (TOIN singleton persistence) |
||
|
|
4b04a45736 |
Add pre-commit hooks for ruff linting and formatting
- Add .pre-commit-config.yaml with ruff and ruff-format hooks - Add pre-commit to dev dependencies - Ignore UP038 rule (tuple syntax in isinstance is clearer) Run `uv run pre-commit install` to enable hooks locally. |
||
|
|
2ce26438a0 |
Integrate DynamicContentDetector into CacheAligner (Phase 1)
- Add DynamicContentDetector integration for comprehensive dynamic content detection (20+ patterns vs previous 4 date patterns) - New detection: UUIDs, API keys, JWT tokens, Unix timestamps, request/trace IDs, hex hashes (MD5/SHA1/SHA256), version numbers, high-entropy strings - Add CacheAlignerConfig options: use_dynamic_detector, detection_tiers, extra_dynamic_labels, entropy_threshold - Maintain backward compatibility with legacy date-only mode - Add 25 new comprehensive tests for Phase 1 functionality - Fix code compressor fallback test to properly mock LLMLingua availability Expected cache hit improvement: 30-50% by extracting more dynamic content |
||
|
|
67c927f857 |
Fix HeadroomAgnoModel to extend agno.models.base.Model and add real integration tests
- Fix HeadroomAgnoModel to properly extend agno.models.base.Model as a dataclass - Implement required abstract methods (invoke, ainvoke, invoke_stream, ainvoke_stream) - Add type: ignore comments for method signature overrides - Fix mypy errors in telemetry/models.py and telemetry/toin.py - Add real Ollama integration tests for both Agno and LangChain (no API keys needed) - Add ollama and langchain-ollama to dev dependencies for local testing - Update existing tests to use new HeadroomAgnoModel API |
||
|
|
77248cd1a3 |
Enhance /stats endpoint and add comprehensive benchmarks
- Add detailed breakdowns by provider and model to /stats - Include compression, telemetry, and feedback loop statistics - Add latency.average_ms metric - Add real-world agent benchmark with MCP tool patterns - Add worst-case and adversarial benchmarks for edge cases - Bump version to 0.2.12 |
||
|
|
dd832fee0c |
Add TOIN field-level learning and comprehensive integration tests
Features: - Add field-level learning to TOIN from retrieved items - CompressionStore now passes retrieved_items to TOIN for learning - Add FieldSemantics class for tracking field usage patterns Test improvements: - Add TestCacheOptimizerInvocation to verify optimizer is actually invoked - Add TestSemanticCacheIntegration to verify cache hit returns without API call - Add TestSessionStatsTracking to verify session stats are tracked - Add TestEndToEndTOINIntegration for full CCR cycle with TOIN - Add critical field_semantics assertions to catch feedback loop bugs Fixes: - Remove unused imports and variables (ruff linting) Bump version to 0.2.11 |
||
|
|
7a34030b0d |
Fix mypy type errors in LiteLLM and OpenAI providers
- Add type: ignore[assignment] comments for optional litellm imports - Add None checks before accessing optional module functions - Handle nullable max_input_tokens and max_output_tokens values Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
f1e7b628c4 |
Add Agno agent framework integration
- HeadroomAgnoModel: Drop-in wrapper for any Agno model with automatic context optimization - HeadroomPreHook/HeadroomPostHook: Agent-level hooks for tracking optimization metrics across tool calls - Provider detection for Agno models (OpenAI, Anthropic, Google, etc.) - Full test coverage for model wrapper and hooks |
||
|
|
09973b614d |
Use LiteLLM for model pricing instead of hardcoded values
- Add litellm as a core dependency for accessing its community-maintained model pricing database (2,425+ models across all major providers) - Create headroom/pricing/litellm_pricing.py with simple wrapper functions - Update ModelRegistry.estimate_cost() to fetch pricing from LiteLLM - Remove hardcoded pricing fields from ModelInfo dataclass - Update tests to reflect new pricing source |
||
|
|
31aa72c885 |
Add universal compression module with ML-based content detection
- Add headroom.compression module with UniversalCompressor - ML-based content detection using Magika (JSON, code, logs, text) - Structure-preserving compression via handler protocol - JSON handler: preserves keys, brackets, high-entropy values (UUIDs) - Code handler: preserves imports, signatures, types (tree-sitter AST) - Entropy-based preservation for identifiers and hashes - CCR integration for reversible compression - Comprehensive test suite with LLM eval tests - Add docs/compression.md with full API documentation |
||
|
|
9c9bb30ded |
Add persistent memory system with zero-latency inline extraction
Features: - with_fast_memory(): Zero-latency inline extraction (Letta-style) - Memory extracted as part of LLM response, no extra API calls - Semantic retrieval with local embeddings (sub-50ms) - with_memory(): Background extraction for non-blocking memory - SQLite + FTS5 storage with vector similarity search - Multi-user isolation by user_id Memory enables temporal compression - extract key facts instead of carrying full conversation history (4000 tokens → 50 tokens). Includes: - Comprehensive test suite (71 new tests) - Documentation (docs/memory.md) - Benchmark examples comparing approaches - E2E test with LLM-as-judge evaluation |
||
|
|
bb041047c8 |
Add seamless LangChain integration
- Add HeadroomChatModel wrapper with auto provider detection (OpenAI, Anthropic, Google) - Add HeadroomChatMessageHistory for automatic conversation compression - Add HeadroomDocumentCompressor for retriever integration - Add wrap_tools_with_headroom() for agent tool output compression - Add async support (ainvoke, astream) - Add LangSmith integration for observability - Restructure integrations package into nested langchain/ and mcp/ subpackages - Fix Pydantic v2 deprecation warning - Add comprehensive docs/langchain.md guide with real-world examples - Update README with LangChain quickstart and framework integrations Bump version to 0.2.3 |
||
|
|
e4a41faa33 |
Fix all ruff lint and format errors for CI
- Fix E402: Move module-level imports to top of file - Fix F401: Add noqa for availability check imports - Fix F402: Rename loop variables shadowing imports - Fix E722: Replace bare except with except Exception - Fix B904: Add exception chaining (from e) - Fix F811: Remove duplicate imports - Fix B027: Add noqa for empty close() method - Fix E741: Rename ambiguous variable l -> label - Fix I001: Import sorting issues - Apply ruff format to all 106 files All 902 tests pass. |