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.5.tar.gz (782.0 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.5-py3-none-any.whl (792.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contextspy-0.1.5.tar.gz
  • Upload date:
  • Size: 782.0 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.5.tar.gz
Algorithm Hash digest
SHA256 122a969769839dece1cf9c4c76463f6a24ac744a91a3384f5dc8da81426f0ef1
MD5 98f7ad1c729109dc5ddaa6f9fa66a4b6
BLAKE2b-256 de7c87de0dce9674aab1789493f8caee725ec36a7eed52e07f31834e616b9d8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextspy-0.1.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: contextspy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 792.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 55428dd7fdc1af3ad374113e827eef5880ff3ea2ecfb91977e38c6f236af322c
MD5 7c9eee398b7a9376e56a28ce9760f62e
BLAKE2b-256 ed44bcae5ab13f5370d186e69bc7950438b50ea7c98d1816c911bc65d9068d6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextspy-0.1.5-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