Repository navigation
Conversation
There was a problem hiding this comment.
The feature works as described. The new tests cover precedence, the cap at the model's limit and config reload, and they pass along with tsc in packages/core and packages/schema. The new config shape decodes on this branch and is rejected on the base. I didn't run a full compaction end to end.
Public API impact:
- Adds the config key
compaction.window(positive integer). - Adds
windowtoProvider.Compaction, sosettings.compaction.windowworks on providers, models and variants. - Adds
agents.<id>.request.settings(the fullConfig.Provider.Settings). - Changes
Provider.Compactionfrom a tagged union{type:"summary"} | {type:"native"}to{ type?: "summary" | "native"; window?: number }. This shows up inopenapi.jsonand the generated client typeProviderCompaction.
Existing configs keep working. Clients that narrow on ProviderCompaction as a discriminated union with a required type will need updating, because type can now be missing.
Concerns:
- The new
agents.<id>.request.settingsaccepts every provider setting, but onlycompaction.windowhas any effect (see inline). - The untyped
compactionWindowkey duplicatescompaction.window(see inline). - The docs aren't updated:
services/www/src/docs/content/config.mdxandcompaction.mdxcovercompaction.*and per-modelsettings.compactionbut notwindow. - #61698 adds the same
autoLimithelper for the per-agent case and was opened earlier. Maintainers will want to settle on one approach.
|
Addressed the review feedback in e1d3f81:
|
There was a problem hiding this comment.
My earlier concerns are addressed:
agents.<id>.requestis back to{ headers, body }, and the window has its ownagents.<id>.compaction.windowfield.- The untyped
compactionWindowkey is gone. - The docs now cover
window.
I re-ran the 4 related test files in packages/core (116 pass) and the packages/schema tests (92 pass). tsc passes in both packages.
Public API impact:
- Adds the config key
compaction.window. - Adds
windowtoProvider.Compaction(settings.compaction.windowon providers, models and variants). - Adds
agents.<id>.compaction.window(Config.Agent.Compaction), also accepted in Markdown agent frontmatter. Provider.Compactionchanges from the tagged union{type:"summary"} | {type:"native"}to{ type?: "summary" | "native"; window?: number }in the OpenAPI spec and the generated client typeProviderCompaction.
Existing configs keep working. Clients that narrow ProviderCompaction on a required type need updating.
One remaining issue is in the docs example (see inline). Overlap with #61698 still needs a maintainer decision.
e1d3f81 to
3705741
Compare
There was a problem hiding this comment.
Since my last review the branch was rebased onto latest dev (the code is unchanged and the docs moved to services/site), plus one docs commit. That commit fixes my last point: the per-agent example in compaction.mdx now uses agents.build, which is the session's agent that autoLimit reads. On the new head, the 4 related test files in packages/core pass (120 tests), tsc passes in packages/core and packages/schema, and the generated OpenAPI spec and client types are up to date.
The public API impact hasn't changed since my last review:
- Adds the config keys
compaction.window,settings.compaction.windowandagents.<id>.compaction.window. Provider.Compactionbecomes{ type?, window? }instead of a tagged union.
Existing configs keep working. Clients that narrow ProviderCompaction on a required type need updating.
No new concerns. The overlap with #61698 is still for maintainers to decide.
Issue for this PR
Related: #61696, #43703
Type of change
What does this PR do?
Adds an optional
window(in tokens) to compaction configuration so automatic compaction can plan for a smaller target context window without reducing the model's actual request limit:compaction.windowinopencode.jsoncsets a default automatic compaction window across models.settings.compaction.windowoverrides the top-level setting for a provider, model, or variant (including setting a larger value to opt back into a large model's full context window when a lower globalcompaction.windowis set).agents.<id>.compaction.window(orcompaction.windowin Markdown agent frontmatter) overrides the model and global window for that agent's sessions.autoLimitcaps the effective window at the model's actual limit so it never raises a model's window, and leaves the summary request's own budget at the model's limit so single-turn bursts pastwindowstill summarize cleanly.How did you verify your code works?
bun --cwd packages/schema test(92 pass) andbun run --cwd packages/schema typecheck:tscbun --cwd packages/core test test/config/compaction.test.ts test/config/provider.test.ts test/config/agent.test.ts test/session-compaction.test.ts(116 pass) andbun run --cwd packages/core typecheck:tscbun run --cwd packages/protocol check:generatedandbun run --cwd packages/client check:generatedservices/www/src/docs/content/config.mdxandservices/www/src/docs/content/compaction.mdxScreenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #61696, #43703
Public API: adds compaction.window, settings.compaction.window and agents..compaction.window config keys; Provider.Compaction becomes { type?, window? } instead of a tagged union (configs compatible; generated client type changes)