Skip to content

CloudAgentNext - Apply balance-skip eligibility to command sendMessage follow-ups#4477

Merged
eshurakov merged 2 commits into
mainfrom
steady-hamster
Jul 9, 2026
Merged

CloudAgentNext - Apply balance-skip eligibility to command sendMessage follow-ups#4477
eshurakov merged 2 commits into
mainfrom
steady-hamster

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

sendMessage only routed prompt payloads through the free/BYOK balance-skip client, so command follow-ups (slash commands like /review) on free or BYOK sessions still hit the worker $1 balance gate and 402'd for the zero-balance users the feature targets.

Both the personal and organization sendMessage routers now apply the same computeCloudAgentNextBalanceCheckEligibilitycreateCloudAgentNextClientForModel path to both payload types:

  • prompt turns use the per-message payload.model (unchanged).
  • command turns carry no model, so the session's stored model is resolved via getSession and used for eligibility.
  • When no session model is available, it falls back to the balance-checked client (safe default).

Direct-to-sandbox operations (terminals, answers, interrupt) are outside sendMessage and unchanged.

Verification

  • pnpm --filter web test on the two router test files → 47/47 pass (6 new command-path tests added: free → skip, paid → enforce, no-model → fallback).
  • pnpm --filter web typecheck → clean.
  • pnpm format → clean.
  • oxlint on changed files → 0 warnings/errors.

…w-ups

sendMessage only routed prompt payloads through the free/BYOK
balance-skip client, so command follow-ups (slash commands) on free
or BYOK sessions still hit the worker $1 balance gate and 402'd for
the zero-balance users the feature targets.

Resolve the session's stored model for command turns via getSession
and route them through the same computeCloudAgentNextBalanceCheckEligibility
check as prompts. Fall back to the balance-checked client when no
session model is available. Direct-to-sandbox operations (terminals,
answers, interrupt) remain outside sendMessage and unchanged.
Comment thread apps/web/src/routers/cloud-agent-next-router.ts Outdated
Comment thread apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The command-turn getSession call is now wrapped in its own try/catch that falls back to the balance-checked client on failure, resolving both previously flagged warnings in the personal and organization sendMessage routers.

Files Reviewed (4 files)
  • apps/web/src/routers/cloud-agent-next-router.ts - previously flagged issue resolved
  • apps/web/src/routers/cloud-agent-next-router.test.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts - previously flagged issue resolved
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.test.ts
Previous Review Summary (commit 7e11036)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 7e11036)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The new getSession call added to resolve a command turn's model runs outside the mutation's existing error-normalization try/catch in both sendMessage routers, introducing a new unmapped-error failure mode and an extra worker round-trip on every command follow-up.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/routers/cloud-agent-next-router.ts 226 getSession call for command-turn model resolution runs outside the error-normalization try/catch, and adds an extra worker round-trip to every command message
apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts 340 Same issue in the organization router
Files Reviewed (4 files)
  • apps/web/src/routers/cloud-agent-next-router.ts - 1 issue
  • apps/web/src/routers/cloud-agent-next-router.test.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts - 1 issue
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.test.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 36 · Output: 6.3K · Cached: 1M

Review guidance: REVIEW.md from base branch main

…ssion fails

Degrade to the PR's existing safe default instead of failing the
sendMessage mutation with an unmapped error when the worker can't
return a command turn's session model. Added a regression test in
each router for the getSession-rejects fallback.
@eshurakov eshurakov merged commit cbd9a22 into main Jul 9, 2026
19 checks passed
@eshurakov eshurakov deleted the steady-hamster branch July 9, 2026 20:37
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.

2 participants