@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
10 lines • 802 B
JavaScript
import { estimateContextTokens } from "@earendil-works/pi-ai/utils/estimate";
import { CLAUDE_SAFETY_MARGIN_TOKENS } from "../compaction/claude-safety-margin.js";
import { coldSeedCalibration, estimateColdSeedTokens } from "./cold-seed-budget.js";
/** Budget a fallback without scaling already billed usage by the cold-seed ratio. */
export function estimateLongContextFallbackTokens(context, blocks, sessionId) {
const usage = estimateContextTokens(context.messages);
const calibration = coldSeedCalibration(sessionId);
return (Math.max(usage.usageTokens + Math.ceil(usage.trailingTokens * calibration), Math.ceil(estimateColdSeedTokens(context, blocks) * calibration)) + (usage.lastUsageIndex === null ? CLAUDE_SAFETY_MARGIN_TOKENS : 0));
}
//# sourceMappingURL=long-context-budget.js.map