feat: per-user per-model chat compaction threshold overrides#23412
feat: per-user per-model chat compaction threshold overrides#23412ibetitsmike merged 32 commits intomainfrom
Conversation
Documentation CheckUpdates Needed
Automated review via Coder Tasks |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c7017bce6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0c7017b to
3948c9e
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3948c9e3e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fafde313b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fafde313b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
DanielleMaywood
left a comment
There was a problem hiding this comment.
Unsure on the best practices so converse with your agent, but it feels like I'm expecting to see a <form> somewhere but I'm not.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5db337a048
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c30d97c979
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f3ef6f5bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
…ompaction thresholds
|
@codex review |
342059c to
3b4a437
Compare
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What
Adds per-user per-model auto-compaction threshold overrides. Users can now customize the percentage of context window usage that triggers chat compaction, independently for each enabled model.
Why
The compaction threshold was previously only configurable at the deployment level (
chat_model_configs.compression_threshold). Different users have different preferences — some want aggressive compaction to keep costs low, others prefer higher thresholds to retain more context. This gives users control without requiring admin intervention.Architecture
Storage: Reuses the existing
user_configstable (no migration needed). Overrides are stored as key/value pairs with keys shapedchat_compaction_threshold:<modelConfigID>and integer percent values.API: Three new experimental endpoints under
/api/experimental/chats/config/:GET /user-compaction-thresholds— list all overrides for the current userPUT /user-compaction-thresholds/{modelConfig}— upsert an override (validates model exists and is enabled, validates 0–100 range)DELETE /user-compaction-thresholds/{modelConfig}— clear an override (idempotent)Runtime resolution: In
coderd/chatd/chatd.go, a newresolveUserCompactionThreshold()helper runs at the start of each chat turn (insiderunChat()), after the model config is resolved but beforeCompactionOptionsis built. If a valid override exists, it replacesmodelConfig.CompressionThreshold. The threshold source (user_overridevsmodel_default) is logged with each compaction event.Precedence:
effectiveThreshold = userOverride ?? modelConfig.CompressionThresholdUI: New "Context Compaction" subsection in the Agents → Settings → Behavior tab, placed after Personal Instructions. Shows one row per enabled model with the system default, a number input for the override, and Save/Reset controls.
Testing
ActionReadPersonal/ActionUpdatePersonalon all query methodsImplementation plan
Phase 1 — Tests
coderd/chats_test.go(9 subtests)coderd/database/dbauthz/dbauthz_test.go(4 methods)UserCompactionThresholdSettings.stories.tsx(4 stories)Phase 2 — Backend preference surface
coderd/database/queries/users.sql(list, get, upsert, delete)make gento propagate into generated artifactscodersdk/chats.gocoderd/chats.goandcoderd/coderd.goPhase 3 — Runtime override
resolveUserCompactionThreshold()helper incoderd/chatd/chatd.gorunChat()before buildingCompactionOptionsthreshold_sourcefield added to compaction logPhase 4 — Settings UI
site/src/api/UserCompactionThresholdSettingscomponent extracted fromSettingsPageContentPhase 5 — Refactor and review fixes
codersdk