Skip to content

feat: Cascade reuse optimization for single-user setups & HTTPS proxy#181

Open
Fermiz wants to merge 1 commit into
dwgx:masterfrom
Fermiz:feat/https-proxy-and-cascade-reuse
Open

feat: Cascade reuse optimization for single-user setups & HTTPS proxy#181
Fermiz wants to merge 1 commit into
dwgx:masterfrom
Fermiz:feat/https-proxy-and-cascade-reuse

Conversation

@Fermiz
Copy link
Copy Markdown

@Fermiz Fermiz commented May 18, 2026

Summary

This PR improves cascade conversation reuse for personal/single-user setups (e.g., Claude Code, Claude Desktop, Claude for Office plugins) and adds an HTTPS reverse proxy for clients that require TLS.

Problem

When using WindsurfAPI with Claude Code in a single-user setup:

  1. Cascade creates multiple conversations instead of reusing the same one, because the conversation fingerprint drifts between turns (system prompt changes with timestamps, cwd, git status, etc.)
  2. Office plugins (e.g., Claude for PowerPoint/Word) require HTTPS but WindsurfAPI only serves HTTP
  3. Pool size is hardcoded at 500 entries — wasteful for single-user setups

Changes

Caller-based cascade reuse fallback

  • New env var CASCADE_REUSE_BY_CALLER=1: adds a secondary index (callerKey + model) -> cascade in the conversation pool
  • When the primary fingerprint lookup misses (due to system prompt drift), falls back to the latest cascade for the same caller+model
  • Result: single-user Claude Code sessions always reuse the same cascade ID, avoiding redundant history replays

Configurable pool size

  • New env var CASCADE_POOL_MAX=N (default 500): set to 1-5 for single-user setups to minimize memory usage

HTTPS reverse proxy

  • https-proxy.js: lightweight HTTP/2 + HTTP/1.1 reverse proxy with full CORS support
  • Handles Office plugin requirements (HTTPS, HTTP/2, preflight headers)
  • Uses mkcert for locally-trusted certificates

Documentation

  • local-setup.md: step-by-step guide for HTTPS setup with mkcert
  • Updated .env.example, README.md, README.en.md with new env vars

Recommended .env for single-user personal use

CASCADE_REUSE_BY_CALLER=1
CASCADE_POOL_MAX=1

Files changed

  • src/conversation-pool.js — configurable pool max, caller-based fallback index
  • src/handlers/chat.js — pass modelKey to pool checkout/checkin
  • https-proxy.js — new HTTPS reverse proxy
  • local-setup.md — setup guide
  • .env.example, .gitignore, README.md, README.en.md — docs

Testing

  • All 34 existing tests pass
  • Verified HTTPS proxy with Claude Messages API
  • Verified with Claude for PowerPoint plugin (HTTP/2 + CORS)

- Add HTTPS reverse proxy (HTTP/2 + HTTP/1.1) with CORS for Office plugins
- Add CASCADE_REUSE_BY_CALLER env var for session-pinned cascade reuse
- Add CASCADE_POOL_MAX env var to configure pool size (default 500)
- Add modelKey to pool entries for caller-based fallback lookup
- Add local-setup.md with step-by-step HTTPS setup guide
- Add *.pem to .gitignore
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.

1 participant