Skip to content

feat: 0.2.0 add drop-in SDK adapters, examples, benchmarks, fuller tests - #1

Merged
EvanPaules merged 1 commit into
mainfrom
feat/0.2.0
May 14, 2026
Merged

feat: 0.2.0 add drop-in SDK adapters, examples, benchmarks, fuller tests#1
EvanPaules merged 1 commit into
mainfrom
feat/0.2.0

Conversation

@EvanPaules

Copy link
Copy Markdown
Owner

Adds an adoption-focused release without changing the core ContextOptimizer API. Wraps the OpenAI and Anthropic SDKs so a one-line swap turns any existing chat call into an auto-trimmed one, and ships the runnable examples, benchmarks, and tests reviewers expect to see before they star a library.

  • src/adapters/openai.ts + src/adapters/anthropic.ts: withOptimizer(client, config) returns a client whose chat.completions.create / messages.create intercepts messages and runs ctx-opt before forwarding. The Anthropic adapter hoists system for the optimizer view and splits it back out for the API. Both expose client, optimizer, lastMeta.
  • Subpath exports ctx-opt/openai and ctx-opt/anthropic via tsup multi-entry build. openai and @anthropic-ai/sdk are optional peer deps.
  • examples/: openai, anthropic, summarizer-with-real-Anthropic, langchain.
  • benchmarks/run.ts: reproducible head-to-head of all 4 strategies. Results pasted into README.
  • tests/strategies/relevance.test.ts + hybrid.test.ts: fill the coverage gap. tests/adapters/*: full adapter suites with mock SDKs. 21 to 52 tests.
  • CHANGELOG.md following Keep-a-Changelog. README updated with the adapter quick-start, benchmark table, and changelog link.
  • Documents in CHANGELOG a known limitation: the hybrid pipeline shares recentWindow between phases, so the post-relevance set is rarely compressible. Summarizer falls through to its sliding-window fallback. Splitting the windows is queued for a future release.

Adds an adoption-focused release without changing the core ContextOptimizer
API. Wraps the OpenAI and Anthropic SDKs so a one-line swap turns any
existing chat call into an auto-trimmed one, and ships the runnable
examples, benchmarks, and tests reviewers expect to see before they
star a library.

- src/adapters/openai.ts + src/adapters/anthropic.ts: withOptimizer(client, config)
  returns a client whose chat.completions.create / messages.create
  intercepts messages and runs ctx-opt before forwarding. The Anthropic
  adapter hoists system for the optimizer view and splits it back out
  for the API. Both expose client, optimizer, lastMeta.
- Subpath exports ctx-opt/openai and ctx-opt/anthropic via tsup
  multi-entry build. openai and @anthropic-ai/sdk are optional peer
  deps.
- examples/: openai, anthropic, summarizer-with-real-Anthropic, langchain.
- benchmarks/run.ts: reproducible head-to-head of all 4 strategies.
  Results pasted into README.
- tests/strategies/relevance.test.ts + hybrid.test.ts: fill the
  coverage gap. tests/adapters/*: full adapter suites with mock SDKs.
  21 to 52 tests.
- CHANGELOG.md following Keep-a-Changelog. README updated with the
  adapter quick-start, benchmark table, and changelog link.
- Documents in CHANGELOG a known limitation: the hybrid pipeline shares
  recentWindow between phases, so the post-relevance set is rarely
  compressible. Summarizer falls through to its sliding-window fallback.
  Splitting the windows is queued for a future release.
@EvanPaules
EvanPaules merged commit af60337 into main May 14, 2026
3 checks passed
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