Skip to main content

LLM proxy that analyses token usage in context windows

Project description

logo

ContextSpy is a local proxy that sits between your coding agent and the LLM API, recording every request and breaking down exactly how your context window is being used.

Modern AI coding agents (GitHub Copilot, Claude Code, opencode, Cursor) pack a lot into each LLM request: system prompts, tool definitions, tool results, file contents, conversation history. It's often unclear why a session is slow, expensive, or hitting the context limit. ContextSpy makes the invisible visible — you see a live breakdown of every token category for every request, across sessions, over time.

Features

  • Two proxy modes — forward proxy for cloud APIs (OpenAI, Anthropic, Copilot), reverse proxy for local LLM servers (Ollama, llama.cpp, vLLM)
  • Context breakdown — input tokens split into 8 categories: system prompt, tool definitions, tool results, file contents, conversation history, current user message, assistant prefill, uncategorised
  • Live dashboard — real-time charts and per-request detail with a visual block map of the context window
  • Session tracking — name and group requests by task to compare usage across runs
  • SQLite storage — all data stored locally in ~/.contextspy/; no data leaves your machine
  • Agent detection — Copilot, Claude Desktop/Code, opencode, Cursor, and generic clients

Quick start

# Install
pip install contextspy
# or: uv tool install contextspy
# or: brew install rimantas/contextspy/contextspy

# Install the CA certificate (cloud mode only, one-time)
contextspy start --no-browser   # generates cert, then Ctrl+C
contextspy install-cert

# Start
contextspy start

Then configure your agent to route through http://127.0.0.1:8888 and open http://127.0.0.1:5173 in your browser.

Documentation

License

Apache 2.0 — see LICENSE and NOTICE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextspy-0.1.6.tar.gz (785.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextspy-0.1.6-py3-none-any.whl (793.2 kB view details)

Uploaded Python 3

File details

Details for the file contextspy-0.1.6.tar.gz.

File metadata

  • Download URL: contextspy-0.1.6.tar.gz
  • Upload date:
  • Size: 785.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextspy-0.1.6.tar.gz
Algorithm Hash digest
SHA256 820526d465a8f06378572397ede6bbf444c41941c4cc9a27dbece0b848301b62
MD5 68e4e41dbfe47b176511fe5d16152160
BLAKE2b-256 4679bbc93dc24e1c77acc4c411130d74e8d70e09782009f388033479d5ece9d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextspy-0.1.6.tar.gz:

Publisher: publish.yml on RimantasZ/contextspy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextspy-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: contextspy-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 793.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextspy-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 28071b69b7038f44142155973a2715a0b2845edb45cd41c1729b684d5e1c0f73
MD5 6ca74574daf942edeadeec3a2d9eaf9d
BLAKE2b-256 d4bfe65417e693bb1f2bc3e78a5af20e3d515607824236bafa98063ab715f148

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextspy-0.1.6-py3-none-any.whl:

Publisher: publish.yml on RimantasZ/contextspy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page