Repository navigation
feat: trigger compaction independently for the chat and compaction models - #28568
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c9d5e5fb0
ℹ️ 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: 4d3b53e70e
ℹ️ 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: 7ff36a0e13
ℹ️ 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: 8a34ac1183
ℹ️ 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. What shall we delve into next? Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5423a3f23
ℹ️ 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".
Documentation CheckThis PR changes user-facing compaction behavior for the Coder Agents chat feature: compaction now fires at whichever of two independent triggers binds first (chat trigger vs. organization compaction model trigger, lower token point wins), a threshold of 100 disables only its own trigger, and an organization compaction model whose own trigger is disabled (threshold 100) or unreachable (point past the chat window) falls back to the chat model. The published docs do not yet reflect any of these semantics. Updates Needed
Automated review via Coder Agents |
f5423a3 to
0b6625c
Compare
0b6625c to
c6054b4
Compare
1a9a4be to
09dc580
Compare
|
@codex review
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ 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". |
mafredri
left a comment
There was a problem hiding this comment.
Backend ✅
Docs have a TODO we shouldn't merge.
09dc580 to
b28362f
Compare
|
@codex review
|
…verride window The organization override trigger no longer reads the override model's compression threshold. It fires at a fixed 80% of the override model's context window, leaving room for the summary prompt and the summary. An override with a threshold of 100 is no longer treated as absent; only an unknown window falls back to the chat model. The still-over-limit copy names the 80% window instead of an override threshold.
…ride window The organization override trigger now fires at a fixed 80% of the override model's context window, mirroring chatd, and no longer reads the override model's own compression threshold. Removes the notice for an override whose own compaction is off, and updates the settings popover, organization warning, fixtures, and tests to the new trigger.
…table The site binding cases now match TestBindingCompactionTriggerSource row for row, with the organization trigger at the fixed 80% of the override window.
|
@codex review |
|
/coder-agents-review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 987cefe399
ℹ️ 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. Keep it up! Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
This round covers the rebase onto ff3fa22 and five new commits, which make the organization trigger a fixed 80% of the override window. New findings: 2 P3, 1 P4, 2 Nit.
The new rule follows the updated #30203 decision: neither chatd nor the site reads the override model's compression_threshold, the Go and TypeScript binding tables match row for row, and the rebase keeps main's table layout and required props. The comment and description say the remaining 20% holds the summary request, and nothing checks that (inline). The round 18 approval was for c804a46.
🤖 This review was automatically generated with Coder Agents.
With the fixed 80% trigger, an override trigger is disabled only for a zero window, which the context_limit > 0 check rejects, so a set override always becomes the organization trigger and summarizer. The 80% comment now calls the rest of the window headroom rather than a guarantee, and a test chat title matches its subtest.
…erride copy Renames the window constant to match chatd's compactionOverrideWindowPercent, describes the remaining 20% as target headroom, rewords the override alert and popovers so the organization override is the subject, and drops the organization trigger's enabled check since the database rejects non-positive windows.
|
@codex review |
|
/coder-agents-review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
This round covers 6e8efb9 and c6f8750. No new findings, and no findings are open.
Verified fixed: the unreachable override gate is gone in chatd and the site, the test chat title matches its subtest, the TypeScript constant has chatd's name, and the alert and Effective popovers make the organization override the subject. The 80% comments and the description now call the remaining 20% a target margin, and the summary-time fit check stays out of this PR because the same overshoot exists for every trigger on main.
Out of scope (needs a ticket or explicit acceptance by a human):
coderd/x/chatd/chatloop/compaction.go:224: when the estimated summary input already exceeds the summarizer's window,GenerateCompactionsends the request with the cap unchanged, for every trigger and on main too. Inferred from the code, not run: a provider that enforces the window rejects it, and every later turn fails the same way with a provider error until the user starts a new conversation.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review New head d5888ce after round 20's approval of c6f8750 (093076f was docs only). Two frontend fixes from UAT round 13 notes:
|
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
This round covers 093076f, 4e172ab, and d5888ce. New findings: 1 P4.
Verified: the architecture doc's compaction bullets now match chatd, which resolves the round 1 finding about the stale stricter-limit rule there; formatContextLimit keeps every label from 1,000 tokens up, and its new test pins each boundary; the personal header now hedges while overrides load or after they fail. The row's 100% tooltip misses the failed-load case (inline). The round 20 approval was for c6f8750.
Out of scope (needs a ticket or explicit acceptance by a human):
site/src/pages/AgentsPage/components/ContextUsageIndicator.tsx:97:formatTokenCountCompact(999_999)returns "1000K", so the context gauge can show the rounding this PR fixed informatContextLimit.site/src/modules/aiModels/knownModels/catalog.ts:89:formatContextBadge(999_999)returns "1000K context" in the model catalog badge, the same rounding.site/src/modules/aiModels/ModelSelector.tsx:83: the M branch labels 1,000,000 tokens "1M" and 1,048,576 tokens "1.0M", so nearly equal windows get labels in two formats in the model picker.site/src/modules/aiModels/ModelSelector.tsx:73:formatContextLimitalso formats compaction points (UserCompactionThresholdSettings.tsx:141), so its name describes only one of its two uses.
🤖 This review was automatically generated with Coder Agents.
…ization overrides fail to load
|
/coder-agents-review CRF-167 is fixed in 3cd5b08: the row's 100% tooltip now hedges when its organization's overrides failed to load, with a new story for that state. Thread replied and resolved. Out of scope, left unchanged (pre-existing on main):
|
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
This round covers 3cd5b08. No new findings, and no findings are open.
Verified fixed: when an organization's overrides fail to load, the row's 100% tooltip now says an organization override may still compact chats with this model, matching the header. A failed load never leaves a trigger for that organization, and rows stay hidden while overrides load, so the tooltip and the header agree in every state the rows render in.
🤖 This review was automatically generated with Coder Agents.
Note
Xum (an AI agent) authored this pull request on Mike's behalf.
Summary
Automatic compaction now fires at whichever of two independent triggers is reached first, and the UI shows when the organization override's trigger applies.
On main, the chat threshold was applied to the smaller of the two windows, and nothing in the UI showed it. Example: with a 20K chat model at 70% and an 8K override, main compacts at 5,600 tokens; this PR compacts at 6,400 (80% of 8K, shown as 32%).
Changes
Backend (
coderd/x/chatd):chat_summarizedresult gainstrigger_context_limit_tokens, andcontext_limit_tokensnow records the chat model's window (main recorded the smaller window). On main, lowering a threshold after a compaction ended every later turn with the error.ARCHITECTURE.mddocuments the two triggers, the summary cap, and the still-over-limit rules.Frontend (
site), through a sharedcompactionTriggershelper that mirrors the backend rules (no new API):formatContextLimitprints counts below 1,000 exactly (an 800-token compaction point showed "~1K") and 999,500 to 999,999 as "1.0M" instead of "1000K". It also labels the model pickers; their other values are unchanged.HelpPopoverIconTriggerlets callers set their ownaria-label; only the Effective column's popover does.Known v1 limits: the Coder Agents settings alert is organization-scoped, so it can warn about an override that some members fall back from for lack of provider credentials. The gauge checks the viewer's provider access, so on a shared chat its label can differ from the owner's runtime trigger (Codex P2, declined). Compaction itself is unaffected.
Screenshots
From remote UAT round 13 on 093076f: an isolated test deployment with a local fake LLM. The models are test fixtures named for their context windows: Chat model 20K (own threshold 70%), Chat model 5K (40%), and Chat model 8K (50%). Chat model 8K is also the organization compaction override, so the organization trigger is 80% of 8,000 = 6,400 tokens, which is 32% of Chat model 20K's window. Chat model 8K's own 50% applies only to chats that use it as the chat model; changing it to 10% or 100% left every value below unchanged.
Coder Agents settings: the organization trigger undercuts Chat model 20K's 70% default.
Personal thresholds: the organization trigger binds Chat model 20K at 32%. Chat model 5K (40%) and Chat model 8K (50%) keep their own chat triggers.
Personal thresholds, organization settings request failed (the first red line is the injected error). Rows fall back to chat-only values.
Chat context gauge: organization trigger binds (Chat model 20K), chat trigger binds (Chat model 5K), overrides request failed (injected).
Still-over-limit errors from real runs: organization trigger, chat trigger, both.
Testing
TestBindingCompactionTriggerSource,TestCompactionStillOverLimitError,TestCompactionStatusFromHistory, andTestActiveServer_CompactionModelOverridecover the 80% point (fails if the override's own threshold is read again), user threshold 100 leaving the organization trigger on, the summary cap for automatic and manual compaction, the over-limit messages, and recompaction after a trigger change. The site binding tests mirror the Go table row for row.compactionTriggersunit tests and Storybook stories for the three surfaces, including the overrides fetch failure.go vet, thechatdandchatlooptests, and the AgentsPage, AISettingsPage, and HelpPopover unit tests (2,274 passed, 2 skipped) pass, and CI is green. On 987cefe, tsc, the five affected story files (109 passed), andmake pre-commitalso passed. 093076f only changesARCHITECTURE.md; the pre-commit hook's markdown format and lint checks pass on it.formatContextLimittest (fails on the old helper for 800 and 999,999), thecompactionTriggersandaiModelsunit tests (224 passed), and the affected story files pass, and the pre-commit hook passed on all three commits.Review record
ARCHITECTURE.mdfinding was left for the maintainer, who asked for the update in the last commit.organizationTriggerForstory helper stays because its three fields must match the model.usage_percentis measured against the binding trigger's window, so it can exceed 100 (nothing reads it), and the 100% help text shows only for an unsaved edit.