Commit 814ffa3
fix(proxy): wire --compression-max-workers / HEADROOM_COMPRESSION_MAX_WORKERS (headroomlabs-ai#1632)
## Description
`ProxyConfig.compression_max_workers` is documented as settable via
`--compression-max-workers` / `HEADROOM_COMPRESSION_MAX_WORKERS` and is
consumed by `HeadroomProxy.__init__` to bound the dedicated compression
threadpool. But the proxy CLI never defined the option and never passed
the value into `ProxyConfig`, so the field was permanently `None` and
always resolved to the `min(32, (cpu_count or 1) * 4)` default. Neither
the flag nor the env var had any effect.
This matters under concurrent sessions: the compression pool runs
CPU-bound Kompress work that releases the GIL, so `cpu*4` oversubscribes
cores and there was no way to cap it despite the docs promising one.
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)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)
## Changes Made
- Added the `--compression-max-workers` click option (with
`envvar="HEADROOM_COMPRESSION_MAX_WORKERS"`) to the `proxy` command,
mirroring the existing `--anthropic-pre-upstream-concurrency` wiring.
- Added the `compression_max_workers` parameter to the `proxy()`
signature and passed it into the `ProxyConfig(...)` construction.
- No change to `HeadroomProxy` — it already reads
`config.compression_max_workers` and clamps `< 1` to 1.
## 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
$ pytest tests/test_cli_proxy_improvements.py::TestCompressionMaxWorkers -q
3 passed in 1.50s
$ pytest tests/test_cli_proxy_improvements.py -q
48 passed in 5.04s
$ ruff check headroom/cli/proxy.py tests/test_cli_proxy_improvements.py
All checks passed!
$ mypy headroom/cli/proxy.py
Success: no issues found in 1 source file
```
## Real Behavior Proof
- Environment: macOS, Python 3.10.18, branch off upstream/main @ 0.28.0
- Exact command / steps: new tests assert the value reaches
`ProxyConfig` via both `--compression-max-workers 3` (flag) and
`HEADROOM_COMPRESSION_MAX_WORKERS=5` (env), and that it stays `None`
when unset.
- Observed result: flag -> `config.compression_max_workers == 3`; env ->
`== 5`; unset -> `is None`.
- Not tested: end-to-end proxy run under real concurrent load (the
pool-sizing effect itself is already covered by existing
`test_proxy_compression_executor.py`).
## 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
- [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
- [ ] I have updated the CHANGELOG.md if applicable
## Additional Notes
CHANGELOG left untouched: this makes existing documented behavior
actually work rather than adding new surface. N/A: manual testing
(covered by unit tests + existing executor tests).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>1 parent 4bf7f92 commit 814ffa3
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
420 | 432 | | |
421 | 433 | | |
422 | 434 | | |
| |||
843 | 855 | | |
844 | 856 | | |
845 | 857 | | |
| 858 | + | |
846 | 859 | | |
847 | 860 | | |
848 | 861 | | |
| |||
1167 | 1180 | | |
1168 | 1181 | | |
1169 | 1182 | | |
| 1183 | + | |
1170 | 1184 | | |
1171 | 1185 | | |
1172 | 1186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
0 commit comments