Skip to content

Expose Claude Code context-scaling on /api/status (#163)#953

Open
seikixtc wants to merge 1 commit intojundot:mainfrom
seikixtc:163-status-claude-code-fields
Open

Expose Claude Code context-scaling on /api/status (#163)#953
seikixtc wants to merge 1 commit intojundot:mainfrom
seikixtc:163-status-claude-code-fields

Conversation

@seikixtc
Copy link
Copy Markdown

Summary

Closes #163.

The issue asked for an API endpoint that statuslines (Claude Code, custom prompts) can poll to render oMLX-specific stats — context limit, usage, cache efficiency. oMLX already ships a GET /api/status endpoint that covers most of this, but it's missing the Claude Code context-scaling fields and isn't documented in the README, so users don't know it exists.

This PR closes the gap with a minimal change:

  1. Surfaces claude_code_context_scaling_enabled and claude_code_target_context_size on /api/status, matching the flat naming already used by the admin /api/stats response.
  2. Documents /api/status in the README under "API Compatibility", with a curl example and a representative response payload, so statusline integrations can discover it.

No new endpoint, no new auth path, no schema break.

Files changed

Area File
Server omlx/server.py (/api/status response)
Tests tests/test_status_endpoint.py (two new test cases)
Docs README.md (new "Status API" subsection)

Test plan

  • pytest tests/test_status_endpoint.py -v — all existing cases plus two new ones:
    • test_claude_code_fields_default_when_no_settings — verifies safe defaults (False, 200000) when global_settings is None.
    • test_claude_code_fields_reflect_settings — verifies configured values flow through (True, 131072).
  • Manual:
    omlx serve --model-dir ~/models &
    curl -s http://localhost:8000/api/status | jq .claude_code_context_scaling_enabled
    

Sample response

{
  "status": "ok",
  "version": "0.3.8",
  "uptime_seconds": 12834.2,
  "default_model": "Qwen3-Coder-Next-8bit",
  "loaded_models": ["Qwen3-Coder-Next-8bit"],
  "cache_efficiency": 87.5,
  "claude_code_context_scaling_enabled": true,
  "claude_code_target_context_size": 200000,
  "...": "..."
}

Notes for review

  • I went with flat field names (claude_code_context_scaling_enabled) rather than a nested claude_code: {...} block to stay consistent with /api/stats. Happy to switch to nested if you'd rather have a cleaner schema for external consumers — easy to flip.
  • The README example response shows cache_efficiency and the other already-exposed fields so a reader can see the full statusline payload in one place. If you'd prefer a minimal example that only highlights the new fields, let me know.
  • No version bump — assuming this rides whatever release goes out next.

Adds claude_code_context_scaling_enabled and claude_code_target_context_size to the existing /api/status endpoint, matching the flat naming convention used by the admin /api/stats response. Documents /api/status in the README so statusline integrations can discover it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add api to enable statusline integration

1 participant