Repository navigation
fix(billing): stop free-plan workflow runs at their usage limit mid-run - #9207
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
All reported issues were addressed across 12 files
This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
[Critical impact] The PR appears safe to merge; no new blocking issue remains. SummaryStops free-plan Agent runs before another model call once recorded usage plus the run’s unsettled model spend reaches the limit.
|
56d9599 to
2d47822
Compare
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
2d47822 to
e10de80
Compare
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
e10de80 to
ebabfe5
Compare
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
…spend with workflow tools
…ntinued calls once - RunUsageLimitError joins the errors every provider already rethrows unwrapped, replacing the per-request side channel that could mask an unrelated later failure - The stop is attributed to the user, so provider, stream-loop and stream-read logs record it at info; a run abort is classified before attribution so a run timeout still logs at warn - A pending call continued from an earlier attempt is billed through the journal only - The stop bills tool results the way success does: successful results and failed Function runs
ebabfe5 to
9d7aa68
Compare
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
… limit once - A turn an earlier process journaled adds its model spend to the run's unrecorded total the first time this run opens it; reopening the turn (fallback model, block retry) never counts it again - Type the continued-call test's tool as a ProviderToolConfig
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 26 files
Confidence score: 3/5
- In
apps/sim/providers/index.ts, a failedfunction_executereplay that proceeds to a model call is charged twice. Clear the failed-function accumulator before addingpriorConversationUsage.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/providers/index.ts">
<violation number="1" location="apps/sim/providers/index.ts:353">
P1: A failed `function_execute` replay is charged twice when this request continues to a model call: once through `failedFunctionToolCost` and again through `priorConversationUsage`. Clear the failed-function accumulator after replaying pending calls, before the current provider response is assembled.
(Based on your team's feedback about journaled agent spend.)</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
prepareConversationGeneration, which every provider loop already calls) and again after a compaction summary, a free-plan run re-judges its payer through the existingreadMidRunUsageVerdict, now counting the run's unrecorded spend; it reads nothing until the run has spent and uses the cached execution gateRunUsageLimitError(non-retryable, attributed to the user so it logs at info), carrying what success would have billed: the request's settled steps, successful tool results and failed Function runs, compaction summaries, and journaled prior attempts (a continued pending call is billed once, through the journal). Providers already pass it through unwrapped viaisConversationContextError, so fallbacks and block retries don't firereadMidRunUsageVerdictpass no spend and are unchangedproviderFailureLogLeveland the streaming tool loops now share one severity rule: a run abort first (timeout warn, Stop info), thenclassifyFailureattributionType of Change
Testing
providers/run-usage-limit.test.ts(21 failure-mode tests through the real hooks,executeProviderRequestand verdict code), plus compaction, workflow-tool and workflow-handler child-sharing tests; each guard reverted to confirm its test goes redbun run lint,check:comment-hygiene,check:test-patterns; type-check andcheck:auditsleft to CIChecklist
test-auditauthoring gate)