Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why I Put Swarm Memory in PostgreSQL Instead of Zep

A completed simulation left me with a report and an ownership problem. MiroFish had built the graph, generated the agents, and run their interactions, but the useful memory still lived behind somebody else's service boundary. The gateway could display the final answer. It couldn't reliably ask its own questions of the evidence that produced it. That distinction mattered because running a swarm…

The project allocated roughly 30,000 to 40,000 credits per simulation for memory usage. Daily runs would turn memory retrieval into a recurring external dependency before the gateway had served its first reader. To resolve this issue, the memory layer was moved into PostgreSQL 16 with pgvector. The upstream checkout still utilized its configured graph provider while constructing a graph.

However, the boundary was now closer and more defensible: once MiroFish returned graph data and action logs, the gateway owned the persisted copy and every read against it. The gateway had three read patterns: retrieving entities by type, walking a bounded neighborhood, and searching agent episodes by meaning. These patterns were met by adding graph nodes, graph edges, and episodes to the existing PostgreSQL database. pgvector facilitated semantic queries without introducing another network call.

The tenant rule was made explicit, with tenantId and simulationId included in the graph tables and unique constraints preventing duplicate records within a simulation. The schema consisted of one store and two kinds of memory: graph entities and agent episodes. Graph entities mirrored named entities from the MiroFish graph, while agent episodes stored actions produced during simulation rounds.

The embedding width was set to 384 dimensions, matching the output of the local Xenova/all-MiniLM-L6-v2 model. The embedding extractor was initialized lazily and shared through a single promise to avoid loading the ONNX model for non-semantic search requests and prevent concurrent model loads. The query function, which carries the security contract, performed semantic retrieval using cosine similarity, with tenantId and simulationId as predicates and an optional agent filter.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

CRC32 vs SHA-256 vs XXHash: Which Checksum Should You Use?

If you've ever needed to verify a download, find duplicate files, or prove a folder hasn't changed, you've met checksums. But which one should you actually use?

  • CRC32 is fast and widely supported but not collision-resistant, risky for critical decisions.
  • XXHash offers speed with non-cryptographic collision resistance, unsuitable for destructive actions.
  • SHA-256 is collision-resistant and ideal for audits, legal cases, and backup verification.

A Simulation ID Is Not a Running Simulation

createSimulation() returned an ID. startSimulation() still failed. That was the sixth version of the gateway's live MiroFish path.

  • Simulation ID does not indicate active simulation
  • Report generation requires explicit trigger after swarm stops
  • Simulation process divided into distinct phases

More from Saturday 29 August →