Skip to content

feat(pruner,proxy,router): adaptive token-budget stream filter, Streamable HTTP & multi-upstream gateway (v1.2.0) - #4

Merged
aloneangel45 merged 7 commits into
mainfrom
feat/dynamic-stream-filter-v1.2
Nov 10, 2026
Merged

aloneangel45 merged 7 commits into
mainfrom
feat/dynamic-stream-filter-v1.2

Conversation

@aloneangel45

Copy link
Copy Markdown
Owner

Closes #1

Summary

Implements ToolPrune v1.2.0, delivering RFC #1 (--max-schema-tokens progressive token-budget compactor and adaptive context-aware stream filter), modern MCP schema fidelity, multi-upstream gateway routing (Stdio + SSE + Streamable HTTP /mcp), localhost DNS-rebinding security hardening, CLI enhancements, and cross-platform E2E + benchmark verification.

Key Architectural Upgrades

  • RFC [RFC] Dynamic context-aware schema filtering for streaming JSON-RPC endpoints #1 Progressive Token-Budget Compactor (pkg/pruner/budget.go): 5-pass deterministic compaction engine (minify -> condense -> aggressive -> signature skeleton -> priority-scored stubbing) calibrated against cl100k_base tokenization to strictly enforce --max-schema-tokens=N (pruning.max_schema_tokens).
  • Adaptive Context-Aware Stream Filter (pkg/proxy/stream_filter.go): Intercepts tools/list and tools/call on the live wire with hot-tool usage scoring (2x priority boost for active tools), SHA-256 (upstream_hash, hot_set, budget) cache (0.0037ms cache hit, 0.353ms cold pass), and pre-bind JSON Schema validation against the unpruned upstream contract (0.010ms).
  • Modern MCP & JSON Schema Fidelity (pkg/mcp, pkg/pruner): Preserves outputSchema, annotations, title, $defs/definitions/$ref, const, pattern, format, items, oneOf/anyOf/allOf, and rune-safe UTF-8 sentence condensation; raises framing limit to 16MB for both Content-Length and NDJSON streams.
  • Multi-Upstream Gateway & Transport Security (pkg/router, pkg/proxy/sse.go, pkg/proxy/sse_client.go): Wires multi-upstream configuration into live gateway execution (toolprune_search_tools / toolprune_call_tool meta-tools + dynamic hydration), adds outbound SSE client and Streamable HTTP /mcp, fixes supervisor pipe/data races, and enforces Host + Origin DNS-rebinding defenses on loopback HTTP listeners.
  • CLI, Presets & Release Hardening: Completes --preset (minimal/balanced/strict/dynamic), routes --profile/--filter, bench --csv/--verbose, config patch-claude, SHA-256 verified installers (install.sh / install.ps1), and windows/arm64 release artifacts.

Benchmarks & Verification (Go 1.23, CGO_ENABLED=0)

  • Enterprise MCP Suite (cl100k_base): 3,596 raw tokens -> 242 tokens under --max-schema-tokens=350 (-93.3%) and 127 tokens in Tier 4 dynamic (-96.5%).
  • Test Suite: go vet ./... clean; 198 top-level test functions passing across all 11 Go packages.

@aloneangel45
aloneangel45 merged commit 70de5f2 into main Nov 10, 2026
6 checks passed
@aloneangel45
aloneangel45 deleted the feat/dynamic-stream-filter-v1.2 branch November 10, 2026 18:56
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.

[RFC] Dynamic context-aware schema filtering for streaming JSON-RPC endpoints

1 participant