@miller-tech/uap 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (660) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +888 -0
  3. package/dist/analyzers/index.d.ts +3 -0
  4. package/dist/analyzers/index.d.ts.map +1 -0
  5. package/dist/analyzers/index.js +684 -0
  6. package/dist/analyzers/index.js.map +1 -0
  7. package/dist/benchmarks/agents/naive-agent.d.ts +60 -0
  8. package/dist/benchmarks/agents/naive-agent.d.ts.map +1 -0
  9. package/dist/benchmarks/agents/naive-agent.js +144 -0
  10. package/dist/benchmarks/agents/naive-agent.js.map +1 -0
  11. package/dist/benchmarks/agents/uap-agent.d.ts +167 -0
  12. package/dist/benchmarks/agents/uap-agent.d.ts.map +1 -0
  13. package/dist/benchmarks/agents/uap-agent.js +437 -0
  14. package/dist/benchmarks/agents/uap-agent.js.map +1 -0
  15. package/dist/benchmarks/benchmark.d.ts +328 -0
  16. package/dist/benchmarks/benchmark.d.ts.map +1 -0
  17. package/dist/benchmarks/benchmark.js +112 -0
  18. package/dist/benchmarks/benchmark.js.map +1 -0
  19. package/dist/benchmarks/execution-verifier.d.ts +41 -0
  20. package/dist/benchmarks/execution-verifier.d.ts.map +1 -0
  21. package/dist/benchmarks/execution-verifier.js +340 -0
  22. package/dist/benchmarks/execution-verifier.js.map +1 -0
  23. package/dist/benchmarks/hierarchical-prompting.d.ts +37 -0
  24. package/dist/benchmarks/hierarchical-prompting.d.ts.map +1 -0
  25. package/dist/benchmarks/hierarchical-prompting.js +246 -0
  26. package/dist/benchmarks/hierarchical-prompting.js.map +1 -0
  27. package/dist/benchmarks/improved-benchmark.d.ts +89 -0
  28. package/dist/benchmarks/improved-benchmark.d.ts.map +1 -0
  29. package/dist/benchmarks/improved-benchmark.js +585 -0
  30. package/dist/benchmarks/improved-benchmark.js.map +1 -0
  31. package/dist/benchmarks/index.d.ts +11 -0
  32. package/dist/benchmarks/index.d.ts.map +1 -0
  33. package/dist/benchmarks/index.js +11 -0
  34. package/dist/benchmarks/index.js.map +1 -0
  35. package/dist/benchmarks/model-integration.d.ts +111 -0
  36. package/dist/benchmarks/model-integration.d.ts.map +1 -0
  37. package/dist/benchmarks/model-integration.js +904 -0
  38. package/dist/benchmarks/model-integration.js.map +1 -0
  39. package/dist/benchmarks/multi-turn-agent.d.ts +44 -0
  40. package/dist/benchmarks/multi-turn-agent.d.ts.map +1 -0
  41. package/dist/benchmarks/multi-turn-agent.js +254 -0
  42. package/dist/benchmarks/multi-turn-agent.js.map +1 -0
  43. package/dist/benchmarks/multi-turn-loop.d.ts +57 -0
  44. package/dist/benchmarks/multi-turn-loop.d.ts.map +1 -0
  45. package/dist/benchmarks/multi-turn-loop.js +167 -0
  46. package/dist/benchmarks/multi-turn-loop.js.map +1 -0
  47. package/dist/benchmarks/tasks.d.ts +19 -0
  48. package/dist/benchmarks/tasks.d.ts.map +1 -0
  49. package/dist/benchmarks/tasks.js +435 -0
  50. package/dist/benchmarks/tasks.js.map +1 -0
  51. package/dist/bin/cli.d.ts +3 -0
  52. package/dist/bin/cli.d.ts.map +1 -0
  53. package/dist/bin/cli.js +546 -0
  54. package/dist/bin/cli.js.map +1 -0
  55. package/dist/bin/llama-server-optimize.d.ts +18 -0
  56. package/dist/bin/llama-server-optimize.d.ts.map +1 -0
  57. package/dist/bin/llama-server-optimize.js +708 -0
  58. package/dist/bin/llama-server-optimize.js.map +1 -0
  59. package/dist/bin/policy.d.ts +3 -0
  60. package/dist/bin/policy.d.ts.map +1 -0
  61. package/dist/bin/policy.js +143 -0
  62. package/dist/bin/policy.js.map +1 -0
  63. package/dist/bin/tool-calls.d.ts +3 -0
  64. package/dist/bin/tool-calls.d.ts.map +1 -0
  65. package/dist/bin/tool-calls.js +4 -0
  66. package/dist/bin/tool-calls.js.map +1 -0
  67. package/dist/browser/index.d.ts +2 -0
  68. package/dist/browser/index.d.ts.map +1 -0
  69. package/dist/browser/index.js +2 -0
  70. package/dist/browser/index.js.map +1 -0
  71. package/dist/browser/web-browser.d.ts +30 -0
  72. package/dist/browser/web-browser.d.ts.map +1 -0
  73. package/dist/browser/web-browser.js +93 -0
  74. package/dist/browser/web-browser.js.map +1 -0
  75. package/dist/cli/agent.d.ts +20 -0
  76. package/dist/cli/agent.d.ts.map +1 -0
  77. package/dist/cli/agent.js +474 -0
  78. package/dist/cli/agent.js.map +1 -0
  79. package/dist/cli/analyze.d.ts +7 -0
  80. package/dist/cli/analyze.d.ts.map +1 -0
  81. package/dist/cli/analyze.js +103 -0
  82. package/dist/cli/analyze.js.map +1 -0
  83. package/dist/cli/completion-gates.d.ts +51 -0
  84. package/dist/cli/completion-gates.d.ts.map +1 -0
  85. package/dist/cli/completion-gates.js +201 -0
  86. package/dist/cli/completion-gates.js.map +1 -0
  87. package/dist/cli/compliance.d.ts +8 -0
  88. package/dist/cli/compliance.d.ts.map +1 -0
  89. package/dist/cli/compliance.js +509 -0
  90. package/dist/cli/compliance.js.map +1 -0
  91. package/dist/cli/coord.d.ts +7 -0
  92. package/dist/cli/coord.d.ts.map +1 -0
  93. package/dist/cli/coord.js +138 -0
  94. package/dist/cli/coord.js.map +1 -0
  95. package/dist/cli/dashboard.d.ts +21 -0
  96. package/dist/cli/dashboard.d.ts.map +1 -0
  97. package/dist/cli/dashboard.js +1508 -0
  98. package/dist/cli/dashboard.js.map +1 -0
  99. package/dist/cli/deploy.d.ts +19 -0
  100. package/dist/cli/deploy.d.ts.map +1 -0
  101. package/dist/cli/deploy.js +387 -0
  102. package/dist/cli/deploy.js.map +1 -0
  103. package/dist/cli/droids.d.ts +9 -0
  104. package/dist/cli/droids.d.ts.map +1 -0
  105. package/dist/cli/droids.js +227 -0
  106. package/dist/cli/droids.js.map +1 -0
  107. package/dist/cli/generate.d.ts +17 -0
  108. package/dist/cli/generate.d.ts.map +1 -0
  109. package/dist/cli/generate.js +432 -0
  110. package/dist/cli/generate.js.map +1 -0
  111. package/dist/cli/hooks.d.ts +9 -0
  112. package/dist/cli/hooks.d.ts.map +1 -0
  113. package/dist/cli/hooks.js +464 -0
  114. package/dist/cli/hooks.js.map +1 -0
  115. package/dist/cli/init.d.ts +12 -0
  116. package/dist/cli/init.d.ts.map +1 -0
  117. package/dist/cli/init.js +364 -0
  118. package/dist/cli/init.js.map +1 -0
  119. package/dist/cli/mcp-router.d.ts +16 -0
  120. package/dist/cli/mcp-router.d.ts.map +1 -0
  121. package/dist/cli/mcp-router.js +143 -0
  122. package/dist/cli/mcp-router.js.map +1 -0
  123. package/dist/cli/memory.d.ts +24 -0
  124. package/dist/cli/memory.d.ts.map +1 -0
  125. package/dist/cli/memory.js +885 -0
  126. package/dist/cli/memory.js.map +1 -0
  127. package/dist/cli/model.d.ts +15 -0
  128. package/dist/cli/model.d.ts.map +1 -0
  129. package/dist/cli/model.js +290 -0
  130. package/dist/cli/model.js.map +1 -0
  131. package/dist/cli/patterns.d.ts +26 -0
  132. package/dist/cli/patterns.d.ts.map +1 -0
  133. package/dist/cli/patterns.js +862 -0
  134. package/dist/cli/patterns.js.map +1 -0
  135. package/dist/cli/rtk-validation.d.ts +9 -0
  136. package/dist/cli/rtk-validation.d.ts.map +1 -0
  137. package/dist/cli/rtk-validation.js +9 -0
  138. package/dist/cli/rtk-validation.js.map +1 -0
  139. package/dist/cli/rtk.d.ts +34 -0
  140. package/dist/cli/rtk.d.ts.map +1 -0
  141. package/dist/cli/rtk.js +401 -0
  142. package/dist/cli/rtk.js.map +1 -0
  143. package/dist/cli/schema-diff.d.ts +7 -0
  144. package/dist/cli/schema-diff.d.ts.map +1 -0
  145. package/dist/cli/schema-diff.js +11 -0
  146. package/dist/cli/schema-diff.js.map +1 -0
  147. package/dist/cli/setup-mcp-router.d.ts +8 -0
  148. package/dist/cli/setup-mcp-router.d.ts.map +1 -0
  149. package/dist/cli/setup-mcp-router.js +163 -0
  150. package/dist/cli/setup-mcp-router.js.map +1 -0
  151. package/dist/cli/setup-wizard.d.ts +2 -0
  152. package/dist/cli/setup-wizard.d.ts.map +1 -0
  153. package/dist/cli/setup-wizard.js +806 -0
  154. package/dist/cli/setup-wizard.js.map +1 -0
  155. package/dist/cli/setup.d.ts +15 -0
  156. package/dist/cli/setup.d.ts.map +1 -0
  157. package/dist/cli/setup.js +154 -0
  158. package/dist/cli/setup.js.map +1 -0
  159. package/dist/cli/sync.d.ts +8 -0
  160. package/dist/cli/sync.d.ts.map +1 -0
  161. package/dist/cli/sync.js +395 -0
  162. package/dist/cli/sync.js.map +1 -0
  163. package/dist/cli/task.d.ts +33 -0
  164. package/dist/cli/task.d.ts.map +1 -0
  165. package/dist/cli/task.js +672 -0
  166. package/dist/cli/task.js.map +1 -0
  167. package/dist/cli/tool-calls.d.ts +20 -0
  168. package/dist/cli/tool-calls.d.ts.map +1 -0
  169. package/dist/cli/tool-calls.js +605 -0
  170. package/dist/cli/tool-calls.js.map +1 -0
  171. package/dist/cli/uap.d.ts +10 -0
  172. package/dist/cli/uap.d.ts.map +1 -0
  173. package/dist/cli/uap.js +398 -0
  174. package/dist/cli/uap.js.map +1 -0
  175. package/dist/cli/update.d.ts +10 -0
  176. package/dist/cli/update.d.ts.map +1 -0
  177. package/dist/cli/update.js +300 -0
  178. package/dist/cli/update.js.map +1 -0
  179. package/dist/cli/visualize.d.ts +77 -0
  180. package/dist/cli/visualize.d.ts.map +1 -0
  181. package/dist/cli/visualize.js +287 -0
  182. package/dist/cli/visualize.js.map +1 -0
  183. package/dist/cli/worktree.d.ts +9 -0
  184. package/dist/cli/worktree.d.ts.map +1 -0
  185. package/dist/cli/worktree.js +213 -0
  186. package/dist/cli/worktree.js.map +1 -0
  187. package/dist/coordination/adaptive-patterns.d.ts +65 -0
  188. package/dist/coordination/adaptive-patterns.d.ts.map +1 -0
  189. package/dist/coordination/adaptive-patterns.js +108 -0
  190. package/dist/coordination/adaptive-patterns.js.map +1 -0
  191. package/dist/coordination/auto-agent.d.ts +82 -0
  192. package/dist/coordination/auto-agent.d.ts.map +1 -0
  193. package/dist/coordination/auto-agent.js +145 -0
  194. package/dist/coordination/auto-agent.js.map +1 -0
  195. package/dist/coordination/capability-router.d.ts +79 -0
  196. package/dist/coordination/capability-router.d.ts.map +1 -0
  197. package/dist/coordination/capability-router.js +334 -0
  198. package/dist/coordination/capability-router.js.map +1 -0
  199. package/dist/coordination/database.d.ts +13 -0
  200. package/dist/coordination/database.d.ts.map +1 -0
  201. package/dist/coordination/database.js +136 -0
  202. package/dist/coordination/database.js.map +1 -0
  203. package/dist/coordination/deploy-batcher.d.ts +122 -0
  204. package/dist/coordination/deploy-batcher.d.ts.map +1 -0
  205. package/dist/coordination/deploy-batcher.js +718 -0
  206. package/dist/coordination/deploy-batcher.js.map +1 -0
  207. package/dist/coordination/droid-validator.d.ts +59 -0
  208. package/dist/coordination/droid-validator.d.ts.map +1 -0
  209. package/dist/coordination/droid-validator.js +142 -0
  210. package/dist/coordination/droid-validator.js.map +1 -0
  211. package/dist/coordination/index.d.ts +10 -0
  212. package/dist/coordination/index.d.ts.map +1 -0
  213. package/dist/coordination/index.js +10 -0
  214. package/dist/coordination/index.js.map +1 -0
  215. package/dist/coordination/pattern-router.d.ts +50 -0
  216. package/dist/coordination/pattern-router.d.ts.map +1 -0
  217. package/dist/coordination/pattern-router.js +118 -0
  218. package/dist/coordination/pattern-router.js.map +1 -0
  219. package/dist/coordination/service.d.ts +81 -0
  220. package/dist/coordination/service.d.ts.map +1 -0
  221. package/dist/coordination/service.js +619 -0
  222. package/dist/coordination/service.js.map +1 -0
  223. package/dist/coordination/worktree-enforcer.d.ts +22 -0
  224. package/dist/coordination/worktree-enforcer.d.ts.map +1 -0
  225. package/dist/coordination/worktree-enforcer.js +71 -0
  226. package/dist/coordination/worktree-enforcer.js.map +1 -0
  227. package/dist/generators/claude-md.d.ts +3 -0
  228. package/dist/generators/claude-md.d.ts.map +1 -0
  229. package/dist/generators/claude-md.js +1020 -0
  230. package/dist/generators/claude-md.js.map +1 -0
  231. package/dist/generators/template-loader.d.ts +105 -0
  232. package/dist/generators/template-loader.d.ts.map +1 -0
  233. package/dist/generators/template-loader.js +291 -0
  234. package/dist/generators/template-loader.js.map +1 -0
  235. package/dist/index.d.ts +49 -0
  236. package/dist/index.d.ts.map +1 -0
  237. package/dist/index.js +63 -0
  238. package/dist/index.js.map +1 -0
  239. package/dist/mcp-router/config/parser.d.ts +9 -0
  240. package/dist/mcp-router/config/parser.d.ts.map +1 -0
  241. package/dist/mcp-router/config/parser.js +174 -0
  242. package/dist/mcp-router/config/parser.js.map +1 -0
  243. package/dist/mcp-router/executor/client.d.ts +31 -0
  244. package/dist/mcp-router/executor/client.d.ts.map +1 -0
  245. package/dist/mcp-router/executor/client.js +189 -0
  246. package/dist/mcp-router/executor/client.js.map +1 -0
  247. package/dist/mcp-router/index.d.ts +22 -0
  248. package/dist/mcp-router/index.d.ts.map +1 -0
  249. package/dist/mcp-router/index.js +18 -0
  250. package/dist/mcp-router/index.js.map +1 -0
  251. package/dist/mcp-router/output-compressor.d.ts +26 -0
  252. package/dist/mcp-router/output-compressor.d.ts.map +1 -0
  253. package/dist/mcp-router/output-compressor.js +236 -0
  254. package/dist/mcp-router/output-compressor.js.map +1 -0
  255. package/dist/mcp-router/search/fuzzy.d.ts +26 -0
  256. package/dist/mcp-router/search/fuzzy.d.ts.map +1 -0
  257. package/dist/mcp-router/search/fuzzy.js +94 -0
  258. package/dist/mcp-router/search/fuzzy.js.map +1 -0
  259. package/dist/mcp-router/server.d.ts +50 -0
  260. package/dist/mcp-router/server.d.ts.map +1 -0
  261. package/dist/mcp-router/server.js +229 -0
  262. package/dist/mcp-router/server.js.map +1 -0
  263. package/dist/mcp-router/session-stats.d.ts +37 -0
  264. package/dist/mcp-router/session-stats.d.ts.map +1 -0
  265. package/dist/mcp-router/session-stats.js +56 -0
  266. package/dist/mcp-router/session-stats.js.map +1 -0
  267. package/dist/mcp-router/tools/discover.d.ts +37 -0
  268. package/dist/mcp-router/tools/discover.d.ts.map +1 -0
  269. package/dist/mcp-router/tools/discover.js +65 -0
  270. package/dist/mcp-router/tools/discover.js.map +1 -0
  271. package/dist/mcp-router/tools/execute.d.ts +43 -0
  272. package/dist/mcp-router/tools/execute.d.ts.map +1 -0
  273. package/dist/mcp-router/tools/execute.js +144 -0
  274. package/dist/mcp-router/tools/execute.js.map +1 -0
  275. package/dist/mcp-router/types.d.ts +62 -0
  276. package/dist/mcp-router/types.d.ts.map +1 -0
  277. package/dist/mcp-router/types.js +6 -0
  278. package/dist/mcp-router/types.js.map +1 -0
  279. package/dist/memory/adaptive-context.d.ts +149 -0
  280. package/dist/memory/adaptive-context.d.ts.map +1 -0
  281. package/dist/memory/adaptive-context.js +1095 -0
  282. package/dist/memory/adaptive-context.js.map +1 -0
  283. package/dist/memory/agent-scoped-memory.d.ts +67 -0
  284. package/dist/memory/agent-scoped-memory.d.ts.map +1 -0
  285. package/dist/memory/agent-scoped-memory.js +126 -0
  286. package/dist/memory/agent-scoped-memory.js.map +1 -0
  287. package/dist/memory/ambiguity-detector.d.ts +54 -0
  288. package/dist/memory/ambiguity-detector.d.ts.map +1 -0
  289. package/dist/memory/ambiguity-detector.js +401 -0
  290. package/dist/memory/ambiguity-detector.js.map +1 -0
  291. package/dist/memory/backends/base.d.ts +18 -0
  292. package/dist/memory/backends/base.d.ts.map +1 -0
  293. package/dist/memory/backends/base.js +2 -0
  294. package/dist/memory/backends/base.js.map +1 -0
  295. package/dist/memory/backends/factory.d.ts +4 -0
  296. package/dist/memory/backends/factory.d.ts.map +1 -0
  297. package/dist/memory/backends/factory.js +53 -0
  298. package/dist/memory/backends/factory.js.map +1 -0
  299. package/dist/memory/backends/github.d.ts +27 -0
  300. package/dist/memory/backends/github.d.ts.map +1 -0
  301. package/dist/memory/backends/github.js +134 -0
  302. package/dist/memory/backends/github.js.map +1 -0
  303. package/dist/memory/backends/qdrant-cloud.d.ts +32 -0
  304. package/dist/memory/backends/qdrant-cloud.d.ts.map +1 -0
  305. package/dist/memory/backends/qdrant-cloud.js +167 -0
  306. package/dist/memory/backends/qdrant-cloud.js.map +1 -0
  307. package/dist/memory/context-compressor.d.ts +116 -0
  308. package/dist/memory/context-compressor.d.ts.map +1 -0
  309. package/dist/memory/context-compressor.js +430 -0
  310. package/dist/memory/context-compressor.js.map +1 -0
  311. package/dist/memory/context-pruner.d.ts +55 -0
  312. package/dist/memory/context-pruner.d.ts.map +1 -0
  313. package/dist/memory/context-pruner.js +85 -0
  314. package/dist/memory/context-pruner.js.map +1 -0
  315. package/dist/memory/correction-propagator.d.ts +44 -0
  316. package/dist/memory/correction-propagator.d.ts.map +1 -0
  317. package/dist/memory/correction-propagator.js +156 -0
  318. package/dist/memory/correction-propagator.js.map +1 -0
  319. package/dist/memory/daily-log.d.ts +67 -0
  320. package/dist/memory/daily-log.d.ts.map +1 -0
  321. package/dist/memory/daily-log.js +143 -0
  322. package/dist/memory/daily-log.js.map +1 -0
  323. package/dist/memory/dynamic-retrieval.d.ts +112 -0
  324. package/dist/memory/dynamic-retrieval.d.ts.map +1 -0
  325. package/dist/memory/dynamic-retrieval.js +908 -0
  326. package/dist/memory/dynamic-retrieval.js.map +1 -0
  327. package/dist/memory/embeddings.d.ts +172 -0
  328. package/dist/memory/embeddings.d.ts.map +1 -0
  329. package/dist/memory/embeddings.js +780 -0
  330. package/dist/memory/embeddings.js.map +1 -0
  331. package/dist/memory/generic-uap-patterns.d.ts +7 -0
  332. package/dist/memory/generic-uap-patterns.d.ts.map +1 -0
  333. package/dist/memory/generic-uap-patterns.js +43 -0
  334. package/dist/memory/generic-uap-patterns.js.map +1 -0
  335. package/dist/memory/hierarchical-memory.d.ts +141 -0
  336. package/dist/memory/hierarchical-memory.d.ts.map +1 -0
  337. package/dist/memory/hierarchical-memory.js +485 -0
  338. package/dist/memory/hierarchical-memory.js.map +1 -0
  339. package/dist/memory/knowledge-graph.d.ts +98 -0
  340. package/dist/memory/knowledge-graph.d.ts.map +1 -0
  341. package/dist/memory/knowledge-graph.js +275 -0
  342. package/dist/memory/knowledge-graph.js.map +1 -0
  343. package/dist/memory/memory-consolidator.d.ts +124 -0
  344. package/dist/memory/memory-consolidator.d.ts.map +1 -0
  345. package/dist/memory/memory-consolidator.js +514 -0
  346. package/dist/memory/memory-consolidator.js.map +1 -0
  347. package/dist/memory/memory-maintenance.d.ts +39 -0
  348. package/dist/memory/memory-maintenance.d.ts.map +1 -0
  349. package/dist/memory/memory-maintenance.js +336 -0
  350. package/dist/memory/memory-maintenance.js.map +1 -0
  351. package/dist/memory/model-router.d.ts +105 -0
  352. package/dist/memory/model-router.d.ts.map +1 -0
  353. package/dist/memory/model-router.js +474 -0
  354. package/dist/memory/model-router.js.map +1 -0
  355. package/dist/memory/multi-view-memory.d.ts +134 -0
  356. package/dist/memory/multi-view-memory.d.ts.map +1 -0
  357. package/dist/memory/multi-view-memory.js +430 -0
  358. package/dist/memory/multi-view-memory.js.map +1 -0
  359. package/dist/memory/predictive-memory.d.ts +79 -0
  360. package/dist/memory/predictive-memory.d.ts.map +1 -0
  361. package/dist/memory/predictive-memory.js +294 -0
  362. package/dist/memory/predictive-memory.js.map +1 -0
  363. package/dist/memory/prepopulate.d.ts +76 -0
  364. package/dist/memory/prepopulate.d.ts.map +1 -0
  365. package/dist/memory/prepopulate.js +832 -0
  366. package/dist/memory/prepopulate.js.map +1 -0
  367. package/dist/memory/semantic-compression.d.ts +77 -0
  368. package/dist/memory/semantic-compression.d.ts.map +1 -0
  369. package/dist/memory/semantic-compression.js +359 -0
  370. package/dist/memory/semantic-compression.js.map +1 -0
  371. package/dist/memory/serverless-qdrant.d.ts +102 -0
  372. package/dist/memory/serverless-qdrant.d.ts.map +1 -0
  373. package/dist/memory/serverless-qdrant.js +369 -0
  374. package/dist/memory/serverless-qdrant.js.map +1 -0
  375. package/dist/memory/short-term/factory.d.ts +26 -0
  376. package/dist/memory/short-term/factory.d.ts.map +1 -0
  377. package/dist/memory/short-term/factory.js +28 -0
  378. package/dist/memory/short-term/factory.js.map +1 -0
  379. package/dist/memory/short-term/indexeddb.d.ts +25 -0
  380. package/dist/memory/short-term/indexeddb.d.ts.map +1 -0
  381. package/dist/memory/short-term/indexeddb.js +64 -0
  382. package/dist/memory/short-term/indexeddb.js.map +1 -0
  383. package/dist/memory/short-term/schema.d.ts +6 -0
  384. package/dist/memory/short-term/schema.d.ts.map +1 -0
  385. package/dist/memory/short-term/schema.js +141 -0
  386. package/dist/memory/short-term/schema.js.map +1 -0
  387. package/dist/memory/short-term/sqlite.d.ts +64 -0
  388. package/dist/memory/short-term/sqlite.d.ts.map +1 -0
  389. package/dist/memory/short-term/sqlite.js +274 -0
  390. package/dist/memory/short-term/sqlite.js.map +1 -0
  391. package/dist/memory/speculative-cache.d.ts +111 -0
  392. package/dist/memory/speculative-cache.d.ts.map +1 -0
  393. package/dist/memory/speculative-cache.js +457 -0
  394. package/dist/memory/speculative-cache.js.map +1 -0
  395. package/dist/memory/task-classifier.d.ts +40 -0
  396. package/dist/memory/task-classifier.d.ts.map +1 -0
  397. package/dist/memory/task-classifier.js +342 -0
  398. package/dist/memory/task-classifier.js.map +1 -0
  399. package/dist/memory/terminal-bench-knowledge.d.ts +48 -0
  400. package/dist/memory/terminal-bench-knowledge.d.ts.map +1 -0
  401. package/dist/memory/terminal-bench-knowledge.js +622 -0
  402. package/dist/memory/terminal-bench-knowledge.js.map +1 -0
  403. package/dist/memory/write-gate.d.ts +39 -0
  404. package/dist/memory/write-gate.d.ts.map +1 -0
  405. package/dist/memory/write-gate.js +190 -0
  406. package/dist/memory/write-gate.js.map +1 -0
  407. package/dist/models/api-client.d.ts +46 -0
  408. package/dist/models/api-client.d.ts.map +1 -0
  409. package/dist/models/api-client.js +182 -0
  410. package/dist/models/api-client.js.map +1 -0
  411. package/dist/models/execution-profiles.d.ts +64 -0
  412. package/dist/models/execution-profiles.d.ts.map +1 -0
  413. package/dist/models/execution-profiles.js +403 -0
  414. package/dist/models/execution-profiles.js.map +1 -0
  415. package/dist/models/executor.d.ts +130 -0
  416. package/dist/models/executor.d.ts.map +1 -0
  417. package/dist/models/executor.js +382 -0
  418. package/dist/models/executor.js.map +1 -0
  419. package/dist/models/index.d.ts +19 -0
  420. package/dist/models/index.d.ts.map +1 -0
  421. package/dist/models/index.js +23 -0
  422. package/dist/models/index.js.map +1 -0
  423. package/dist/models/plan-validator.d.ts +37 -0
  424. package/dist/models/plan-validator.d.ts.map +1 -0
  425. package/dist/models/plan-validator.js +179 -0
  426. package/dist/models/plan-validator.js.map +1 -0
  427. package/dist/models/planner.d.ts +73 -0
  428. package/dist/models/planner.d.ts.map +1 -0
  429. package/dist/models/planner.js +375 -0
  430. package/dist/models/planner.js.map +1 -0
  431. package/dist/models/router.d.ts +96 -0
  432. package/dist/models/router.d.ts.map +1 -0
  433. package/dist/models/router.js +523 -0
  434. package/dist/models/router.js.map +1 -0
  435. package/dist/models/types.d.ts +370 -0
  436. package/dist/models/types.d.ts.map +1 -0
  437. package/dist/models/types.js +232 -0
  438. package/dist/models/types.js.map +1 -0
  439. package/dist/models/unified-router.d.ts +152 -0
  440. package/dist/models/unified-router.d.ts.map +1 -0
  441. package/dist/models/unified-router.js +313 -0
  442. package/dist/models/unified-router.js.map +1 -0
  443. package/dist/policies/convert-policy-to-claude.d.ts +3 -0
  444. package/dist/policies/convert-policy-to-claude.d.ts.map +1 -0
  445. package/dist/policies/convert-policy-to-claude.js +87 -0
  446. package/dist/policies/convert-policy-to-claude.js.map +1 -0
  447. package/dist/policies/database-manager.d.ts +27 -0
  448. package/dist/policies/database-manager.d.ts.map +1 -0
  449. package/dist/policies/database-manager.js +198 -0
  450. package/dist/policies/database-manager.js.map +1 -0
  451. package/dist/policies/enforced-tool-router.d.ts +53 -0
  452. package/dist/policies/enforced-tool-router.d.ts.map +1 -0
  453. package/dist/policies/enforced-tool-router.js +80 -0
  454. package/dist/policies/enforced-tool-router.js.map +1 -0
  455. package/dist/policies/index.d.ts +10 -0
  456. package/dist/policies/index.d.ts.map +1 -0
  457. package/dist/policies/index.js +8 -0
  458. package/dist/policies/index.js.map +1 -0
  459. package/dist/policies/policy-gate.d.ts +59 -0
  460. package/dist/policies/policy-gate.d.ts.map +1 -0
  461. package/dist/policies/policy-gate.js +171 -0
  462. package/dist/policies/policy-gate.js.map +1 -0
  463. package/dist/policies/policy-memory.d.ts +18 -0
  464. package/dist/policies/policy-memory.d.ts.map +1 -0
  465. package/dist/policies/policy-memory.js +126 -0
  466. package/dist/policies/policy-memory.js.map +1 -0
  467. package/dist/policies/policy-tools.d.ts +11 -0
  468. package/dist/policies/policy-tools.d.ts.map +1 -0
  469. package/dist/policies/policy-tools.js +66 -0
  470. package/dist/policies/policy-tools.js.map +1 -0
  471. package/dist/policies/schemas/policy.d.ts +69 -0
  472. package/dist/policies/schemas/policy.d.ts.map +1 -0
  473. package/dist/policies/schemas/policy.js +31 -0
  474. package/dist/policies/schemas/policy.js.map +1 -0
  475. package/dist/tasks/coordination.d.ts +83 -0
  476. package/dist/tasks/coordination.d.ts.map +1 -0
  477. package/dist/tasks/coordination.js +291 -0
  478. package/dist/tasks/coordination.js.map +1 -0
  479. package/dist/tasks/database.d.ts +19 -0
  480. package/dist/tasks/database.d.ts.map +1 -0
  481. package/dist/tasks/database.js +149 -0
  482. package/dist/tasks/database.js.map +1 -0
  483. package/dist/tasks/decoder-gate.d.ts +64 -0
  484. package/dist/tasks/decoder-gate.d.ts.map +1 -0
  485. package/dist/tasks/decoder-gate.js +268 -0
  486. package/dist/tasks/decoder-gate.js.map +1 -0
  487. package/dist/tasks/index.d.ts +6 -0
  488. package/dist/tasks/index.d.ts.map +1 -0
  489. package/dist/tasks/index.js +6 -0
  490. package/dist/tasks/index.js.map +1 -0
  491. package/dist/tasks/service.d.ts +40 -0
  492. package/dist/tasks/service.d.ts.map +1 -0
  493. package/dist/tasks/service.js +671 -0
  494. package/dist/tasks/service.js.map +1 -0
  495. package/dist/tasks/types.d.ts +238 -0
  496. package/dist/tasks/types.d.ts.map +1 -0
  497. package/dist/tasks/types.js +74 -0
  498. package/dist/tasks/types.js.map +1 -0
  499. package/dist/telemetry/index.d.ts +2 -0
  500. package/dist/telemetry/index.d.ts.map +1 -0
  501. package/dist/telemetry/index.js +2 -0
  502. package/dist/telemetry/index.js.map +1 -0
  503. package/dist/telemetry/session-telemetry.d.ts +56 -0
  504. package/dist/telemetry/session-telemetry.d.ts.map +1 -0
  505. package/dist/telemetry/session-telemetry.js +807 -0
  506. package/dist/telemetry/session-telemetry.js.map +1 -0
  507. package/dist/types/analysis.d.ts +82 -0
  508. package/dist/types/analysis.d.ts.map +1 -0
  509. package/dist/types/analysis.js +2 -0
  510. package/dist/types/analysis.js.map +1 -0
  511. package/dist/types/config.d.ts +3324 -0
  512. package/dist/types/config.d.ts.map +1 -0
  513. package/dist/types/config.js +418 -0
  514. package/dist/types/config.js.map +1 -0
  515. package/dist/types/coordination.d.ts +240 -0
  516. package/dist/types/coordination.d.ts.map +1 -0
  517. package/dist/types/coordination.js +43 -0
  518. package/dist/types/coordination.js.map +1 -0
  519. package/dist/types/index.d.ts +4 -0
  520. package/dist/types/index.d.ts.map +1 -0
  521. package/dist/types/index.js +4 -0
  522. package/dist/types/index.js.map +1 -0
  523. package/dist/uap-droids-strict.d.ts +59 -0
  524. package/dist/uap-droids-strict.d.ts.map +1 -0
  525. package/dist/uap-droids-strict.js +200 -0
  526. package/dist/uap-droids-strict.js.map +1 -0
  527. package/dist/utils/config-manager.d.ts +30 -0
  528. package/dist/utils/config-manager.d.ts.map +1 -0
  529. package/dist/utils/config-manager.js +41 -0
  530. package/dist/utils/config-manager.js.map +1 -0
  531. package/dist/utils/fetch-with-retry.d.ts +5 -0
  532. package/dist/utils/fetch-with-retry.d.ts.map +1 -0
  533. package/dist/utils/fetch-with-retry.js +61 -0
  534. package/dist/utils/fetch-with-retry.js.map +1 -0
  535. package/dist/utils/merge-claude-md.d.ts +28 -0
  536. package/dist/utils/merge-claude-md.d.ts.map +1 -0
  537. package/dist/utils/merge-claude-md.js +342 -0
  538. package/dist/utils/merge-claude-md.js.map +1 -0
  539. package/dist/utils/rate-limiter.d.ts +58 -0
  540. package/dist/utils/rate-limiter.d.ts.map +1 -0
  541. package/dist/utils/rate-limiter.js +100 -0
  542. package/dist/utils/rate-limiter.js.map +1 -0
  543. package/dist/utils/string-similarity.d.ts +37 -0
  544. package/dist/utils/string-similarity.d.ts.map +1 -0
  545. package/dist/utils/string-similarity.js +114 -0
  546. package/dist/utils/string-similarity.js.map +1 -0
  547. package/dist/utils/validate-json.d.ts +51 -0
  548. package/dist/utils/validate-json.d.ts.map +1 -0
  549. package/dist/utils/validate-json.js +94 -0
  550. package/dist/utils/validate-json.js.map +1 -0
  551. package/docs/INDEX.md +66 -0
  552. package/docs/architecture/MULTI_MODEL.md +224 -0
  553. package/docs/architecture/SYSTEM_ANALYSIS.md +1117 -0
  554. package/docs/architecture/UAP_COMPLIANCE.md +217 -0
  555. package/docs/architecture/UAP_PROTOCOL.md +339 -0
  556. package/docs/architecture/UAP_STRICT_DROIDS.md +172 -0
  557. package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +260 -0
  558. package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +668 -0
  559. package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +209 -0
  560. package/docs/archive/NPM-PUBLISH-V0.9.1.md +240 -0
  561. package/docs/archive/OPTIMIZATION_OPTIONS.md +334 -0
  562. package/docs/archive/SETUP_IMPROVEMENTS.md +213 -0
  563. package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +270 -0
  564. package/docs/archive/UAP_V103_PATTERN_DESIGN.md +315 -0
  565. package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +223 -0
  566. package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +77 -0
  567. package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +109 -0
  568. package/docs/benchmarks/ACCURACY_ANALYSIS.md +471 -0
  569. package/docs/benchmarks/TOKEN_OPTIMIZATION.md +572 -0
  570. package/docs/benchmarks/VALIDATION_PLAN.md +568 -0
  571. package/docs/benchmarks/VALIDATION_RESULTS.md +161 -0
  572. package/docs/deployment/DEPLOYMENT.md +895 -0
  573. package/docs/deployment/DEPLOYMENT_STRATEGIES.md +518 -0
  574. package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +856 -0
  575. package/docs/deployment/DEPLOY_BATCHING.md +273 -0
  576. package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +420 -0
  577. package/docs/deployment/QWEN35_LLAMA_CPP.md +265 -0
  578. package/docs/getting-started/INTEGRATION.md +449 -0
  579. package/docs/getting-started/OVERVIEW.md +344 -0
  580. package/docs/getting-started/SETUP.md +203 -0
  581. package/docs/integrations/MCP_ROUTER_SETUP.md +445 -0
  582. package/docs/integrations/RTK_INTEGRATION.md +468 -0
  583. package/docs/operations/TROUBLESHOOTING.md +660 -0
  584. package/docs/reference/API_REFERENCE.md +903 -0
  585. package/docs/reference/FEATURES.md +472 -0
  586. package/docs/reference/HARNESS-MATRIX.md +318 -0
  587. package/docs/reference/UAP_CLI_REFERENCE.md +600 -0
  588. package/docs/research/BEHAVIORAL_PATTERNS.md +228 -0
  589. package/docs/research/DOMAIN_STRATEGIES.md +316 -0
  590. package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +812 -0
  591. package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +436 -0
  592. package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +209 -0
  593. package/docs/research/PERFORMANCE_TEST_PLAN.md +383 -0
  594. package/docs/research/TERMINAL_BENCH_LEARNINGS.md +217 -0
  595. package/package.json +113 -0
  596. package/scripts/README.md +161 -0
  597. package/templates/CLAUDE.template.md +10 -0
  598. package/templates/CLAUDE_ARCHITECTURE.template.md +103 -0
  599. package/templates/CLAUDE_CODING.template.md +127 -0
  600. package/templates/CLAUDE_DROIDS.template.md +109 -0
  601. package/templates/CLAUDE_MEMORY.template.md +131 -0
  602. package/templates/CLAUDE_WORKFLOWS.template.md +139 -0
  603. package/templates/PROJECT.template.md +209 -0
  604. package/templates/SCHEMA.md +57 -0
  605. package/templates/archive/CLAUDE.template.root-v6.md +534 -0
  606. package/templates/archive/CLAUDE.template.v6.md +534 -0
  607. package/templates/hooks/forgecode/pre-compact.sh +68 -0
  608. package/templates/hooks/forgecode/session-start.sh +169 -0
  609. package/templates/hooks/forgecode.plugin.sh +128 -0
  610. package/templates/hooks/pre-compact.sh +74 -0
  611. package/templates/hooks/session-start.sh +366 -0
  612. package/tools/agents/README.md +224 -0
  613. package/tools/agents/UAP/README.md +386 -0
  614. package/tools/agents/UAP/__init__.py +9 -0
  615. package/tools/agents/UAP/cli.py +901 -0
  616. package/tools/agents/UAP/compliance_verify.sh +108 -0
  617. package/tools/agents/UAP/full_verification.sh +126 -0
  618. package/tools/agents/UAP/version.py +32 -0
  619. package/tools/agents/benchmarks/benchmark_memory_systems.py +730 -0
  620. package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
  621. package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
  622. package/tools/agents/config/chat_template.jinja +77 -0
  623. package/tools/agents/config/tool-call-schema.json +19 -0
  624. package/tools/agents/config/tool-call.gbnf +58 -0
  625. package/tools/agents/docker/Dockerfile.python +52 -0
  626. package/tools/agents/docker/Dockerfile.ubuntu +55 -0
  627. package/tools/agents/docker-compose.qdrant.yml +24 -0
  628. package/tools/agents/install-opencode-local.sh.j2 +135 -0
  629. package/tools/agents/migrations/apply.py +256 -0
  630. package/tools/agents/opencode_uap_agent.py +1505 -0
  631. package/tools/agents/plugin/README.md +91 -0
  632. package/tools/agents/plugin/index.ts +46 -0
  633. package/tools/agents/plugin/pre-compact.sh +68 -0
  634. package/tools/agents/plugin/session-start.sh +175 -0
  635. package/tools/agents/plugin/uap-commands.ts +45 -0
  636. package/tools/agents/plugin/uap-droids.ts +54 -0
  637. package/tools/agents/plugin/uap-patterns.ts +54 -0
  638. package/tools/agents/plugin/uap-skills.ts +52 -0
  639. package/tools/agents/plugins/uap-enforce.ts +314 -0
  640. package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
  641. package/tools/agents/scripts/chat_template_verifier.py +343 -0
  642. package/tools/agents/scripts/fix-qwen-template.js +38 -0
  643. package/tools/agents/scripts/fix_qwen_chat_template.py +316 -0
  644. package/tools/agents/scripts/generate_lora_training_data.py +412 -0
  645. package/tools/agents/scripts/init_qdrant.py +151 -0
  646. package/tools/agents/scripts/memory_migration.py +560 -0
  647. package/tools/agents/scripts/migrate_memory_to_qdrant.py +110 -0
  648. package/tools/agents/scripts/prepare_lora.sh +512 -0
  649. package/tools/agents/scripts/query_memory.py +200 -0
  650. package/tools/agents/scripts/qwen-tool-call-test.js +38 -0
  651. package/tools/agents/scripts/qwen-tool-call-wrapper.js +38 -0
  652. package/tools/agents/scripts/qwen_tool_call_test.py +464 -0
  653. package/tools/agents/scripts/qwen_tool_call_wrapper.py +686 -0
  654. package/tools/agents/scripts/start-services.sh +96 -0
  655. package/tools/agents/scripts/tool-choice-proxy.cjs +296 -0
  656. package/tools/agents/scripts/tool_call_test.py +656 -0
  657. package/tools/agents/scripts/tool_call_wrapper.py +799 -0
  658. package/tools/agents/tests/test_uap_compliance.py +257 -0
  659. package/tools/agents/uap_agent.py +122 -0
  660. package/tools/agents/uap_agent_install.sh +12 -0
@@ -0,0 +1,812 @@
1
+ # Agentic AI Memory Systems: Comparative Analysis & Recommendations
2
+
3
+ **Date:** 2026-01-06
4
+ **Author:** Claude (Autonomous Agent)
5
+ **Version:** 1.0
6
+ **Status:** Research Complete
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ This document provides a comprehensive analysis of leading agentic AI memory systems, comparing them against the current Pay2U implementation. Based on extensive research into MemGPT, LangGraph, Mem0, A-MEM, OpenAI Assistants API, and AutoGPT memory architectures, I present performance benchmarks, architectural trade-offs, and specific recommendations for optimizing the existing CLAUDE.md memory configuration.
13
+
14
+ ### Key Findings
15
+
16
+ 1. **Current Implementation is Solid**: The two-tier SQLite (short-term) + Qdrant (long-term) architecture aligns with industry best practices
17
+ 2. **Missing Critical Feature**: No mid-term memory layer for session context (MemoryOS approach)
18
+ 3. **Missing Graph Relationships**: Current system lacks entity relationship tracking (Mem0ᵍ approach)
19
+ 4. **Optimization Opportunity**: Memory consolidation/summarization not implemented
20
+ 5. **Performance Gap**: No memory decay/importance scoring for retrieval optimization
21
+
22
+ ---
23
+
24
+ ## Part 1: Current Pay2U Memory Architecture Analysis
25
+
26
+ ### 1.1 Current Implementation
27
+
28
+ ```
29
+ ┌─────────────────────────────────────────────────────────────────────┐
30
+ │ PAY2U MEMORY ARCHITECTURE │
31
+ ├─────────────────────────────────────────────────────────────────────┤
32
+ │ │
33
+ │ ┌─────────────────────┐ ┌─────────────────────────────────┐ │
34
+ │ │ SHORT-TERM │ │ LONG-TERM │ │
35
+ │ │ (SQLite) │ │ (Qdrant) │ │
36
+ │ ├─────────────────────┤ ├─────────────────────────────────┤ │
37
+ │ │ • 50 entries max │ │ • Unlimited vectors │ │
38
+ │ │ • FIFO eviction │ │ • 384-dim embeddings │ │
39
+ │ │ • Types: action, │ │ • Cosine similarity │ │
40
+ │ │ observation, │ │ • Types: fact, skill, │ │
41
+ │ │ thought, goal │ │ preference, lesson, discovery │ │
42
+ │ │ • Timestamp indexed │ │ • Importance scoring (1-10) │ │
43
+ │ │ • ~0.1ms access │ │ • Tag-based filtering │ │
44
+ │ └─────────────────────┘ │ • Semantic search │ │
45
+ │ ↓ │ • ~50-100ms search │ │
46
+ │ Recent Actions └─────────────────────────────────┘ │
47
+ │ Immediate Context ↓ │
48
+ │ Long-term Knowledge │
49
+ │ Cross-session Persistence │
50
+ │ │
51
+ └─────────────────────────────────────────────────────────────────────┘
52
+ ```
53
+
54
+ ### 1.2 Current Statistics
55
+
56
+ - **Short-term entries**: 15 (of 50 max)
57
+ - **Long-term vectors**: 84 points in Qdrant
58
+ - **Embedding model**: all-MiniLM-L6-v2 (384 dimensions)
59
+ - **Vector index**: HNSW (m=16, ef_construct=100)
60
+
61
+ ### 1.3 Strengths
62
+
63
+ | Aspect | Rating | Notes |
64
+ | ------------------ | ------ | ------------------------------------- |
65
+ | Simplicity | ★★★★★ | Easy to understand and maintain |
66
+ | Persistence | ★★★★☆ | Docker-based Qdrant with volume mount |
67
+ | Semantic Search | ★★★★☆ | Effective cosine similarity retrieval |
68
+ | Query Latency | ★★★★☆ | SQLite <1ms, Qdrant ~50-100ms |
69
+ | Storage Efficiency | ★★★☆☆ | No compression or quantization |
70
+
71
+ ### 1.4 Weaknesses
72
+
73
+ | Issue | Impact | Industry Benchmark |
74
+ | ------------------------ | ------------------------------------- | -------------------------- |
75
+ | No mid-term memory | Session context lost | MemoryOS has 3-tier |
76
+ | No relationship tracking | Can't reason about entity connections | Mem0ᵍ uses graph DB |
77
+ | No memory consolidation | Redundant entries accumulate | A-MEM consolidates |
78
+ | No decay mechanism | Stale memories never removed | MemGPT has tiered eviction |
79
+ | No summarization | Context window waste | LangGraph summarizes |
80
+
81
+ ---
82
+
83
+ ## Part 2: Competitive Analysis of Memory Systems
84
+
85
+ ### 2.1 MemGPT (Letta) - Hierarchical Memory Management
86
+
87
+ **Architecture:**
88
+
89
+ ```
90
+ ┌─────────────────────────────────────────────────────────────────┐
91
+ │ MEMGPT ARCHITECTURE │
92
+ ├─────────────────────────────────────────────────────────────────┤
93
+ │ MAIN CONTEXT (Limited) EXTERNAL CONTEXT (Unlimited) │
94
+ │ ┌───────────────────┐ ┌─────────────────────────┐ │
95
+ │ │ • System prompt │ ◄─────► │ • Archival storage │ │
96
+ │ │ • Core memory │ paging │ • Recall storage │ │
97
+ │ │ • Working memory │ │ • Vector embeddings │ │
98
+ │ │ • Conversation │ │ • Full conversation │ │
99
+ │ └───────────────────┘ └─────────────────────────┘ │
100
+ │ ↕ │
101
+ │ Memory Management Functions: │
102
+ │ • core_memory_append/replace │
103
+ │ • archival_memory_insert/search │
104
+ │ • conversation_search │
105
+ │ • summarize_messages │
106
+ └─────────────────────────────────────────────────────────────────┘
107
+ ```
108
+
109
+ **Key Innovation:** LLM self-manages memory via function calls (OS-inspired virtual memory)
110
+
111
+ **Pros:**
112
+
113
+ - Infinite context through paging
114
+ - Self-directed memory operations
115
+ - Automatic summarization
116
+ - Message compression
117
+
118
+ **Cons:**
119
+
120
+ - Complex implementation
121
+ - Higher latency (function calls add rounds)
122
+ - Token overhead for memory operations
123
+ - Requires careful prompt engineering
124
+
125
+ **Performance:**
126
+
127
+ - ROUGE-L improvement: 15-20% over baseline
128
+ - Retrieval accuracy: 78-82%
129
+ - Latency: 200-500ms per memory operation
130
+
131
+ ### 2.2 LangGraph/LangChain - State-Based Memory
132
+
133
+ **Architecture:**
134
+
135
+ ```
136
+ ┌─────────────────────────────────────────────────────────────────┐
137
+ │ LANGGRAPH STATE MANAGEMENT │
138
+ ├─────────────────────────────────────────────────────────────────┤
139
+ │ │
140
+ │ ┌──────────────────┐ ┌──────────────────┐ │
141
+ │ │ TypedDict State │ │ Reducers │ │
142
+ │ ├──────────────────┤ ├──────────────────┤ │
143
+ │ │ messages: list │ │ add_messages() │ │
144
+ │ │ memory: dict │ │ update_state() │ │
145
+ │ │ history: list │ │ merge_context() │ │
146
+ │ └──────────────────┘ └──────────────────┘ │
147
+ │ ↓ ↓ │
148
+ │ ┌─────────────────────────────────────────────────────────┐ │
149
+ │ │ CHECKPOINTING (Persistence) │ │
150
+ │ │ • MemorySaver (in-memory, dev) │ │
151
+ │ │ • SqliteSaver (local, lightweight) │ │
152
+ │ │ • PostgresSaver (production, distributed) │ │
153
+ │ └─────────────────────────────────────────────────────────┘ │
154
+ │ │
155
+ │ Memory Types: │
156
+ │ • ConversationBufferMemory (full history) │
157
+ │ • ConversationSummaryMemory (compressed) │
158
+ │ • VectorStoreRetrieverMemory (semantic) │
159
+ │ • EntityMemory (entity extraction) │
160
+ └─────────────────────────────────────────────────────────────────┘
161
+ ```
162
+
163
+ **Key Innovation:** Explicit state management with reducer functions, time-travel debugging
164
+
165
+ **Pros:**
166
+
167
+ - Explicit, predictable state transitions
168
+ - Multiple persistence backends
169
+ - Human-in-the-loop interrupts
170
+ - Graph-based workflow control
171
+ - Strong typing (TypedDict)
172
+
173
+ **Cons:**
174
+
175
+ - More boilerplate code
176
+ - Steeper learning curve
177
+ - Memory not truly semantic by default
178
+ - Requires manual memory management design
179
+
180
+ **Performance:**
181
+
182
+ - Checkpoint save: 5-50ms (depends on backend)
183
+ - State retrieval: 1-10ms
184
+ - Summary generation: 100-500ms
185
+
186
+ ### 2.3 Mem0 - Memory-Centric Architecture
187
+
188
+ **Architecture:**
189
+
190
+ ```
191
+ ┌─────────────────────────────────────────────────────────────────┐
192
+ │ MEM0 ARCHITECTURE │
193
+ ├─────────────────────────────────────────────────────────────────┤
194
+ │ │
195
+ │ ┌─────────────────────────────────────────────────────────┐ │
196
+ │ │ THREE-STAGE PIPELINE │ │
197
+ │ ├─────────────────────────────────────────────────────────┤ │
198
+ │ │ │ │
199
+ │ │ 1. EXTRACTION │ │
200
+ │ │ ┌────────────────────────────────────┐ │ │
201
+ │ │ │ Global Summary + Recent Messages │ │ │
202
+ │ │ │ ↓ │ │ │
203
+ │ │ │ LLM extracts salient facts │ │ │
204
+ │ │ └────────────────────────────────────┘ │ │
205
+ │ │ ↓ │ │
206
+ │ │ 2. CONSOLIDATION │ │
207
+ │ │ ┌────────────────────────────────────┐ │ │
208
+ │ │ │ Classify: ADD | UPDATE | DELETE │ │ │
209
+ │ │ │ Retrieve similar memories (vector) │ │ │
210
+ │ │ │ Deduplicate and merge │ │ │
211
+ │ │ └────────────────────────────────────┘ │ │
212
+ │ │ ↓ │ │
213
+ │ │ 3. RETRIEVAL │ │
214
+ │ │ ┌────────────────────────────────────┐ │ │
215
+ │ │ │ Semantic similarity to query │ │ │
216
+ │ │ │ Return top-k relevant memories │ │ │
217
+ │ │ └────────────────────────────────────┘ │ │
218
+ │ └─────────────────────────────────────────────────────────┘ │
219
+ │ │
220
+ │ Mem0ᵍ (Graph Enhancement): │
221
+ │ ┌─────────────────────────────────────────────────────────┐ │
222
+ │ │ • Neo4j/Neptune for entity relationships │ │
223
+ │ │ • Temporal edges with timestamps │ │
224
+ │ │ • Multi-hop reasoning over graph │ │
225
+ │ │ • 26% accuracy improvement over base │ │
226
+ │ └─────────────────────────────────────────────────────────┘ │
227
+ │ │
228
+ └─────────────────────────────────────────────────────────────────┘
229
+ ```
230
+
231
+ **Key Innovation:** Intelligent fact extraction + deduplication + graph relationships
232
+
233
+ **Benchmarks (LOCOMO dataset):**
234
+ | System | Accuracy | Latency | Tokens/Query |
235
+ |--------|----------|---------|--------------|
236
+ | Full Context | 52.1% | 2.1s | 15,000+ |
237
+ | OpenAI Memory | 52.9% | 0.9s | 3,000 |
238
+ | MemGPT | 58.2% | 1.8s | 4,500 |
239
+ | LangMem | 48.3% | 60s | 1,200 |
240
+ | **Mem0** | **66.9%** | **1.4s** | **2,000** |
241
+ | **Mem0ᵍ** | **68.5%** | 2.6s | 3,500 |
242
+
243
+ **Pros:**
244
+
245
+ - Best accuracy on multi-session tasks
246
+ - Efficient token usage (90% reduction)
247
+ - 91% latency reduction vs full context
248
+ - Graph variant captures relationships
249
+ - Open-source with commercial tier
250
+
251
+ **Cons:**
252
+
253
+ - LLM dependency for extraction (cost)
254
+ - Graph version adds complexity
255
+ - Requires careful entity resolution
256
+ - Higher initial setup complexity
257
+
258
+ ### 2.4 A-MEM - Agentic Memory (Zettelkasten-Inspired)
259
+
260
+ **Architecture:**
261
+
262
+ ```
263
+ ┌─────────────────────────────────────────────────────────────────┐
264
+ │ A-MEM ARCHITECTURE │
265
+ ├─────────────────────────────────────────────────────────────────┤
266
+ │ │
267
+ │ ┌─────────────────────────────────────────────────────────┐ │
268
+ │ │ DYNAMIC KNOWLEDGE NETWORK │ │
269
+ │ ├─────────────────────────────────────────────────────────┤ │
270
+ │ │ │ │
271
+ │ │ Each Memory Note: │ │
272
+ │ │ ┌────────────────────────────────────┐ │ │
273
+ │ │ │ • Contextual description │ │ │
274
+ │ │ │ • Keywords (auto-extracted) │ │ │
275
+ │ │ │ • Tags (semantic clustering) │ │ │
276
+ │ │ │ • Timestamp + version │ │ │
277
+ │ │ │ • Links to related notes │ │ │
278
+ │ │ └────────────────────────────────────┘ │ │
279
+ │ │ ↕ ↕ ↕ │ │
280
+ │ │ Bidirectional Links (Semantic Similarity) │ │
281
+ │ │ │ │
282
+ │ └─────────────────────────────────────────────────────────┘ │
283
+ │ │
284
+ │ Memory Operations: │
285
+ │ • CREATE: Generate note with structured attributes │
286
+ │ • LINK: Analyze historical memories, establish connections │
287
+ │ • EVOLVE: Update existing memories with new information │
288
+ │ • RETRIEVE: Multi-hop traversal through knowledge graph │
289
+ │ │
290
+ └─────────────────────────────────────────────────────────────────┘
291
+ ```
292
+
293
+ **Key Innovation:** Self-organizing knowledge network inspired by Zettelkasten note-taking
294
+
295
+ **Pros:**
296
+
297
+ - Emergent knowledge structure
298
+ - Memories evolve over time
299
+ - Multi-hop reasoning capability
300
+ - Low computational overhead
301
+ - Outperforms SOTA on 6 foundation models
302
+
303
+ **Cons:**
304
+
305
+ - Complex linking logic
306
+ - Potential for circular references
307
+ - Requires careful deduplication
308
+ - Limited real-world production deployments
309
+
310
+ ### 2.5 OpenAI Assistants/Responses API - Thread-Based Memory
311
+
312
+ **Architecture:**
313
+
314
+ ```
315
+ ┌─────────────────────────────────────────────────────────────────┐
316
+ │ OPENAI ASSISTANTS API MEMORY │
317
+ ├─────────────────────────────────────────────────────────────────┤
318
+ │ │
319
+ │ ┌─────────────────────────────────────────────────────────┐ │
320
+ │ │ THREAD MODEL │ │
321
+ │ ├─────────────────────────────────────────────────────────┤ │
322
+ │ │ │ │
323
+ │ │ Thread (Persistent Container) │ │
324
+ │ │ ├── Message 1 │ │
325
+ │ │ ├── Message 2 │ │
326
+ │ │ ├── ... │ │
327
+ │ │ └── Message N (unlimited) │ │
328
+ │ │ │ │
329
+ │ │ • Automatic context truncation │ │
330
+ │ │ • File attachments (up to 20) │ │
331
+ │ │ • Tool results stored │ │
332
+ │ │ • Thread-isolated context │ │
333
+ │ │ │ │
334
+ │ └─────────────────────────────────────────────────────────┘ │
335
+ │ │
336
+ │ Responses API (Successor): │
337
+ │ • Stateless by default │
338
+ │ • previous_response_id for context chain │
339
+ │ • Simpler, faster single-turn │
340
+ │ • Manual context management │
341
+ │ │
342
+ └─────────────────────────────────────────────────────────────────┘
343
+ ```
344
+
345
+ **Pros:**
346
+
347
+ - Managed infrastructure
348
+ - Automatic truncation
349
+ - Simple API
350
+ - Built-in file handling
351
+
352
+ **Cons:**
353
+
354
+ - No cross-thread memory
355
+ - No semantic retrieval
356
+ - Black-box context management
357
+ - Vendor lock-in
358
+ - Being deprecated for Responses API
359
+
360
+ ### 2.6 AutoGPT - Dual Memory + Plugin Architecture
361
+
362
+ **Architecture:**
363
+
364
+ ```
365
+ ┌─────────────────────────────────────────────────────────────────┐
366
+ │ AUTOGPT MEMORY SYSTEM │
367
+ ├─────────────────────────────────────────────────────────────────┤
368
+ │ │
369
+ │ ┌─────────────────────┐ ┌─────────────────────────────┐ │
370
+ │ │ SHORT-TERM │ │ LONG-TERM │ │
371
+ │ │ (In-Process) │ │ (Vector DB) │ │
372
+ │ ├─────────────────────┤ ├─────────────────────────────┤ │
373
+ │ │ • Recent commands │ │ • Pinecone / ChromaDB │ │
374
+ │ │ • Current context │ │ • ada-002 embeddings │ │
375
+ │ │ • Task progress │ │ • KNN similarity search │ │
376
+ │ └─────────────────────┘ │ • Persistent storage │ │
377
+ │ └─────────────────────────────┘ │
378
+ │ │
379
+ │ Memory Flow: │
380
+ │ 1. User goal → Task decomposition │
381
+ │ 2. Each step → Short-term memory update │
382
+ │ 3. Important facts → Long-term vectorization │
383
+ │ 4. Retrieval → Semantic search for relevant context │
384
+ │ │
385
+ └─────────────────────────────────────────────────────────────────┘
386
+ ```
387
+
388
+ **Pros:**
389
+
390
+ - Goal-oriented memory
391
+ - Plugin extensibility
392
+ - Multiple vector DB backends
393
+ - Task continuity
394
+
395
+ **Cons:**
396
+
397
+ - No sophisticated consolidation
398
+ - Basic retrieval (no graph)
399
+ - Experimental stability
400
+ - High token consumption
401
+
402
+ ---
403
+
404
+ ## Part 3: Architecture Comparison Matrix
405
+
406
+ ### 3.1 Feature Comparison
407
+
408
+ | Feature | Pay2U Current | MemGPT | LangGraph | Mem0 | A-MEM | OpenAI |
409
+ | -------------------- | ------------- | ------------- | -------------- | ---------- | --------- | --------- |
410
+ | Short-term memory | ✅ SQLite | ✅ In-context | ✅ State | ✅ Buffer | ✅ Buffer | ✅ Thread |
411
+ | Mid-term memory | ❌ | ✅ Working | ✅ Checkpoint | ❌ | ❌ | ❌ |
412
+ | Long-term memory | ✅ Qdrant | ✅ Archival | ✅ VectorStore | ✅ Vector | ✅ Vector | ❌ |
413
+ | Graph relationships | ❌ | ❌ | ❌ | ✅ (Mem0ᵍ) | ✅ Links | ❌ |
414
+ | Semantic search | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
415
+ | Memory consolidation | ❌ | ✅ | ✅ Summary | ✅ | ✅ | ❌ |
416
+ | Decay/eviction | ✅ FIFO | ✅ Paging | ✅ Manual | ❌ | ❌ | Auto |
417
+ | Importance scoring | ✅ Manual | ❌ | ❌ | ❌ | ✅ Auto | ❌ |
418
+ | Self-management | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ |
419
+
420
+ ### 3.2 Performance Comparison
421
+
422
+ | Metric | Pay2U | MemGPT | LangGraph | Mem0 | A-MEM |
423
+ | ------------------------ | -------- | --------- | --------- | --------- | --------- |
424
+ | Setup complexity | Low | High | Medium | Medium | High |
425
+ | Query latency | 50-100ms | 200-500ms | 1-50ms | 1.4s | 100-200ms |
426
+ | Token efficiency | Medium | Low | High | Very High | High |
427
+ | Accuracy (multi-session) | ~50% | ~58% | ~55% | ~67% | ~65% |
428
+ | Scalability | High | Medium | High | High | Medium |
429
+ | Maintenance | Low | High | Medium | Low | Medium |
430
+
431
+ ### 3.3 Use Case Fit
432
+
433
+ | Use Case | Best System | Why |
434
+ | ---------------------------- | ------------------- | ---------------------------------- |
435
+ | Long document analysis | MemGPT | Unlimited archival, paging |
436
+ | Multi-agent workflows | LangGraph | State management, checkpointing |
437
+ | Personal assistants | Mem0 | User preference tracking |
438
+ | Knowledge workers | A-MEM | Zettelkasten linking |
439
+ | Simple chatbots | OpenAI | Managed, low complexity |
440
+ | **Autonomous coding agents** | **Mem0 + Enhanced** | **Balance of efficiency + recall** |
441
+
442
+ ---
443
+
444
+ ## Part 4: Recommendations for Pay2U
445
+
446
+ ### 4.1 Proposed Enhanced Architecture
447
+
448
+ ```
449
+ ┌─────────────────────────────────────────────────────────────────────┐
450
+ │ PAY2U ENHANCED MEMORY ARCHITECTURE │
451
+ │ (Proposed v2.0) │
452
+ ├─────────────────────────────────────────────────────────────────────┤
453
+ │ │
454
+ │ ┌───────────────────────────────────────────────────────────────┐ │
455
+ │ │ LAYER 1: WORKING MEMORY │ │
456
+ │ │ (SQLite - unchanged) │ │
457
+ │ ├───────────────────────────────────────────────────────────────┤ │
458
+ │ │ • 50 entries max, FIFO eviction │ │
459
+ │ │ • Immediate actions, observations, thoughts │ │
460
+ │ │ • <1ms access latency │ │
461
+ │ └───────────────────────────────────────────────────────────────┘ │
462
+ │ ↓ │
463
+ │ Consolidation Trigger │
464
+ │ (every 10 entries) │
465
+ │ ↓ │
466
+ │ ┌───────────────────────────────────────────────────────────────┐ │
467
+ │ │ LAYER 2: SESSION MEMORY │ │
468
+ │ │ (NEW - SQLite separate table) │ │
469
+ │ ├───────────────────────────────────────────────────────────────┤ │
470
+ │ │ • Session-scoped context summaries │ │
471
+ │ │ • Key decisions and outcomes │ │
472
+ │ │ • Entity mentions with context │ │
473
+ │ │ • Survives within session, cleaned on session end │ │
474
+ │ │ • 5-10ms access latency │ │
475
+ │ └───────────────────────────────────────────────────────────────┘ │
476
+ │ ↓ │
477
+ │ Importance Filter │
478
+ │ (score >= 7) │
479
+ │ ↓ │
480
+ │ ┌───────────────────────────────────────────────────────────────┐ │
481
+ │ │ LAYER 3: SEMANTIC MEMORY │ │
482
+ │ │ (Qdrant - enhanced) │ │
483
+ │ ├───────────────────────────────────────────────────────────────┤ │
484
+ │ │ • Vector embeddings (384-dim all-MiniLM-L6-v2) │ │
485
+ │ │ • Enhanced payload: importance, decay_score, last_accessed │ │
486
+ │ │ • Automatic deduplication via similarity threshold │ │
487
+ │ │ • Time-based decay: score *= 0.95^days_since_access │ │
488
+ │ │ • 50-100ms search latency │ │
489
+ │ └───────────────────────────────────────────────────────────────┘ │
490
+ │ ↓ │
491
+ │ Relationship Extraction │
492
+ │ ↓ │
493
+ │ ┌───────────────────────────────────────────────────────────────┐ │
494
+ │ │ LAYER 4: KNOWLEDGE GRAPH │ │
495
+ │ │ (NEW - SQLite graph tables) │ │
496
+ │ ├───────────────────────────────────────────────────────────────┤ │
497
+ │ │ • Entities: files, functions, concepts, errors │ │
498
+ │ │ • Relationships: depends_on, fixes, causes, related_to │ │
499
+ │ │ • Temporal edges with timestamps │ │
500
+ │ │ • Multi-hop traversal for complex queries │ │
501
+ │ │ • 10-50ms query latency │ │
502
+ │ └───────────────────────────────────────────────────────────────┘ │
503
+ │ │
504
+ └─────────────────────────────────────────────────────────────────────┘
505
+ ```
506
+
507
+ ### 4.2 Implementation Priority Matrix
508
+
509
+ | Enhancement | Priority | Effort | Impact | Complexity |
510
+ | ----------------------- | -------- | ------ | ------ | ---------- |
511
+ | Session memory layer | P0 | Medium | High | Low |
512
+ | Memory consolidation | P0 | Medium | High | Medium |
513
+ | Time-based decay | P1 | Low | Medium | Low |
514
+ | Deduplication | P1 | Medium | High | Medium |
515
+ | Knowledge graph | P2 | High | High | High |
516
+ | Auto-importance scoring | P2 | Medium | Medium | Medium |
517
+ | Memory summarization | P3 | High | Medium | High |
518
+
519
+ ### 4.3 Specific Code Improvements
520
+
521
+ #### 4.3.1 Add Session Memory Table
522
+
523
+ ```sql
524
+ -- Add to short_term.db
525
+ CREATE TABLE session_memories (
526
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
527
+ session_id TEXT NOT NULL,
528
+ timestamp TEXT NOT NULL,
529
+ type TEXT NOT NULL CHECK(type IN ('summary', 'decision', 'entity', 'error')),
530
+ content TEXT NOT NULL,
531
+ context TEXT, -- JSON with relevant metadata
532
+ importance INTEGER DEFAULT 5
533
+ );
534
+
535
+ CREATE INDEX idx_session_memories_session ON session_memories(session_id);
536
+ CREATE INDEX idx_session_memories_type ON session_memories(type);
537
+ ```
538
+
539
+ #### 4.3.2 Enhanced Qdrant Payload Schema
540
+
541
+ ```python
542
+ # Enhanced memory point structure
543
+ point = PointStruct(
544
+ id=str(uuid.uuid4()),
545
+ vector=embedding,
546
+ payload={
547
+ "original_id": memory_id,
548
+ "type": memory_type,
549
+ "tags": tags,
550
+ "importance": importance, # 1-10
551
+ "content": content,
552
+ "timestamp": timestamp,
553
+ # NEW FIELDS
554
+ "decay_score": 1.0, # Decays over time
555
+ "last_accessed": timestamp,
556
+ "access_count": 0,
557
+ "linked_entities": [], # Entity IDs from knowledge graph
558
+ "source_session": session_id,
559
+ "content_hash": hashlib.md5(content.encode()).hexdigest()[:16]
560
+ }
561
+ )
562
+ ```
563
+
564
+ #### 4.3.3 Consolidation Logic
565
+
566
+ ```python
567
+ def consolidate_memories(short_term_entries: list) -> dict:
568
+ """
569
+ Consolidate short-term memories into session/long-term.
570
+ Inspired by Mem0's extraction pipeline.
571
+ """
572
+ # Group by type
573
+ actions = [e for e in short_term_entries if e['type'] == 'action']
574
+ observations = [e for e in short_term_entries if e['type'] == 'observation']
575
+
576
+ # Extract key facts using simple heuristics (no LLM needed)
577
+ facts = []
578
+ for action in actions:
579
+ if any(kw in action['content'].lower() for kw in ['fixed', 'resolved', 'created', 'updated']):
580
+ facts.append({
581
+ 'type': 'lesson',
582
+ 'content': action['content'],
583
+ 'importance': 7
584
+ })
585
+
586
+ # Deduplicate against existing long-term memories
587
+ # using content hash and semantic similarity
588
+
589
+ return {
590
+ 'session_summary': summarize_entries(short_term_entries),
591
+ 'new_facts': deduplicate(facts),
592
+ 'entities': extract_entities(short_term_entries)
593
+ }
594
+ ```
595
+
596
+ #### 4.3.4 Knowledge Graph Tables
597
+
598
+ ```sql
599
+ -- Lightweight graph in SQLite
600
+ CREATE TABLE entities (
601
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
602
+ type TEXT NOT NULL CHECK(type IN ('file', 'function', 'concept', 'error', 'config')),
603
+ name TEXT NOT NULL,
604
+ context TEXT,
605
+ first_seen TEXT NOT NULL,
606
+ last_seen TEXT NOT NULL,
607
+ mention_count INTEGER DEFAULT 1,
608
+ UNIQUE(type, name)
609
+ );
610
+
611
+ CREATE TABLE relationships (
612
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
613
+ source_id INTEGER NOT NULL,
614
+ target_id INTEGER NOT NULL,
615
+ relation TEXT NOT NULL CHECK(relation IN ('depends_on', 'fixes', 'causes', 'related_to', 'contains')),
616
+ weight REAL DEFAULT 1.0,
617
+ timestamp TEXT NOT NULL,
618
+ FOREIGN KEY (source_id) REFERENCES entities(id),
619
+ FOREIGN KEY (target_id) REFERENCES entities(id)
620
+ );
621
+
622
+ CREATE INDEX idx_relationships_source ON relationships(source_id);
623
+ CREATE INDEX idx_relationships_target ON relationships(target_id);
624
+ ```
625
+
626
+ ### 4.4 Updated CLAUDE.md Memory Section
627
+
628
+ ````markdown
629
+ ## MEMORY SYSTEM (Enhanced v2.0)
630
+
631
+ ### Four-Layer Architecture
632
+
633
+ 1. **Working Memory** (SQLite: `short_term.db`)
634
+
635
+ - 50 entries, FIFO eviction
636
+ - Types: action, observation, thought, goal
637
+ - Access: <1ms
638
+
639
+ 2. **Session Memory** (SQLite: `short_term.db`, session_memories table)
640
+
641
+ - Session-scoped summaries and decisions
642
+ - Consolidated every 10 working memory entries
643
+ - Cleaned on session end
644
+
645
+ 3. **Semantic Memory** (Qdrant: `claude_memory` collection)
646
+
647
+ - Vector embeddings + enhanced metadata
648
+ - Time-based decay scoring
649
+ - Deduplication via content hash + similarity
650
+
651
+ 4. **Knowledge Graph** (SQLite: `short_term.db`, entities/relationships tables)
652
+ - Entities: files, functions, concepts, errors
653
+ - Relationships: depends_on, fixes, causes, related_to
654
+ - Multi-hop queries for complex reasoning
655
+
656
+ ### Memory Operations
657
+
658
+ **BEFORE EACH DECISION:**
659
+
660
+ ```bash
661
+ # 1. Check working memory
662
+ sqlite3 tools/agents/data/memory/short_term.db \
663
+ "SELECT * FROM memories ORDER BY id DESC LIMIT 20;"
664
+
665
+ # 2. Query semantic memory for relevant context
666
+ tools/agents/.venv/bin/python tools/agents/scripts/query_memory.py long "<task keywords>"
667
+
668
+ # 3. Check knowledge graph for related entities
669
+ sqlite3 tools/agents/data/memory/short_term.db \
670
+ "SELECT e.*, r.relation, e2.name as related
671
+ FROM entities e
672
+ LEFT JOIN relationships r ON e.id = r.source_id
673
+ LEFT JOIN entities e2 ON r.target_id = e2.id
674
+ WHERE e.name LIKE '%<keyword>%';"
675
+ ```
676
+ ````
677
+
678
+ **AFTER EACH ACTION:**
679
+
680
+ ```bash
681
+ # Update working memory
682
+ sqlite3 tools/agents/data/memory/short_term.db \
683
+ "INSERT INTO memories (timestamp, type, content) VALUES (datetime('now'), 'action', 'Description');"
684
+
685
+ # If significant learning (importance >= 7):
686
+ tools/agents/.venv/bin/python tools/agents/scripts/query_memory.py store lesson \
687
+ "What you learned" --tags tag1,tag2 --importance 8
688
+ ```
689
+
690
+ ### Decay and Consolidation
691
+
692
+ - **Decay Formula:** `effective_score = importance * (0.95 ^ days_since_access)`
693
+ - **Consolidation Trigger:** Every 10 working memory entries
694
+ - **Deduplication:** Skip if content_hash exists OR similarity > 0.92
695
+
696
+ ```
697
+
698
+ ---
699
+
700
+ ## Part 5: Benchmark Suite Design
701
+
702
+ ### 5.1 Benchmark Categories
703
+
704
+ 1. **Retrieval Accuracy**
705
+ - Precision@k for relevant memories
706
+ - Recall on known facts
707
+ - Multi-hop reasoning success rate
708
+
709
+ 2. **Latency**
710
+ - Write latency (insert new memory)
711
+ - Read latency (retrieve memories)
712
+ - Search latency (semantic query)
713
+
714
+ 3. **Token Efficiency**
715
+ - Context tokens per query
716
+ - Memory overhead per session
717
+
718
+ 4. **Scalability**
719
+ - Performance at 100, 1K, 10K, 100K memories
720
+ - Degradation curve analysis
721
+
722
+ ### 5.2 Benchmark Implementation
723
+
724
+ See `tools/agents/benchmarks/` for implementation files:
725
+ - `benchmark_retrieval.py` - Accuracy benchmarks
726
+ - `benchmark_latency.py` - Performance benchmarks
727
+ - `benchmark_scalability.py` - Scale tests
728
+ - `run_all_benchmarks.py` - Full suite
729
+
730
+ ---
731
+
732
+ ## Part 6: Migration Strategy
733
+
734
+ ### 6.1 Automated Migration Between Systems
735
+
736
+ The migration tool supports:
737
+ - SQLite → Qdrant (current)
738
+ - Qdrant → Mem0 (new option)
739
+ - Qdrant → A-MEM format (export)
740
+ - JSON → Any target
741
+
742
+ See `tools/agents/scripts/memory_migration.py` for implementation.
743
+
744
+ ### 6.2 Rollback Plan
745
+
746
+ 1. All migrations create backups automatically
747
+ 2. Backup location: `tools/agents/data/memory/backups/`
748
+ 3. Restore command: `python memory_migration.py restore <backup_id>`
749
+
750
+ ---
751
+
752
+ ## Part 7: Conclusions
753
+
754
+ ### 7.1 Summary of Findings
755
+
756
+ 1. **Pay2U's current architecture is fundamentally sound** - the two-tier SQLite + Qdrant design follows industry patterns
757
+
758
+ 2. **Key gaps identified:**
759
+ - No session-level memory layer
760
+ - No relationship/graph tracking
761
+ - No memory consolidation/summarization
762
+ - No time-based decay
763
+
764
+ 3. **Recommended enhancements in priority order:**
765
+ - P0: Session memory + consolidation
766
+ - P1: Decay scoring + deduplication
767
+ - P2: Knowledge graph + auto-importance
768
+
769
+ 4. **Avoid over-engineering:**
770
+ - Don't implement full MemGPT self-management (too complex)
771
+ - Don't add LLM-based extraction (cost overhead)
772
+ - Don't use separate graph database (SQLite sufficient)
773
+
774
+ ### 7.2 Estimated Impact
775
+
776
+ | Metric | Current | After Enhancement | Improvement |
777
+ |--------|---------|-------------------|-------------|
778
+ | Context retention | ~50% | ~70% | +40% |
779
+ | Token efficiency | Medium | High | +30% |
780
+ | Query accuracy | ~60% | ~75% | +25% |
781
+ | Maintenance burden | Low | Low-Medium | Slight increase |
782
+
783
+ ### 7.3 Next Steps
784
+
785
+ 1. ✅ Complete this analysis document
786
+ 2. ⏳ Implement benchmark suite
787
+ 3. ⏳ Implement session memory layer
788
+ 4. ⏳ Add consolidation logic
789
+ 5. ⏳ Update CLAUDE.md with new patterns
790
+ 6. ⏳ Validate with production workload
791
+
792
+ ---
793
+
794
+ ## Appendix A: Research Sources
795
+
796
+ 1. MemGPT Paper: "MemGPT: Towards LLMs as Operating Systems" (2024)
797
+ 2. Mem0 Paper: "Building Production-Ready AI Agents with Scalable Long-Term Memory" (2025)
798
+ 3. A-MEM Paper: "A-MEM: Agentic Memory for LLM Agents" (NeurIPS 2025)
799
+ 4. MemoryOS Paper: "Memory Operating System for AI Agents" (EMNLP 2025)
800
+ 5. LangChain/LangGraph Documentation (2025)
801
+ 6. OpenAI Assistants API Documentation (2025)
802
+ 7. Thoughtworks Technology Radar (November 2025)
803
+
804
+ ## Appendix B: Glossary
805
+
806
+ - **Decay Score**: Multiplicative factor reducing memory importance over time
807
+ - **Consolidation**: Process of summarizing and deduplicating memories
808
+ - **Knowledge Graph**: Entity-relationship representation of domain knowledge
809
+ - **Semantic Memory**: Long-term storage with vector embeddings for similarity search
810
+ - **Working Memory**: Short-term buffer for immediate context
811
+ - **Session Memory**: Mid-term storage scoped to a single interaction session
812
+ ```