Registry Mirror
Skip to content

Conversation

@anurag629

Copy link
Copy Markdown
Member

What

The docs chat at chat.codercops.com (website/src/pages/api/chat.ts) now has a daily budget:

  • globalPerDay: { tokens: 5_000_000 }. Before this it had none, so the OpenAI bill had no ceiling.
  • perIpPerDay: { tokens: 250_000 }. The default per-IP budget is 2M tokens, which is 40% of the new daily cap, so two scripted IPs could close the chat for everyone.

A docs answer in the eval recordings averages about 2,000 tokens in and 500 out. That makes the daily cap about 2,000 answers and the per-IP cap about 100. Past the daily cap, the widget shows "The assistant has reached its limit for today" until midnight UTC. The 200-reply-per-conversation default still applies.

No changeset: this only touches the website.

How I tested this

  • Typechecked the budgets object against chatcopsCloudflareHandler's config type with tsc --strict.
  • Ran createBudgetGuard with these budgets and 2,000-in/500-out answers: one IP is refused after 100 answers (budget_exceeded, scope ip), and the whole site after 2,000 (scope global).

A hotfix PR into production carries the same change, so it goes live without releasing the 20 changesets waiting on dev.

The docs chat on chat.codercops.com had no global budget, so its bill had
no ceiling. Cap it at 5M tokens a day (about 2,000 answers) and lower the
per-IP default from 2M to 250k tokens (about 100 answers), so one script
can't use up the day for everyone.
@anurag629
anurag629 merged commit 735b6b5 into dev Nov 16, 2026
@anurag629
anurag629 deleted the chore/docs-chat-daily-cap branch November 16, 2026 07:13
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.

1 participant