statusNoticeHelpers.ts
1 import { roughTokenCountEstimation } from '../services/tokenEstimation.js' 2 import type { AgentDefinitionsResult } from '../tools/AgentTool/loadAgentsDir.js' 3 4 export const AGENT_DESCRIPTIONS_THRESHOLD = 15_000 5 6 /** 7 * Calculate cumulative token estimate for agent descriptions 8 */ 9 export function getAgentDescriptionsTotalTokens( 10 agentDefinitions?: AgentDefinitionsResult, 11 ): number { 12 if (!agentDefinitions) return 0 13 14 return agentDefinitions.activeAgents 15 .filter(a => a.source !== 'built-in') 16 .reduce((total, agent) => { 17 const description = `${agent.agentType}: ${agent.whenToUse}` 18 return total + roughTokenCountEstimation(description) 19 }, 0) 20 }