Repository navigation
Closed
Description
Coder Agents created this issue on behalf of @ibetitsmike.
Part of #4. Follow-up to #283.
Gap
The token-budget context windows from #283 are on main (#285, #313, #315, #314, #316), behind the fork-token-budget experiment. There is no setting for them anywhere in the UI or the API:
- The chatd: token-budget context windows instead of summary compaction #283 design chose "no new deployment setting". With the experiment on, every chat that has the
notesandnew_contexttools uses token-budget windows. With it off, every chat uses summary compaction. - So the only switch is the server experiment list, which only ops can change and which needs a restart. An admin cannot see whether the feature is on, cannot turn it on or off, and cannot pick what happens when an agent ignores the handoff requests.
- On 2026-11-14 Mike looked for the option on the daily server and did not find it.
The upstream prototype (coder#31191, read only) and Xum both have an admin setting for this. The prototype's version is a "Context window fallback" select on the Coder Agents settings page, stored in site_configs and served by /api/experimental/chats/config/context-windows.
Wanted
An admin setting on the Coder Agents settings page that controls token-budget compaction. It is shown only when fork-token-budget is on.
- Compaction strategy: "Summary" (as on
main) or "Token budget" (context windows). The default is "Summary". Ops can then turn the experiment on with no change in behavior, and an admin opts in from the UI. - Forced rollover fallback: what happens when a chat reaches the usable limit without calling
new_context. The choices are "Start a new context window" (the current behavior of feat(coderd/x/chatd): start token-budget context windows behind fork-token-budget #314, and the default) or "Summarize the conversation". - The description says that the handoff point is the per-model compression threshold, which is set on the model config. It also says that a threshold of 100% turns the budget off for that model.
Backend:
- Fork code only:
fork_*.gofiles, one hook line per upstream file,forkdbqueries, and no numbered migrations. Follow the existing fork settings pattern,ForkSubagentLimits(codersdk types, a/api/v2/chats/fork/...route, dbauthz, andForkSubagentLimitsSettings.tsxonOrganizationAgentSettings). Choose between organization scope and deployment scope from that pattern and say why in the PR. - The read and the update need the same RBAC as the subagent limits setting. The route sits behind
httpmw.RequireExperiment(api.Experiments, codersdk.ExperimentForkTokenBudget)incoderd/fork_chat_routes.go, like the other fork routes. - chatd reads the setting once per turn, where
tokenBudgetTriggersruns inturn_environment.go. It does not add a store read per step. With "Summary", the turn takes exactly themainpath: no handoff or final requests, nonew_contexttool, summary compaction. Thenotesandchat_historytools may stay, because they are useful without windows. The PR states which tools stay. - With the fallback set to "Summarize", the forced point runs the upstream summary compaction instead of the lead-in window.
Acceptance
- API tests: get returns the defaults (
summary,new_window) when unset. Update round-trips. Bad values return 400. A member without the permission gets 403. The route is refused with the experiment off. - chatd tests: with the experiment on and the strategy set to
summary, a small-context-limit chat compacts by summary and gets no handoff request. Withtoken_budget, the feat(coderd/x/chatd): start token-budget context windows behind fork-token-budget #314 end-to-end test still passes. Withtoken_budgetand thesummaryfallback, ignoring the requests summarizes at the usable limit. - A site test or story for the settings component, and a check that it is hidden when the experiment is off.
- Docs:
docs/fork/pstack-adapter.md,coderd/x/chatd/ARCHITECTURE.md(written in the PR, no TODOs), andmake genoutput. - Out of scope: a per-user or per-chat override, and turning the experiment on for the daily server (an ops step in Fork ops).
Metadata
Metadata
Assignees
Labels
No labels
Activity
ibetitsmike commentedon Nov 14, 2026
The API and chatd part (#330) merged as 9308bf6 at 16:02Z. The UI (#331) comes next, after the deploy, once it is retargeted to
mainand has fork-ci on its head.ibetitsmike commentedon Nov 14, 2026
Done. Backend #330 (9308bf6, live 17:11Z) and UI #331 (9f99450, merged 17:12Z, deploy pending) are on main. The setting is under Admin settings > AI > Coder Agents per organization: strategy summary (default) or token_budget, fallback new_window (default) or summary. It shows and works only with the
fork-token-budgetexperiment on; enabling it on the daily server is an ops step.