feat(x): graceful wrap-up when a chat turn hits its model-call limit

Interactive turns no longer die with a raw 'Model call limit of N
reached' error. The final budgeted model call is composed as a wrap-up:
the durable request records wrapUp: true, and the composer strips tools
and appends a notice telling the model to answer with what it has,
state what's unfinished, and mention the limit is configurable in
Settings -> Advanced. The turn then completes normally with that answer.

Headless turns (and a wrap-up call that still emits tool calls) keep
the hard model-call-limit failure so automation retains the
machine-readable outcome; sub-agents already surface partial results.
If a hard limit failure still reaches the chat UI, the error bubble now
explains the limit and points at the setting instead of the raw error.
This commit is contained in:
Gagan 2026-07-21 15:50:04 +05:30
parent 47453fc333
commit f270f39e35
6 changed files with 129 additions and 2 deletions

View file

@ -519,6 +519,13 @@ Rules:
the global limit. Without a resolver (tests) it defaults to `20`. Spawned
sub-agents default to the global limit, which also caps the budget a
parent may grant them. Settings changes affect only newly created turns.
- Budget exhaustion (§20): interactive turns (`humanAvailable: true`) spend
their final budgeted call wrapping up — the request records `wrapUp: true`,
and the composer strips tools and appends the shared `wrapUpNotice`, so
the turn completes with a real answer that admits what's unfinished.
Headless turns (and a wrap-up call that still emits tool calls) keep the
hard `turn_failed` with `model-call-limit` — automation needs the
machine-readable outcome.
- Persisted values are fully resolved and immutable.
The capability is named `humanAvailable`, not `headless`. `headless` describes