Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
This works as described, but one generated file needs updating before it's ready. I checked it with the core config, compaction and shared-schema tests and the schema model tests (all pass) and with type checks of packages/core and packages/schema (pass). I also read through the settings merge: Provider.mergeOverlay merges provider and model settings deeply, so a model { buffer } keeps the provider's type, and the order model → provider → top-level compaction.buffer holds. Using the session model's buffer for the "is it due" check and the compaction model's buffer for the summary budget is consistent, since each is measured against that model's own window.
Public API:
- Config: adds
settings.compaction.buffer(non-negative integer) to providers and models. Existing configs still validate. - Schema and SDK:
Provider.Compaction/ProviderCompactionchanges from{ type: "summary" } | { type: "native" }to{ type?: "summary" | "native"; buffer?: number }. Configs are backwards compatible, and a missingtypestill means summary. TypeScript code that readcompaction.typeas always set now has to handleundefined. - The OpenAPI document wasn't regenerated (see the inline comment).
Concern: packages/protocol/openapi.json is stale, so bun run check:generated in packages/protocol fails with this change but passes on the base.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Tested this branch locally against head 926ae54 (Windows, Bun 1.4.0):
The model-level One rebase note: current |
Issue for this PR
Closes #43703
Type of change
What does this PR do?
Adds an optional
bufferto the existing per-provider/model compaction policy:{ "providers": { "openai": { "models": { "gpt-4.1": { "settings": { "compaction": { "buffer": 40000 } } } } } } }The effective buffer is the model setting, then the provider setting, then the top-level
compaction.buffer. This lets models with different context windows keep independent headroom instead of sharing one global value.bufferremains an absolute token count; percentage scaling was intentionally not added.How did you verify your code works?
bun test test/config/provider.test.ts test/config/compaction.test.ts test/session-compaction.test.tsinpackages/core(49 pass)bun test test/model.test.tsinpackages/schema(9 pass)bun run typecheckinpackages/core,packages/schema, andpackages/clientbunx oxlinton changed filespackages/clienttypes andpackages/protocol/openapi.json;bun run check:generatedinpackages/protocolpasses.bun run checkfails onpackages/app/src/custom-elements.d.tsbecause this Windows checkout has symlinks disabled, unrelated to this change.Screenshots / recordings
N/A — not a UI change.
Checklist