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

Function pruneToolErrors

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

Source from the content-addressed store, hash-verified

126}
127
128const pruneToolErrors = (state: SessionState, logger: Logger, messages: WithParts[]): void => {
129 for (const msg of messages) {
130 if (isMessageCompacted(state, msg)) {
131 continue
132 }
133
134 const parts = Array.isArray(msg.parts) ? msg.parts : []
135 for (const part of parts) {
136 if (part.type !== "tool") {
137 continue
138 }
139 if (!state.prune.tools.has(part.callID)) {
140 continue
141 }
142 if (part.state.status !== "error") {
143 continue
144 }
145
146 // Prune all string inputs for errored tools
147 const input = part.state.input
148 if (input && typeof input === "object") {
149 for (const key of Object.keys(input)) {
150 if (typeof input[key] === "string") {
151 input[key] = PRUNED_TOOL_ERROR_INPUT_REPLACEMENT
152 }
153 }
154 }
155 }
156 }
157}
158
159const filterCompressedRanges = (
160 state: SessionState,

Callers 1

pruneFunction · 0.85

Calls 1

isMessageCompactedFunction · 0.90

Tested by

no test coverage detected