Add Cache-Aware "Token + Cache" Usage Limit Type - #3543
Draft
Kaveh-Vakili wants to merge 1 commit into
Draft
Conversation
Adds a Cache read/write weight (%) pair to the Model Settings card, backed by the new CACHE_READ_WEIGHT/CACHE_WRITE_WEIGHT model metadata fields, and a new "Token + Cache" option to every surface that offers the Usage Limit Type selector so members can be restricted with a cache-aware token budget instead of the plain Token limit. - engine-metadata-display.tsx: add cacheReadWeight/cacheWriteWeight to ModelMetadata/ModelSettingsValues, normalize, and render read-only - engine-model-settings.tsx: editable Cache read/write weight inputs (0-1000%, blank = 100% default) alongside Context window/Max output tokens, wired into the UpdateModelMetadata save payload - members-table.tsx, add-members.tsx, model-restriction-fields.tsx, member-profile-form.tsx, user-add-overlay.tsx: add the "Token + Cache" option to the Usage Limit Type selector and extend the Max Tokens field's visibility/payload conditionals to include it - members-list.tsx: recognize token_cache in the restriction label and Limit Value column, and carry max_tokens through on inline permission-only edits - members.json (en): add the tokenCache i18n label
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a "Token + Cache" usage limit type so admins can restrict a member's model usage by a token budget that also counts cache read/creation tokens, weighted at a per-model percentage, instead of only plain prompt+completion tokens. Includes a new Cache read/write weight (%) config in Model Settings, backed by the backend's new CACHE_READ_WEIGHT/CACHE_WRITE_WEIGHT model metadata fields (see companion backend PR).
Changes Made
engine-metadata-display.tsx: add cacheReadWeight/cacheWriteWeight to ModelMetadata/ModelSettingsValues, normalize on fetch, and render read-only in ModelMetadataFields
engine-model-settings.tsx: editable Cache read weight / Cache write weight inputs (0–1000%, blank = 100% default) next to Context window/Max output tokens, validated and included in the UpdateModelMetadata save payload
members-table.tsx (Edit Member modal), add-members.tsx / model-restriction-fields.tsx (Add Members), member-profile-form.tsx, user-add-overlay.tsx: add "Token + Cache" to the Usage Limit Type selector and extend the Max Tokens field's visibility/payload conditionals to include it (previously only "token" showed/sent Max Tokens)
members-list.tsx: recognize token_cache in the restriction label and Limit Value column (previously fell through to "—"), and carry max_tokens through on inline permission-only edits for this mode
libs/i18n/.../en/shared/members.json: add the tokenCache label ("Token + Cache")
How to Test
Notes
This is UI/config plumbing only — actual enforcement (throwing when a member exceeds a Token + Cache limit) lives in the backend PR. This PR alone lets you configure and persist the setting; pair it with the backend PR to see it enforced live.
The Usage Limit Type dropdown is duplicated across 4 components (members-table.tsx, add-members.tsx/model-restriction-fields.tsx, member-profile-form.tsx, user-add-overlay.tsx) with independently-maintained label maps — already a pre-existing drift risk (e.g. label capitalization already differed slightly between two of them before this PR). Worth consolidating into one shared constant/component in a follow-up rather than continuing to add new options in four places.