Skip to content

fix(auto-fix): show clear insufficient-credits message - #5077

Merged
eshurakov merged 2 commits into
mainfrom
session/agent_6128bbbb-7b89-4f75-94e7-ca93b51eb1da
Aug 18, 2026
Merged

fix(auto-fix): show clear insufficient-credits message#5077
eshurakov merged 2 commits into
mainfrom
session/agent_6128bbbb-7b89-4f75-94e7-ca93b51eb1da

Conversation

@eshurakov

@eshurakov eshurakov commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Map autofix 402/billing failures to a clear user-facing message instead of dumping the raw initiateFromKilocodeSessionV2 tRPC envelope.
  • Normalize billing errors at the orchestrator client, status/PR callback write paths, ticket UI, and GitHub review-comment failure replies.
  • Explain the $1 minimum credit requirement and that the user should add credits, then retry.

Comment thread apps/web/src/lib/auto-fix/core/format-error-message.ts Outdated
Comment thread apps/web/src/lib/auto-fix/github/handle-comment-reply.ts Outdated
Comment thread apps/web/src/app/api/internal/auto-fix/pr-callback/route.ts Outdated
Comment thread services/auto-fix-infra/src/services/cloud-agent-next-client.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 234e0b01d: the new commit reuses the shared isAutoFixBillingErrorMessage detector in review-comment failure replies (verified case handling and branch ordering keep the hedged balance-check copy intact) and adds the raw errorMessage to the status-route server log, matching the previously requested raw-payload logging pattern.

Files Reviewed (2 files)
  • apps/web/src/app/api/internal/auto-fix-status/[ticketId]/route.ts
  • apps/web/src/lib/auto-fix/github/handle-comment-reply.ts
Previous Review Summaries (4 snapshots, latest commit 2cac687)

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

Previous review (commit 2cac687)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 2cac6876c: the branch was rebased onto current main with no changes to the PR's own content — the insufficient-credits message centralization, hedged balance-check copy, and raw-payload server logging all verified intact against the rebased tree.

Files Reviewed (9 files)
  • apps/web/src/app/api/internal/auto-fix-status/[ticketId]/route.ts
  • apps/web/src/app/api/internal/auto-fix/pr-callback/route.ts
  • apps/web/src/components/auto-fix/AutoFixTicketsCard.tsx
  • apps/web/src/lib/auto-fix/core/format-error-message.test.ts
  • apps/web/src/lib/auto-fix/core/format-error-message.ts
  • apps/web/src/lib/auto-fix/github/handle-comment-reply.ts
  • packages/worker-utils/src/cloud-agent-next-client.ts
  • packages/worker-utils/src/index.ts
  • services/auto-fix-infra/src/services/cloud-agent-next-client.ts

Previous review (commit 1f0f69d)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 1f0f69d5e: the previous balance-check WARNING is fixed — failed to verify balance / balance check failures now route to their own hedged branch instead of asserting insufficient credits, and routing was verified against the actual error strings (Failed to verify balance in balance-validation.ts, AUTO_FIX_INSUFFICIENT_CREDITS_MESSAGE in @kilocode/worker-utils).

Files Reviewed (1 file)
  • apps/web/src/lib/auto-fix/github/handle-comment-reply.ts

Previous review (commit af21e1b)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

All four previous findings are fixed at HEAD, but merging failed to verify balance / balance check into the insufficient-credits branch in handle-comment-reply.ts now misdiagnoses transient balance-check failures as insufficient credits in GitHub review-comment failure replies.

Overview

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

WARNING

File Line Issue
apps/web/src/lib/auto-fix/github/handle-comment-reply.ts 89 Balance-check failures now assert insufficient credits and tell users to add credits; keep the previous hedged branch for failed verification calls
Files Reviewed (9 files)
  • apps/web/src/lib/auto-fix/github/handle-comment-reply.ts - 1 issue
  • apps/web/src/lib/auto-fix/core/format-error-message.ts - 0 issues
  • apps/web/src/lib/auto-fix/core/format-error-message.test.ts - 0 issues
  • apps/web/src/app/api/internal/auto-fix/pr-callback/route.ts - 0 issues
  • apps/web/src/app/api/internal/auto-fix-status/[ticketId]/route.ts - 0 issues
  • apps/web/src/components/auto-fix/AutoFixTicketsCard.tsx - 0 issues
  • packages/worker-utils/src/cloud-agent-next-client.ts - 0 issues
  • packages/worker-utils/src/index.ts - 0 issues
  • services/auto-fix-infra/src/services/cloud-agent-next-client.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review

Status: 4 Issues Found | Recommendation: Address before merge

Executive Summary

The centralized insufficient-credits formatting works end to end, but the broad 'minimum required' substring pattern (added in two places) can mislabel unrelated failures as billing errors, and two minor maintainability/observability nits remain.

Overview

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

WARNING

File Line Issue
apps/web/src/lib/auto-fix/core/format-error-message.ts 19 'minimum required' pattern is broad enough to misclassify non-billing errors as insufficient credits
apps/web/src/lib/auto-fix/github/handle-comment-reply.ts 87 Same broad 'minimum required' pattern mislabels unrelated failures in review-comment replies

SUGGESTION

File Line Issue
apps/web/src/app/api/internal/auto-fix/pr-callback/route.ts 179 Logging the formatted message drops the raw billing error payload from server logs
services/auto-fix-infra/src/services/cloud-agent-next-client.ts 4 Duplicated credits-message constant can drift from AUTO_FIX_INSUFFICIENT_CREDITS_MESSAGE
Files Reviewed (7 files)
  • apps/web/src/lib/auto-fix/core/format-error-message.ts - 1 issue
  • apps/web/src/lib/auto-fix/github/handle-comment-reply.ts - 1 issue
  • apps/web/src/app/api/internal/auto-fix/pr-callback/route.ts - 1 issue
  • services/auto-fix-infra/src/services/cloud-agent-next-client.ts - 1 issue
  • apps/web/src/app/api/internal/auto-fix-status/[ticketId]/route.ts - 0 issues
  • apps/web/src/components/auto-fix/AutoFixTicketsCard.tsx - 0 issues
  • apps/web/src/lib/auto-fix/core/format-error-message.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 58.5K · Output: 4.4K · Cached: 266.4K

Review guidance: REVIEW.md from base branch main

eshurakov added a commit that referenced this pull request Aug 6, 2026
…essage

Add AUTO_FIX_INSUFFICIENT_CREDITS_MESSAGE next to the cloud-agent-next
billing-error helpers so the web app and auto-fix-infra can share one
source of truth for the user-facing copy.

Addresses review feedback on #5077.
eshurakov added a commit that referenced this pull request Aug 6, 2026
Import AUTO_FIX_INSUFFICIENT_CREDITS_MESSAGE from @kilocode/worker-utils
in the web formatter (re-exported for existing consumers) and in
auto-fix-infra, replacing the byte-identical local copies that could
drift apart.

Addresses review feedback on #5077.
eshurakov added a commit that referenced this pull request Aug 6, 2026
The substring matched non-billing failures (e.g. version requirements),
mislabeling them as insufficient-credits errors. The known 402 payloads
are already caught by 'insufficient credits' and 'payment_required'.

Addresses review feedback on #5077.
eshurakov added a commit that referenced this pull request Aug 6, 2026
The formatted credits message replaced the original tRPC envelope for
billing failures, making production diagnosis harder. Log the raw
errorMessage; the formatted message stays on user-facing surfaces.

Addresses review feedback on #5077.
Comment thread apps/web/src/lib/auto-fix/github/handle-comment-reply.ts Outdated
eshurakov added a commit that referenced this pull request Aug 6, 2026
Balance-check failures describe a failed verification call, not a
confirmed low balance. Merging them into the insufficient-credits branch
asserted the wrong diagnosis and remediation. Restore the pre-existing
hedged copy ('the account balance check failed' / 'Confirm your Kilo
account has available credits, then retry').

Addresses review feedback on #5077.
Centralize auto-fix error formatting so web and auto-fix-infra share one
user-facing insufficient-credits message, while keeping raw billing
payloads in server logs.

Keep balance-check failures on their own hedged copy instead of treating
them as confirmed low-balance errors, and drop the overly broad
'minimum required' matcher that mislabeled non-billing failures.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@eshurakov
eshurakov force-pushed the session/agent_6128bbbb-7b89-4f75-94e7-ca93b51eb1da branch from 1f0f69d to 2cac687 Compare August 18, 2026 09:56
Route review-comment billing replies through isAutoFixBillingErrorMessage
so they pick up the same patterns as formatAutoFixErrorMessage. Log the
raw status-route error payload before formatting, matching pr-callback.
@eshurakov
eshurakov merged commit 553e34c into main Aug 18, 2026
40 checks passed
@eshurakov
eshurakov deleted the session/agent_6128bbbb-7b89-4f75-94e7-ca93b51eb1da branch August 18, 2026 11:41
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