feat(engine): unify compaction under one Compactor abstraction; add summarizer + truncation; comprehensive stats - #2
Merged
Conversation
…ummarizer + truncation; comprehensive stats Every compaction approach now implements one interface, engine.Compactor (conversation in -> conversation out), name-registered and selected via `compactors:` config. reduce, extract, summarize, truncate and cache are all Compactors; a new approach plugs in the same way (implement + Register + list). - Summarizer (internal/summarize): ReSum-style prompts ported from CE-Manager; replaces older turns with one <summary>, keeps the last keep_last verbatim, dropped span recoverable. Opt-in. - Truncation: naive keep-last-N baseline (no model), recoverable. Opt-in. - Extract fully decoupled from the reduce candidate flow: it does its own large-output detection (reduce.SelectLLMCandidates) and runs before reduce. - Uniform model + credentials for every LLM compactor (config.ModelTransport + engine.ModelSpec): provider/model/auth/base, inline api_key or key_env, and source=config|incoming (reuse the proxied request's own model + credentials). - --reduce-cached-prefix: run the deterministic reducers + extractor on a self-caching client's cached prefix (e.g. Claude Code) instead of deferring. - Observability: /stats now exposes per-session breakdown, a recent-per-call ring, and full latency distribution (p50/p95/p99/max/mean) at global + session scope; the per-call slog event carries the same metrics. - Naming: purge the upstream prototype name from the runtime surface — markers («labcx:..», labcx_expand), /labcx/expand, x-labcx-bypass, LABCX_* env, the eval compose service; provenance comments reworded. - Docs: README/RUNNING/RESULTS + swe-bench integration updated with the new abstraction, flags, stats, and a real 10-task SWE-bench run (-35.5% aggregate input tokens via the deterministic reducers on Claude Code's cached prefix). Assisted-By: Claude Opus 4.8 Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unifies the pipeline under a single
Compactorabstraction and adds two new compaction approaches, uniform model/credential handling, a self-caching-client lever, and comprehensive metrics — plus a real 10-task SWE-bench run.Every compaction approach now implements one interface —
engine.Compactor(conversation in → conversation out), name-registered and selected viacompactors:. reduce, extract, summarize, truncate, cache are all Compactors; a new approach plugs in the same way (implement →Register→ list by name).What's included
internal/summarize): ReSum-style prompts ported from CE-Manager; replaces older turns with one<summary>, keeps the lastkeep_lastverbatim, dropped span recoverable. Opt-in.reduce.SelectLLMCandidates) and runs before reduce.config.ModelTransport+engine.ModelSpec): provider/model/auth/base, inlineapi_keyorkey_env, andsource: config|incoming(reuse the proxied request's own model + credentials).--reduce-cached-prefix: run the deterministic reducers + extractor on a self-caching client's cached prefix (e.g. Claude Code) instead of deferring to its cache./stats: per-session breakdown, a recent-per-call ring, and full latency distribution (p50/p95/p99/max/mean) at global + session scope; the per-call slog event carries the same metrics.«labcx:…»,labcx_expand),/labcx/expand,x-labcx-bypass,LABCX_*env, the eval compose service; provenance comments reworded (only the../winnowpath reference to the prototype dir remains).Validation
make fmt lint test buildclean; new tests for the Compactor registry, summarize/truncate, model-specincoming,modelBaseprefixing, and the enriched aggregator.Assisted-By: Claude Opus 4.8