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

Method lookup

src/tools/dedup.js:93–106  ·  view source on GitHub ↗

* Check whether (name, args) was just executed. Returns the cached result * or null. Only deduplicates pure tools.

(name, args)

Source from the content-addressed store, hash-verified

91 * or null. Only deduplicates pure tools.
92 */
93 lookup(name, args) {
94 if (this.disabled) return null;
95 if (!PURE_TOOLS.has(name)) return null;
96 const h = this._hash(name, args);
97 for (let i = this.recent.length - 1; i >= 0; i--) {
98 if (this.recent[i].hash === h) {
99 this.hits++;
100 // Return a shallow copy so callers can't mutate the cached entry
101 return { ...this.recent[i].result };
102 }
103 }
104 this.misses++;
105 return null;
106 }
107
108 /**
109 * Record the (name, args, result) of a just-executed call.

Callers 1

executeToolFunction · 0.80

Calls 2

_hashMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected