feat(core): add soft max-cost nudge state - #11831
Merged
Merged
Conversation
5 tasks
johnnyeric
force-pushed
the
johnnyeric/maxcost-nudge-core
branch
from
June 30, 2026 12:12
98517b8 to
7195102
Compare
Surface-agnostic, dependency-free MaxCostNudge: aggregates per-assistant
message cost into a session total (session.cost is written via direct SQL
and never emits session.updated), and decides when to fire a non-blocking
"keep going?" alert once a global limit is crossed.
check() alerts once per run; resolve("continue") suppresses re-alerts for
that limit; rearm() re-arms on a new run; onSessionDeleted() clears state.
Consumers own the limit (set via setLimit) and the UI/abort.
johnnyeric
force-pushed
the
johnnyeric/maxcost-nudge-core
branch
from
June 30, 2026 12:34
7195102 to
68f1feb
Compare
johnnyeric
marked this pull request as ready for review
June 30, 2026 12:38
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous Review Summaries (2 snapshots, latest commit 506f6e0)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 506f6e0)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (2 files)
Previous review (commit 68f1feb)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · Input: 44.1K · Output: 4.2K · Cached: 225.3K Review guidance: REVIEW.md from base branch |
chrarnoldus
approved these changes
Jul 1, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
* feat(core): soft max-cost nudge state machine
Surface-agnostic, dependency-free MaxCostNudge: aggregates per-assistant
message cost into a session total (session.cost is written via direct SQL
and never emits session.updated), and decides when to fire a non-blocking
"keep going?" alert once a global limit is crossed.
check() alerts once per run; resolve("continue") suppresses re-alerts for
that limit; rearm() re-arms on a new run; onSessionDeleted() clears state.
Consumers own the limit (set via setLimit) and the UI/abort.
* feat(core): extend max cost nudge state
* fix(core): clear stale message cost when value becomes non-finite
* test(core): add missing cost aggregation and session isolation tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Add a reusable core state machine for soft per-session max-cost nudges. The nudge tracks cumulative assistant message costs, alerts once a configured whole-dollar limit is crossed, and lets callers continue or stop without hard-blocking the running session.
Implementation
MaxCostNudgeunderpackages/core/src/kilocode/cost/.Screenshots / Video
N/A, core logic only.
How to Test
Manual/local verification
bun test ./test/kilocode/cost/max-cost-nudge.test.tsfrompackages/core/passed with 19 tests.Reviewer test steps
packages/core/, runbun test ./test/kilocode/cost/max-cost-nudge.test.ts.MaxCostNudgebehavior for limit normalization, cost aggregation, continue suppression, stop re-arm, and session cleanup.Checklist