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

Function pruneToolInputs

lib/messages/prune.ts:99–126  ·  view source on GitHub ↗
(state: SessionState, logger: Logger, messages: WithParts[])

Source from the content-addressed store, hash-verified

97}
98
99const pruneToolInputs = (state: SessionState, logger: Logger, messages: WithParts[]): void => {
100 for (const msg of messages) {
101 if (isMessageCompacted(state, msg)) {
102 continue
103 }
104
105 const parts = Array.isArray(msg.parts) ? msg.parts : []
106 for (const part of parts) {
107 if (part.type !== "tool") {
108 continue
109 }
110
111 if (!state.prune.tools.has(part.callID)) {
112 continue
113 }
114 if (part.state.status !== "completed") {
115 continue
116 }
117 if (part.tool !== "question") {
118 continue
119 }
120
121 if (part.state.input?.questions !== undefined) {
122 part.state.input.questions = PRUNED_QUESTION_INPUT_REPLACEMENT
123 }
124 }
125 }
126}
127
128const pruneToolErrors = (state: SessionState, logger: Logger, messages: WithParts[]): void => {
129 for (const msg of messages) {

Callers 1

pruneFunction · 0.85

Calls 1

isMessageCompactedFunction · 0.90

Tested by

no test coverage detected