Commit graph

1 commit

Author SHA1 Message Date
chopratejas
f121138c8a Fix context-blind compression: pass user query to SmartCrusher relevance scorer
ROOT CAUSE: compress() did not extract the user's question from messages.
The pipeline received empty context, so SmartCrusher selected items by
statistics only (position, anomaly, boundary) — keeping irrelevant chunks
and dropping relevant ones.

FIX: _extract_user_query() in compress.py finds the most recent user
message and passes it as `context` kwarg through the pipeline. SmartCrusher's
RelevanceScorer now receives the actual query and scores items by relevance.

Before: 12 RAG chunks → kept hallucination/video (0/6 key terms)
After:  12 RAG chunks → kept reward hacking content (3/4 key terms)

Also adds:
- examples/context_compression_demo.py — real compression demo for OSS PR
- examples/test_ccr.py — content preservation verification
- OSS_PR_STRATEGY.md — PR target list for LangChain ecosystem

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 23:15:19 -07:00