Q17: budget every model request against the provider's context window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 04:40:02 -04:00
1 parent f42ab62dbd
commit f4d16eb46a
26 files changed
+247 -52

No files matched your search

+3
View File
@@ -28,6 +28,9 @@ export const zh: Record<string, string> = {
"Advanced": "高级",
"Integrations": "集成密钥",
"Read by {names}": "已读:{names}",
"Context window (tokens)": "上下文窗口(token)",
"{label} context window": "{label} 上下文窗口",
"The model's context window. Runs keep prompts, skills, history, and tool results inside it.": "模型的上下文窗口。运行时提示词、技能、历史和工具结果都要放进这个范围。",
"Keys are stored on this device, encrypted by the operating system, and shared by every company.": "密钥保存在本机,由操作系统加密,所有公司共用。",
"Composio API key": "Composio API 密钥",
"Powers the Connectors page and agent connector tools. Create one at platform.composio.dev.": "用于连接器页面和 Agent 的连接器工具。在 platform.composio.dev 创建。",
@@ -26,7 +26,7 @@ interface ProvidersPanelProps {
actions: SnapshotActions;
}
const POLICY_GRID = "minmax(150px, 1.2fr) minmax(118px, 0.8fr) minmax(140px, 1fr) 112px 124px 92px";
const POLICY_GRID = "minmax(150px, 1.2fr) minmax(118px, 0.8fr) minmax(140px, 1fr) 112px 124px 124px 92px";
type WorkspaceScope = "organization" | "workspace";
export function ProvidersPanel({ orgId, employeeId, providers, authProfiles, catalog, agents, providerRateLimits, actions }: ProvidersPanelProps) {
@@ -138,9 +138,9 @@ function ProviderPolicyTable({
<div className="card" style={{ padding: 0, overflowX: "auto", marginBottom: 28 }}>
<div
className="table-row head"
style={{ gridTemplateColumns: POLICY_GRID, minWidth: 780 }}
style={{ gridTemplateColumns: POLICY_GRID, minWidth: 900 }}
>
<div>{t("Provider")}</div><div>{t("Scope")}</div><div>{t("Data policy")}</div><div>{t("Background")}</div><div>{t("Monthly limit")}</div><div>{t("Usage")}</div>
<div>{t("Provider")}</div><div>{t("Scope")}</div><div>{t("Data policy")}</div><div>{t("Background")}</div><div>{t("Monthly limit")}</div><div>{t("Context window (tokens)")}</div><div>{t("Usage")}</div>
</div>
{providers.map((provider, index) => {
const rateLimit = requireProviderRateLimit(provider, providerRateLimits);
@@ -176,6 +176,7 @@ function ProviderPolicyRow({
const [dataPolicy, setDataPolicy] = useState(provider.dataPolicy);
const [backgroundEnabled, setBackgroundEnabled] = useState(provider.backgroundEnabled);
const [monthlyRequestLimit, setMonthlyRequestLimit] = useState(String(provider.monthlyRequestLimit));
const [contextWindowTokens, setContextWindowTokens] = useState(String(provider.contextWindowTokens));
const [workspaceScope, setWorkspaceScope] = useState<WorkspaceScope>(provider.workspaceScope === "workspace" ? "workspace" : "organization");
const savePolicy = () => {
@@ -186,6 +187,7 @@ function ProviderPolicyRow({
backgroundEnabled,
monthlyRequestLimit: Number(monthlyRequestLimit),
workspaceScope,
contextWindowTokens: Number(contextWindowTokens),
}));
};
@@ -199,7 +201,7 @@ function ProviderPolicyRow({
className="table-row"
style={{
gridTemplateColumns: POLICY_GRID,
minWidth: 780,
minWidth: 900,
borderBottom: last ? "none" : "1px solid var(--border-soft)",
}}
>
@@ -242,6 +244,16 @@ function ProviderPolicyRow({
value={monthlyRequestLimit}
onChange={(event) => setMonthlyRequestLimit(event.target.value)}
/>
<input
className="input"
aria-label={t("{label} context window", { label: provider.label })}
title={t("The model's context window. Runs keep prompts, skills, history, and tool results inside it.")}
type="number"
min={24000}
step={1000}
value={contextWindowTokens}
onChange={(event) => setContextWindowTokens(event.target.value)}
/>
<div>
<div className="num mono">{rateLimit.requestCount} / {rateLimit.monthlyRequestLimit}</div>
<button type="button" className="button small" aria-label={t("Save {label} policy", { label: provider.label })} onClick={savePolicy}>