/** * Assembling a system prompt to a size, rather than to whatever it happens to add up to. * * "Why still there's a limit?" — because the tool list was the part that had been measured, and it * was not the part that mattered. In a real project the overhead was 4,166 tokens against a * 4,096-token window even after the tools were cut from 2.3k to 0.6k: the instructions came to * 1.3k, and 720 tokens of framework guidance had been appended automatically because the project * happens to be Next.js. Nobody asked for that, and on a small window it is a fifth of everything * the model will ever see. * * A prompt built by concatenating whatever applies has no size — it has a size that emerges. Here * the sections are declared with a priority, a budget is given, and what does not fit is dropped * from the least important end and reported. On a large window the budget is not reached and * nothing is dropped, which is the normal case and must stay untouched. */ export interface PromptSection { /** Shown when reporting what was dropped. */ name: string; text: string; /** * Lower goes in first. Identity and the rules that prevent harm are 0; guidance that only * improves style is last. */ priority: number; /** Never dropped, whatever the budget. */ essential?: boolean; /** * Cut to this many characters rather than dropped outright, when it does not fit. * * For sections where a part is worth more than nothing — a project's first lines say what it is * even when the rest will not fit. */ truncateTo?: number; } export interface Assembled { text: string; /** Sections left out entirely. */ dropped: string[]; /** Sections included but cut short. */ truncated: string[]; tokens: number; } /** * The sections that fit, in the order they were given. * * Essential sections go in whatever the cost — a prompt without its identity or its safety rules * is worse than a prompt that is too long. Everything else is taken in priority order while there * is room, and a section with `truncateTo` is cut rather than lost when only part of it fits. */ export declare function assembleWithinBudget(sections: readonly PromptSection[], budgetTokens: number): Assembled; /** What the user is told when part of the prompt did not fit. */ export declare function budgetNotice(result: Assembled, budgetTokens: number): string; //# sourceMappingURL=prompt-budget.d.ts.map