(messages)
| 2090 | // Fix #18: Cap skill injection to ~1000 tokens (4000 chars). Multiple matching |
| 2091 | // skills can each be a full .md file, quickly blowing up the system prompt. |
| 2092 | function getSkillContext(messages) { |
| 2093 | if (!skillManager) return ''; |
| 2094 | try { |
| 2095 | const lastUser = [...messages].reverse().find(m => m.role === 'user'); |
| 2096 | if (!lastUser) return ''; |
| 2097 | const skills = skillManager.getAutoSkills(lastUser.content); |
| 2098 | if (skills.length === 0) return ''; |
| 2099 | const formatted = skillManager.formatForPrompt(skills); |
| 2100 | // Hard cap: truncate if too long |
| 2101 | return formatted.length > 4000 |
| 2102 | ? formatted.slice(0, 4000) + '\n... (skills truncated to fit context)' |
| 2103 | : formatted; |
| 2104 | } catch { |
| 2105 | return ''; |
| 2106 | } |
| 2107 | } |
| 2108 | |
| 2109 | // Get plugin prompt injections for the current task type |
| 2110 | // Fix #17: Cap plugin injection to ~500 tokens (2000 chars). |
no test coverage detected