◉ Pulse
co-l avatar
#12 today ▲ 6

co-l/cache-hunter

TypeScript AI

LLM proxy specialized in analyzing harness traffic to catch cache invalidation.

Created Jul 18, 2026
Stars
30
Today
+12
Forks
1
Quality
85/100
Momentum
21

README

Fetched from GitHub on Oct 30, 2026, 10:16 PM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to co-l/cache-hunter and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

Cache Hunter

Transparent proxy for OpenAI-API compatible endpoints with SQLite logging to debug prefix caching behavior.

Quick Start

# Install
npm install

# Start proxy
npm start

# Point Harness to the proxy
export OPENAI_BASE_URL=http://localhost:8787

# Run your Harness tool as normal — all traffic gets logged

Architecture

Harness → Proxy (localhost:8787) → OpenAI-API endpoint (127.0.0.1:8000)
                                   ↓
                             cache-hunter.db

Configuration

Set via environment variables (or persisted from the UI):

  • TARGET_HOST (default: 127.0.0.1)
  • TARGET_PORT (default: 8000)
  • PROXY_PORT (default: 8787)
  • WEB_PORT (default: 4000)

Database Schema

requests

  • id - UUID for correlation
  • timestamp - Unix ms
  • method - HTTP method
  • path - Request path
  • headers - JSON string
  • body - Full request body (JSON string)
  • cache_salt - Extracted if present in body
  • client_ip - Client IP address

responses

  • request_id - FK to requests.id
  • timestamp - Unix ms
  • status_code - HTTP status
  • headers - JSON string
  • body - Full response body (JSON string)
  • duration_ms - Total request duration
  • prompt_tokens - From usage.prompt_tokens
  • completion_tokens - From usage.completion_tokens
  • total_tokens - From usage.total_tokens

Query Examples

Basic queries

node query-examples.js

Cache analysis

node analyze-cache.js

Advanced pattern detection

npm run analyze

Context coherence verification

npm run demo
npm run tree

This provides:

  • Latency trends over time
  • Prefix hash analysis
  • Conversational chain detection
  • Cache invalidation indicators
  • CSV export for visualization

Manual queries

sqlite3 cache-hunter.db

-- Recent requests
SELECT datetime(timestamp/1000, 'unixepoch', 'localtime') as time,
       path, duration_ms, prompt_tokens
FROM responses
ORDER BY timestamp DESC
LIMIT 10;

-- Find requests with similar prefixes
SELECT r1.id, r2.id, substr(r1.body, 1, 100) as prefix
FROM requests r1
JOIN requests r2 ON r2.timestamp > r1.timestamp
WHERE r1.path = '/v1/chat/completions'
  AND r2.path = '/v1/chat/completions'
  AND r2.body LIKE r1.body || '%'
ORDER BY r2.timestamp DESC
LIMIT 5;

-- Latency per token (high values = potential cache misses)
SELECT datetime(timestamp/1000, 'unixepoch', 'localtime') as time,
       prompt_tokens,
       duration_ms,
       round(duration_ms * 1.0 / prompt_tokens, 2) as ms_per_token
FROM responses
WHERE prompt_tokens > 50
ORDER BY ms_per_token DESC;

Debugging Cache Behavior

vLLM's prefix caching is transparent - it doesn't expose cache hit/miss signals. To detect caching behavior:

1. Latency Analysis

Cache hits should show lower ms/token for requests with similar prefixes:

SELECT prompt_tokens, duration_ms,
       round(duration_ms * 1.0 / prompt_tokens, 2) as ms_per_token
FROM responses
WHERE prompt_tokens > 100
ORDER BY ms_per_token;

2. Prefix Overlap Detection

Find requests that share prefixes:

SELECT r1.body as req1, r2.body as req2
FROM requests r1, requests r2
WHERE r2.body LIKE r1.body || '%'
  AND length(r1.body) > 100
  AND length(r1.body) < length(r2.body);

3. Timeline Analysis

Look for latency patterns over time:

SELECT datetime(timestamp/1000, 'unixepoch', 'localtime') as time,
       duration_ms, prompt_tokens
FROM responses
ORDER BY timestamp;

Features

  • ✅ 100% Transparent: Forwards all requests as-is
  • ✅ SSE Streaming: Supports /v1/chat/completions streaming
  • ✅ Async Logging: Non-blocking SQLite writes
  • ✅ Correlation IDs: x-proxy-request-id header for tracing
  • ✅ Token Metrics: Logs prompt/completion/total tokens
  • ✅ Timing Data: Precise duration measurements
  • ✅ Context Verification: Hash-based tree to verify conversation coherence

Limitations

  • No cache signals: vLLM doesn't expose cache hit/miss
  • Network latency: Duration includes localhost→vLLM network time
  • Memory queue: In-memory write queue (flushed every 100ms or 50 requests)

Cleanup

# Remove all logs
rm cache-hunter.db

How It Works

  1. Proxy intercepts all HTTP requests to the upstream endpoint
  2. Captures request body, headers, timestamp
  3. Forwards transparently to the target (127.0.0.1:8000)
  4. Captures response body, headers, duration, token counts
  5. Logs to SQLite asynchronously (batched writes)
  6. Adds correlation ID header (x-proxy-request-id)

Development

# Watch mode
npm run dev

# Direct TypeScript execution
npx tsx src/index.ts
Rendered by GitHub from the repository’s README. Scroll to read the full file.
First trending

Jul 18, 2026

first spotted on the list

Best rank

#12

highest position reached

Appearances

2

times on the trending list

Quality score

85

out of 100

Momentum

21

trend strength indicator

Star velocity

0.29

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot
1520253035co-l/cache-hunter · Jul 18, 7 PM UTC: 18 starsco-l/cache-hunter · Jul 19, 3 AM UTC: 30 stars7 PM11 PM3 AM

Rank history

position on trending · lower is better
#1#12#13#14#15#16#17Jul 18, 7 PM UTC: rank #17Jul 19, 3 AM UTC: rank #127 PM11 PM3 AM

3D card for your website

Live HTML card with a glass surface and pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/co-l/cache-hunter" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="co-l/cache-hunter — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

co-l/cache-hunter stars badge
Markdown
[![co-l/cache-hunter](https://www.notionpulse.cc/api/badge/co-l/cache-hunter.svg)](https://www.notionpulse.cc/repo/co-l/cache-hunter)
HTML
<a href="https://www.notionpulse.cc/repo/co-l/cache-hunter"><img src="https://www.notionpulse.cc/api/badge/co-l/cache-hunter.svg" alt="co-l/cache-hunter stars badge" /></a>

Repository of the Day

#12 Repository of the Day

Repository of the Week

#12 Repository of the Week

Repository of the Month

#12 Repository of the Month