( data: ContextData, suggestions: ContextSuggestion[], )
| 68 | } |
| 69 | |
| 70 | function checkLargeToolResults( |
| 71 | data: ContextData, |
| 72 | suggestions: ContextSuggestion[], |
| 73 | ): void { |
| 74 | if (!data.messageBreakdown) return |
| 75 | |
| 76 | for (const tool of data.messageBreakdown.toolCallsByType) { |
| 77 | const totalToolTokens = tool.callTokens + tool.resultTokens |
| 78 | const percent = (totalToolTokens / data.rawMaxTokens) * 100 |
| 79 | |
| 80 | if ( |
| 81 | percent < LARGE_TOOL_RESULT_PERCENT || |
| 82 | totalToolTokens < LARGE_TOOL_RESULT_TOKENS |
| 83 | ) { |
| 84 | continue |
| 85 | } |
| 86 | |
| 87 | const suggestion = getLargeToolSuggestion( |
| 88 | tool.name, |
| 89 | totalToolTokens, |
| 90 | percent, |
| 91 | ) |
| 92 | if (suggestion) { |
| 93 | suggestions.push(suggestion) |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | function getLargeToolSuggestion( |
| 99 | toolName: string, |
no test coverage detected