Repository navigation
feat(chat): ask before a job the remaining AI limit covers only in part (W2-03) - #1994
Merged
Merged
Conversation
…-09) Each / menu shortcut (CHAT-08) now has a hidden playbook in skills/ (metadata.hidden: "true"): its allowed reads, default scope, output, question rules and next moves, checked by the same format, scan and CI as the library skills. The menu gains /start, /optimize, /opportunities and /audit; "Create a report on" moves to /new-report, as /report is the Weekly report skill's. The composer sends shortcutId with the message while its trigger words stay (rewritten, it drops), and keeps it on Retry. Home chips whose job is a shortcut's send its id; chips for the focus areas' skills ask with the skill's /name. The server takes the id only for a message that is still that shortcut's, writes chat_messages.shortcut_id, loads the playbook first as one of the run's three skill bodies, offers only the reads in its data plan, and tells the model in one line what the plan leaves out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rt (W2-03)
Before work in several like parts (drafts, pages, tasks), the model calls
the engine's plan_parts with how many; the server counts how many the AI
limit left covers (fitChatUnits and POST /api/internal/chat/budget/fit,
each part one write step's worst case, an agent run's own cap included):
a count, never dollars.
All covered, the work goes on. None, the run pauses at the AI limit as
before. Some, a question card asks "Your remaining AI limit covers about
{k} of the {n} ...": Do the first {k} now (Recommended), Get more AI
credits (pauses at the limit) or Cancel (stops). With no one there (an
agent's or a scheduled run), the first {k} are done and filed and the run
stops at the AI limit as it ends. A skill's run is checked as it starts,
before anything is read. Nothing is checked on the workspace's own key.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 of 13 tasks
Contributor
|
One issue: every new cap path calls |
…heck hits
The fit check (fitChatUnits) took the smaller of what is left of the
month's AI limit and what an agent run's own cap leaves, but only returned
the count. The engine then paused every new cap path (a skill's run that
can't start, a job none of whose parts fit, Get more AI credits, and the
parts done with no one there) at the month's limit. For a triggered run
stopped by its own cap, the agent driver read capHit 'month' and paused
the whole agent until the month resets instead of ending the run as
"Stopped at its limit".
The server now returns which limit binds ('run' when the run's cap leaves
no more than the month, as reserveChatStep's run_cap), the route passes it
on, and the web client reads it (the month's when absent). The engine
pauses with that limit, keeping it on the parts card and on limitStop, as
modelStep already does for run_cap refusals.
# Conflicts: # help/chat/chat.md # server/src/lib/chat-budget.test.js # server/src/routes/internal-chat-budget.js # server/src/routes/internal-chat-budget.test.js # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
gkhngyk
approved these changes
Nov 2, 2026
cihan-gyk
added a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 4, 2026
…2003, already in this branch)
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.
Summary
CHAT-04 item 17a: before a job in several like parts, Chat checks that the remaining AI limit covers all of them, and asks first when it covers only some. Behind
CHAT_AGENTIC. Stacked on #1993 (feature/chat-shortcut-playbooks): merge it first. Until then, this PR's diff also shows W2-09's commit. No migration. Plan: Chat waves plan, W2-03.Server
fitChatUnits(orgId, { modelId, perUnit, units, ownKey, agentRunId })inchat-budget.jscounts how many of the job's parts the AI budget left covers. Each part is sized as one write step's worst case (stepWorstCaseUsd).POST /api/internal/chat/budget/fit(Zod: 1–100 parts).Engine
plan_parts, offered while writing. Before work in several like parts (drafts, pages, tasks), the model calls it once with how many parts (2–50) and what they are.paused_cap).lib/chat/partial-limit.ts;engine.tsonly gets thin hooks. The card is the existing question card, with new words inen.json.Help:
help/chat/chat.mdgets "When only part of a job fits" (stillapproved: false).Related issue
None. Chat waves plan, W2-03 (CHAT-04 item 17a).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Unit tests:
chat-budget.test.js(fitChatUnits: room, purchased credits, an agent run's cap, own key) andinternal-chat-budget.test.js(/fit).partial-limit.test.ts,budget.test.ts, andengine.test.ts:Manually (
CHAT_AGENTIC=true, web and API server running, a cloud workspace whose remaining AI limit covers only a few write steps):/report: the run pauses at the AI limit before any step reads data.Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (9bdd514), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41411448922): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code