Skip to content

feat(site): add the organization token budget setting - #331

Merged
ibetitsmike merged 11 commits into
mainfrom
mike/issue-321-token-budget-setting-ui
Nov 14, 2026
Merged

ibetitsmike merged 11 commits into
mainfrom
mike/issue-321-token-budget-setting-ui

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #321. The API and chatd half merged in #330.

What

A Context compaction section in AI Settings > Coder Agents for the organization token budget setting from #330.

  • Strategy: "Summarize the conversation" (summary) or "Token budget" (token_budget).
  • Fallback at the usable limit: "Start a new context window" (new_window) or "Summarize the conversation" (summary). It is disabled unless the strategy is the token budget, and the stored value is kept.
  • The description says the handoff point is each model's compression threshold, set on the model config, and that a 100% threshold turns the budget off for that model.

The section shows only with fork-token-budget and for a user who can read the organization's chat model configs, the same gate as the subagent limits section. Users without edit permission see it read only.

How

  • Fork files only: site/src/api/forkTokenBudget.ts, site/src/api/queries/forkTokenBudget.ts, ForkTokenBudget.tsx, components/ForkTokenBudgetSettings.tsx with stories, a test, and a fixture in site/src/testHelpers/forkTokenBudget.ts.
  • ForkOrganizationAgentSettings.tsx renders the subagent limits and the new section, so the existing hook line in the upstream OrganizationAgentSettings.tsx now names this wrapper. No new hook line.
  • A refetch updates an unedited form and keeps a draft, as in the subagent limits form. A save cancels any refetch in flight, then writes its response into the cache.
  • Docs: docs/fork/pstack-adapter.md names the section and adds the evidence line.

How tested

  • pnpm test src/pages/AISettingsPage/CoderAgentsPage: 3 files, 25 tests pass. ForkTokenBudget.test.tsx has 8 tests: a save of token_budget with the summary fallback and the cache update, an announced failed save, a kept draft on refetch, a refreshed unedited form, hidden with the experiment off, hidden and no request without read permission, read only for viewers (all radios disabled, no Save), and the fallback disabled under summary and enabled with the token budget.
  • I broke each gate in turn and restored it: the read-only test fails without the canEdit check, the fallback test fails without the strategy check, and both hidden tests fail with the visibility gate forced on. Earlier, the draft test failed without the draft guard, and the failed-save test failed without role="alert".
  • vitest --project storybook on ForkTokenBudgetSettings.stories.tsx (8 stories) and OrganizationAgentSettings.stories.tsx (2): pass.
  • pnpm lint:types and biome check and format on the touched files: pass.
  • fork-ci on the head, linked in the checks.

Not verified: the page in a running deployment.

The fork-token-budget experiment now reads a per-organization setting.
The summary strategy, the default, keeps main's summary compaction with
notes and chat_history. The token_budget strategy keeps the windows of
#314, and its fallback picks a new window or a summary at the usable
limit.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T16:43:17.462755Z 080b736 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15435aba7b

ℹ️ 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".

…ools

The new_context tool holds the fallback of the step that built it, so triggers and compaction follow one setting and a foreign new_context tool does not make a turn eligible. With the summary fallback, the compaction model override's trigger still applies.
…1-token-budget-setting-ui

# Conflicts:
#	docs/fork/pstack-adapter.md
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged the base branch after the chatd fixes on #330.

@codex review

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b5e50691e

ℹ️ 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".

Comment thread site/src/api/queries/forkTokenBudget.ts Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f6e364b68

ℹ️ 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".

Comment thread site/src/api/forkTokenBudget.ts Resolved
Comment thread site/src/api/queries/forkTokenBudget.ts Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: dc4933ed4b

ℹ️ 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".

Base automatically changed from mike/issue-321-token-budget-setting to main November 14, 2026 16:02
…budget-setting-ui

# Conflicts:
#	docs/fork/pstack-adapter.md
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d33f6b574e

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: adc5bb99c0

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a741b2281f

ℹ️ 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".

Comment thread docs/fork/pstack-adapter.md Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 080b7360d7

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit 9f99450 into main Nov 14, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-321-token-budget-setting-ui branch November 14, 2026 17:12
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as 9f99450 (squash, --match-head-commit).

Gates on head 080b736:

  • All 9 check runs passed. fork-ci run 43616854274 succeeded on this head.
  • Codex: "Didn't find any major issues" for 080b736: feat(site): add the organization token budget setting #331 (comment)
  • Unresolved review threads: 0. Behind main: 0. Main was 9308bf6 and the server ran 9308bf6 at merge time.
  • Tests I ran on this head: pnpm test src/pages/AISettingsPage/CoderAgentsPage, 3 files, 25 tests pass (8 in ForkTokenBudget.test.tsx, including the read-only viewer, hidden with the experiment off, and fallback gate tests).
  • Negative control I ran on the previous head adc5bb9: with the experiment gate removed from ForkTokenBudget.tsx, "is hidden while fork-token-budget is off" fails; restored afterwards.
  • Opus review on adc5bb9: mergeable, no P1. Its P2 (no read-only test) and nits were fixed in a741b22 and 080b736. I reviewed that delta myself (tests, two removed comments, a cursor class, hint text).

Not exercised: the page on a running deployment. The section shows only with the fork-token-budget experiment on, which is off on the daily server; enabling it is an ops step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chatd: admin setting for token-budget compaction (strategy and fallback)

1 participant