* Record the (name, args, result) of a just-executed call.
(name, args, result)
| 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) { |
no test coverage detected