MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / pruneAtBoundary

Function pruneAtBoundary

test/mcp-and-pruning.test.ts:71–83  ·  view source on GitHub ↗
(
    messages: Array<{ role: string; content: string | null }>,
    droppedGroupsCount: number,
  )

Source from the content-addressed store, hash-verified

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 = [

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected