| 58 | } |
| 59 | |
| 60 | std::string ToolMemory::lookup(const std::vector<std::string> & call_ids) { |
| 61 | std::string result_text; |
| 62 | bool first = true; |
| 63 | |
| 64 | for (const auto & id : call_ids) { |
| 65 | if (id.empty()) return ""; |
| 66 | auto it = by_id_.find(id); |
| 67 | if (it == by_id_.end()) return ""; |
| 68 | |
| 69 | if (first) { |
| 70 | result_text = it->second; |
| 71 | first = false; |
| 72 | } else if (result_text != it->second) { |
| 73 | return ""; // different blocks — can't replay |
| 74 | } |
| 75 | touch(id); |
| 76 | } |
| 77 | |
| 78 | return result_text; |
| 79 | } |
| 80 | |
| 81 | void ToolMemory::touch(const std::string & call_id) { |
| 82 | auto it = lru_map_.find(call_id); |