rowboat/apps/x/packages/shared/src/turn-limits.ts
Gagan dd04738015 feat(x): raise model-call limit cap to 500, polish limit stepper UI
Validation range is now 1-500. The Advanced tab's native number inputs
are replaced with a segmented minus/value/plus stepper (custom buttons,
digits-only typing, range clamping, immediate save on step). The chat
override gets a smaller placeholder, steps from the effective global
limit when empty, and has a clear button to fall back to the global
limit.
2026-07-21 15:29:11 +05:30

34 lines
1.1 KiB
TypeScript

import { z } from 'zod';
import { DEFAULT_MAX_MODEL_CALLS } from './turns.js';
/**
* User-configurable model-call budgets (see issue #768).
*
* - maxModelCalls: the global limit every turn inherits by default,
* including headless/knowledge work and spawned sub-agents (it is also
* the cap a parent can grant a sub-agent).
* - chatMaxModelCalls: optional override for interactive chat turns only;
* when absent, chat uses the global limit.
*
* Changing these affects only newly created turns — each turn persists its
* resolved limit in turn_created.config.maxModelCalls.
*/
export const MIN_MODEL_CALL_LIMIT = 1;
export const MAX_MODEL_CALL_LIMIT = 500;
const limit = z
.number()
.int()
.min(MIN_MODEL_CALL_LIMIT)
.max(MAX_MODEL_CALL_LIMIT);
export const TurnLimitsSettingsSchema = z.object({
maxModelCalls: limit,
chatMaxModelCalls: limit.optional(),
});
export const DEFAULT_TURN_LIMITS_SETTINGS: TurnLimitsSettings = {
maxModelCalls: DEFAULT_MAX_MODEL_CALLS,
};
export type TurnLimitsSettings = z.infer<typeof TurnLimitsSettingsSchema>;