()
| 2109 | // Get plugin prompt injections for the current task type |
| 2110 | // Fix #17: Cap plugin injection to ~500 tokens (2000 chars). |
| 2111 | function getPluginPrompts() { |
| 2112 | if (!pluginLoader) return ''; |
| 2113 | try { |
| 2114 | const injection = pluginLoader.getPromptInjections(currentTaskType); |
| 2115 | if (!injection) return ''; |
| 2116 | // Hard cap: a single misconfigured plugin with 10k content shouldn't |
| 2117 | // blow up the system prompt. |
| 2118 | const capped = injection.length > 2000 |
| 2119 | ? injection.slice(0, 2000) + '\n... (plugin prompts truncated)' |
| 2120 | : injection; |
| 2121 | return '\n\n' + capped; |
| 2122 | } catch { |
| 2123 | return ''; |
| 2124 | } |
| 2125 | } |
| 2126 | |
| 2127 | // Make a chat completion request (non-streaming for tool use, streaming for final response) |
| 2128 | async function chatCompletion(config, messages) { |
no test coverage detected