MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / execute

Function execute

lib/compress/message.ts:48–143  ·  view source on GitHub ↗
(args, toolCtx)

Source from the content-addressed store, hash-verified

46 description: runtimePrompts.compressMessage + MESSAGE_FORMAT_EXTENSION,
47 args: buildSchema(),
48 async execute(args, toolCtx) {
49 const input = args as CompressMessageToolArgs
50 validateArgs(input)
51 const callId =
52 typeof (toolCtx as unknown as { callID?: unknown }).callID === "string"
53 ? (toolCtx as unknown as { callID: string }).callID
54 : undefined
55
56 const { rawMessages, searchContext } = await prepareSession(
57 ctx,
58 toolCtx,
59 `Compress Message: ${input.topic}`,
60 )
61 const { plans, skippedIssues, skippedCount } = resolveMessages(
62 input,
63 searchContext,
64 ctx.state,
65 ctx.config,
66 )
67
68 if (plans.length === 0 && skippedCount > 0) {
69 throw new Error(formatIssues(skippedIssues, skippedCount))
70 }
71
72 const notifications: NotificationEntry[] = []
73
74 const preparedPlans: Array<{
75 plan: (typeof plans)[number]
76 summaryWithTools: string
77 }> = []
78
79 for (const plan of plans) {
80 const summaryWithPromptInfo = appendProtectedPromptInfo(
81 plan.entry.summary,
82 plan.selection,
83 searchContext,
84 ctx.state,
85 ctx.config.compress.protectTags,
86 )
87
88 const summaryWithTools = await appendProtectedTools(
89 ctx.client,
90 ctx.state,
91 ctx.config.experimental.allowSubAgents,
92 summaryWithPromptInfo,
93 plan.selection,
94 searchContext,
95 ctx.config.compress.protectedTools,
96 ctx.config.protectedFilePatterns,
97 )
98
99 preparedPlans.push({
100 plan,
101 summaryWithTools,
102 })
103 }
104
105 const runId = allocateRunId(ctx.state)

Callers

nothing calls this directly

Calls 13

validateArgsFunction · 0.90
prepareSessionFunction · 0.90
resolveMessagesFunction · 0.90
formatIssuesFunction · 0.90
appendProtectedToolsFunction · 0.90
allocateRunIdFunction · 0.90
allocateBlockIdFunction · 0.90
wrapCompressedSummaryFunction · 0.90
countTokensFunction · 0.90
applyCompressionStateFunction · 0.90
finalizeSessionFunction · 0.90

Tested by

no test coverage detected