MCPcopy
hub / github.com/Doorman11991/smallcode / record

Method record

src/tools/dedup.js:111–121  ·  view source on GitHub ↗

* Record the (name, args, result) of a just-executed call.

(name, args, result)

Source from the content-addressed store, hash-verified

109 * Record the (name, args, result) of a just-executed call.
110 */
111 record(name, args, result) {
112 if (this.disabled) return;
113 if (!PURE_TOOLS.has(name)) return;
114 // Don't cache errors — the model should be allowed to retry
115 if (result && result.error) return;
116 const h = this._hash(name, args);
117 // Move-to-front: drop existing entry with same hash, push fresh
118 this.recent = this.recent.filter(r => r.hash !== h);
119 this.recent.push({ hash: h, name, result, ts: Date.now() });
120 while (this.recent.length > this.windowSize) this.recent.shift();
121 }
122
123 /** Wrap a result with a [cached] marker so the model knows it's a hit. */
124 static markCached(result) {

Callers 6

executeToolFunction · 0.45
runAgentLoopFunction · 0.45
chatCompletionFunction · 0.45
chatCompletionFunction · 0.45
executeToolFunction · 0.45

Calls 2

_hashMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected