Skip to content

Windows: _core.detect_content_type hangs on headroom-ai 0.24.0 / Python 3.13, breaking MCP compression #845

Description

@laiyangli001

Summary

headroom._core.detect_content_type() hangs on Windows with headroom-ai 0.24.0 and Python 3.13. This makes headroom_compress unusable for any content large enough to enter the real compression path.

This appears related to #713 / #575, but I am filing a new issue because this is still reproducible on the current 0.24.0 Windows wheel and a newer Python 3.13 environment.

Environment

  • OS: Windows 10 10.0.19045
  • Python: 3.13.13 CPython win_amd64
  • headroom-ai: 0.24.0
  • Wheel: headroom_ai-0.24.0-cp313-cp313-win_amd64.whl
  • Shell: PowerShell

Minimal Reproduction

python -c "from headroom._core import detect_content_type; print(detect_content_type('short headroom mcp smoke test'))"

Actual Result

The process hangs. In my test it did not return within 60 seconds.

This is not caused by large input. The input above is a short plain-text string.

Expected Result

detect_content_type() should return quickly, for example as plain text.

Related Checks

The Rust extension itself imports and other exported functions return immediately:

python -c "from headroom._core import hello; import time; t=time.perf_counter(); print(hello(), round(time.perf_counter()-t,3))"

Output:

headroom-core 0.0
python -c "from headroom._core import is_json_array_of_dicts; import time,json; content=json.dumps([{'a':1}]); t=time.perf_counter(); print(is_json_array_of_dicts(content), round(time.perf_counter()-t,3))"

Output:

True 0.0

The pure Python fallback detector returns immediately:

python -c "from headroom.transforms.content_detector import detect_content_type; import time; content='short headroom mcp smoke test'; t=time.perf_counter(); r=detect_content_type(content); print(r, round(time.perf_counter()-t,3))"

Output:

DetectionResult(content_type=<ContentType.PLAIN_TEXT: 'text'>, confidence=0.5, metadata={}) 0.0

Impact

headroom_compress through MCP only works for very small content because it exits via router:noop.

For larger content:

  1. MCP headroom_compress wraps the content as a tool message.
  2. headroom.compress.compress() enters ContentRouter.
  3. ContentRouter._detect_content() calls headroom._core.detect_content_type().
  4. The call hangs.
  5. MCP eventually times out after 120 seconds.

headroom perf also showed proxy optimization overhead around 30 seconds per request with 0 tokens saved before I stopped using proxy mode.

Request

Please either:

  1. Fix the Windows deadlock/hang in _core.detect_content_type(), or
  2. Provide a supported opt-out to force the Python detector, for example an environment variable such as HEADROOM_DETECT_BACKEND=python / regex.

Without such a fallback, Headroom MCP on Windows cannot reliably compress large tool outputs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    LowMinor bugs and issues that do not prevent usability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions