Skip to content

Commit 4e4826b

Browse files
committed
fix: cap section budget to per-section share of remaining lines
1 parent 890fcd3 commit 4e4826b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/agent/prompts/optional/budget.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ function remainingLines(overheadLines?: number): number {
1717
/** Scale max lines based on enabled section count and available remaining space. */
1818
export function maxLines(min: number, max: number, sectionCount?: number, overheadLines?: number): number {
1919
const remaining = remainingLines(overheadLines)
20+
const sections = Math.max(1, sectionCount ?? 1)
21+
const perSection = Math.floor(remaining / sections)
2022
const scale = budgetScale(sectionCount)
21-
return Math.max(min, Math.min(Math.round(max * scale), remaining))
23+
return Math.max(min, Math.min(Math.round(max * scale), perSection))
2224
}
2325

2426
/** Scale item count based on enabled section count. */

0 commit comments

Comments
 (0)