Skip to content

fix(redis): give chat its own per-user byte budget and name sizes in payload-limit errors - #10219

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/loop-results-chat-budget
Nov 20, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/loop-results-chat-budget

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Chat streams and workflow executions shared one per-user Redis byte counter, but with different ceilings (128 MB for Chat, 256 MB for executions). Workflow runs alone could push the counter past Chat's ceiling, and every Chat turn was then refused for up to an hour with "Your recent responses streamed more output than the hourly limit allows", even though Chat had streamed almost nothing.
  • Each owner kind now gets its own user counter. Executions keep their original user:<id> key, so counters already in flight still apply. Chat moves to copilot_stream_user:<id>. During cutover, a refund to the new key just deletes it, which over-counts in the safe direction.
  • Worst-case Redis held per user rises from 256 MB to 384 MB (256 + 128). That is the cost of the two ceilings no longer interfering with each other.
  • ExecutionResourceLimitError for execution_payload_bytes now names the value's size and the limit, and says what to change. Before, a function reading a 28 MB loop output saw only "Execution memory limit exceeded. Reduce payload size and try again.", so both the user and Chat kept re-running a workflow that could never fit. Redis-budget refusals keep the generic text, because their byte counts describe a write chunk, not anything the user controls.

Type of Change

  • Bug fix

Testing

  • New replay-budget.integration.ts case against real Redis and Postgres: the user's execution counter is held at its full ceiling and a Chat turn completes. Red on the old shared key layout (expected ['error','complete'] to not include 'error'), green on the fix, 24/24.
  • New execute-request.test.ts case drives the real sim.values.read broker with a 28 MB value ref. Red on the old message, green on the new one.
  • Updated byte-budget.server.test.ts and buffer.test.ts for the per-kind key. The cleared-buffer check now allow-lists exactly the owner key.
  • Targeted vitest across lib/core/redis, lib/execution, lib/mothership/request/session, lib/function-execution, app/api/workflows, lib/logs/execution, lib/uploads/utils and lib/workflows/streaming: 1,975 passed. Biome is clean. CI runs type-check and check:audits.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 20, 2026 12:16am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This appears safe to merge; no actionable issues were found.

Summary

Chat now has its own per-user Redis byte budget, and payload-limit errors show useful sizes and advice.

  • Workflow runs and Chat streams charge separate per-user byte counters.
  • Oversized payload errors show the value size and the limit when known.

waleedlatif1 explicitly accepts the higher combined allowance and temporary over-counting during cutover. No actionable issues found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  W[Workflow writes] --> E[Existing per-user counter]
  E --> EL[256 MB limit]
  C[Chat writes] --> S[Separate per-user Chat counter]
  S --> SL[128 MB limit]
Loading

Reviews (1) · Last reviewed commit: "fix(redis): give chat its own per-user b..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit b3e928f into staging Nov 20, 2026
79 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/loop-results-chat-budget branch November 20, 2026 00:20

This branch was previously deployed

1 inactive deployment
Preview — ec834797 Deployed Nov 20, 2026 by vercel[bot]
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