(
messages: Array<{ role: string; content: string | null }>,
droppedGroupsCount: number,
)
| 69 | |
| 70 | // Inline copy of the logic (the real method is private to AgentLoop) |
| 71 | function pruneAtBoundary( |
| 72 | messages: Array<{ role: string; content: string | null }>, |
| 73 | droppedGroupsCount: number, |
| 74 | ): Array<{ role: string; content: string | null }> { |
| 75 | const notice = `[CONTEXT_COMPACTED] ${droppedGroupsCount} earlier turn(s) omitted.\n\n---\n\n`; |
| 76 | const flat = messages.slice(); |
| 77 | const first = flat[0]; |
| 78 | if (first?.role === 'user' && typeof first.content === 'string') { |
| 79 | flat[0] = { ...first, content: notice + first.content }; |
| 80 | return flat; |
| 81 | } |
| 82 | return [{ role: 'user', content: notice }, ...flat]; |
| 83 | } |
| 84 | |
| 85 | it('merges notice into the first user message without creating duplicates', () => { |
| 86 | const input = [ |
no outgoing calls
no test coverage detected