The world’s first unified interface for agent harnessesOpen Source4.6kPowered by UHP

InsightsDec 2, 202614 min read

Vectors and graphs belong in one engine. The optimizer belongs in the agent.

Most agent memory glues a vector database to a graph database. Why similarity and traversal belong in one engine, why no standard graph query language can say "similar to this", why the language for agents should grow out of Gremlin's steps, and why part of the optimizer moves up to the agent.

Richard's cover for Vectors and graphs belong in one engine. The optimizer belongs in the agent, and the query language agent memory needs: a vector database glued to a graph database, with a top-k cut and merged scores; one engine, where similarity ranks what the traversal reached; and steps the agent can read, where the engine optimizes a step and the agent picks the next.

Ask an agent: "What did Alice's team decide about the pricing page before the launch?"

That one question mixes two kinds of search:

  • Graph questions: who is Alice, which team is hers, and what did that team decide?
  • A time question: what was true before the launch?
  • A similarity question: which of those decisions is about the pricing page, when nobody wrote the words "pricing page"?

Most agent memory today answers it by asking two databases and gluing the answers together. A vector database finds records that look like "pricing page". A graph database knows who Alice is and what her team decided. Some code in the middle merges the two result lists and hopes they overlap.

I built a vector database in 2023, and I've worked on graphs for more than seven years. My view is that this split is the wrong shape for agent memory. Similarity and traversal belong in one engine and one query, so a similarity search ranks only the things the traversal has already reached.

The query language on top matters just as much. None of the standard graph languages can say "similar to this", and the one that fits agents best isn't the one with the most momentum. I think agent memory needs a new language that grows out of Gremlin's step-by-step model, not out of Cypher or GQL. And part of the query optimizer moves up, out of the database and into the agent.

Below:

  • why "similar among the connected" breaks when two systems are glued together;
  • what that glue costs in practice;
  • how far the graph databases have got with vectors;
  • the four query languages, compared;
  • what a language for agents needs;
  • where the optimizer should live;
  • the strongest arguments against all of this.
Similar among connected, search first vs traverse first, for the question what did Alice's team decide about the pricing page before the launch: a vector database glued to a graph database takes the global top 4 by similarity, then filters for Alice's team before the launch, and 0 of 4 survive because the answer was fifth; one engine goes from Alice to the Platform team to its decisions, keeps the 4 made before the Oct 1 launch, then ranks them by pricing page and finds annual prices first.

What stitching costs in practice

The wrong order is only the first problem. Projects that run a graph store and a vector store side by side admit the rest in their own code and changelogs.

  • Two writes drift apart. Cognee's source orders its writes "GRAPH BEFORE VECTORS" and explains why: "The two stores fail independently, and only one of the two orders is recoverable." If the vector write lands and the graph write fails, content from a failed run is "served to users, permanently". LightRAG ships a repair tool because when a vector write fails, "the graph and the vector storage drift apart", and then "local/hybrid queries miss relations that exist in the graph". The fix it documents is a full re-embed: "real money".
  • Each store has its own rules for who may see what. Graphiti on Amazon Neptune keeps its search index in a second service, OpenSearch. A fix merged in October says "a search with group_ids could return nodes and communities from other groups", and "Episode fulltext search returned no results". Two stores means two places to get isolation right.
  • When the vector side misses, the graph never gets a chance. In several of these systems the graph only expands what the vector search hands it. Miss the seed and the relationships behind it don't exist as far as the agent knows.
  • Two scores that don't compare. A cosine score and a graph distance aren't on the same scale, so the results get merged by rule of thumb: reciprocal rank fusion (which only looks at positions in each list), round-robin, or fixed shares of the context window. None of these knows which result actually answers the question.

The vendors seem to have noticed:

One dropped the external graph databases and the other built a single engine. Either way, the stitched middle is emptying out.

What gluing a vector database to a graph database costs, as the projects admit in their own code and changelogs: writes drift apart (Cognee, LightRAG), two access rules (Graphiti on Neptune), the graph sees only the seeds (LightRAG), scores merged by rank (RRF, round-robin, fixed shares) and the top-k cut before the filter (Neo4j manual); with one engine the agent sends one query and gets one ranking, Mem0 dropped its external graph database drivers and Zep built Konig.

The graph databases bolt vectors on, too

If stitching is the problem, a graph database with vector search built in should be the answer. Mostly it isn't yet, because the vector index sits beside the graph pattern rather than inside it.

  • Neo4j has had vector indexes since 5.11. Its new SEARCH clause in Cypher 25 (2026.01) is the most advanced version so far, and it can filter on properties copied into the vector index. But the docs list what the pattern around it can't do. "The pattern cannot have a length longer than one relationship hop." "The pattern cannot have predicates on other elements than the bound variable." So "similar, among the decisions of Alice's team" still means search first, filter after.
  • Amazon Neptune Analytics allows "only one vector index for a graph", with its dimension fixed when the graph is created, and says "updates to the vector index are not atomic in nature".
  • FalkorDB's docs say "No support for filtering" for vector queries. Memgraph warns that "a search may return fewer than the requested number of results".
  • PostgreSQL, with pgvector beside Apache AGE, filters after the index scan by default: "If a condition matches 10% of rows… only 4 rows will match on average."

It can be done properly. TigerGraph's TigerVector (SIGMOD 2025) "treats the graph pattern as a filter and applies filtered vector search": it works out the qualifying vertices first and searches only among them. Its authors add that "in graph pattern matching scenarios, post-filtering is further limited, making pre-filtering the preferred approach." The research on filtered vector search agrees: ACORN (SIGMOD 2024) reports "2–1,000× higher throughput at a fixed recall" over existing methods.

So one engine isn't a fantasy. It's a design choice most databases haven't made yet.

No standard can say "similar to this"

GQL, the ISO standard query language for property graphs, was published on 12 April 2024. It runs to 610 pages. I searched the open grammar generated from the standard's own BNF for vector, similar, cosine, distance, embedding and nearest, and found zero matches. openCypher's grammar has none either. Neither does the core Gremlin language, in the current release or the 4.0 beta. (The ISO text is paywalled, and a second edition is in draft. I couldn't check whether it adds vectors.)

So every vendor invents its own:

DatabaseLanguageHow you ask "similar to this"
Neo4jCypher 25a SEARCH clause over a vector index
Spanner GraphGQLdistance functions, plus an index hint for approximate search
Neptune AnalyticsopenCyphera procedure call
TigerGraphGSQLa vectorSearch() function
OracleSQL with SQL/PGQa VECTOR_DISTANCE function

Five databases, five syntaxes. An agent that learns one has learned nothing it can take to the next.

That matters for memory in particular, because similarity isn't an add-on in agent memory. It's how most questions start. A language that can't express it natively isn't the language of agent memory, however standard it is.

No standard can say similar to this: searched for vector, similar, cosine, distance, embedding and nearest, GQL (ISO/IEC 39075, Apr 2024), openCypher 2024.3 and Gremlin core (3.8.3, 4.0 beta) have zero vector words, while Neo4j with Cypher 25, Spanner Graph with GQL, Neptune with openCypher, TigerGraph with GSQL and Oracle with SQL/PGQ each bolt on their own syntax: a SEARCH clause, distance functions, a procedure call, vectorSearch() and VECTOR_DISTANCE.

Cypher, GQL, GSQL or Gremlin?

Each of the four was designed for a different reader.

Cypher and GQL are declarative. You draw the pattern you want, such as (person)-[:ON]->(team)-[:DECIDED]->(decision), and a cost-based optimizer decides how to find it. They're readable, they're standard or close to it, and Neo4j says Cypher 25 now covers "most mandatory GQL features". They also have the most training data. An LDBC talk in 2025 put it plainly: "Text2Cypher has the most datasets among all graph query languages", and "LLM is not familiar with GQL grammar." Even so, the best model on CypherBench reaches only 61.58% execution accuracy.

GSQL is TigerGraph's. It's "Turing-complete", built from chained SELECT blocks, with accumulators that gather values as the traversal runs. It's a programming language for graph analytics, which is powerful for an engineer and a lot of surface for an agent.

Gremlin is a traversal language. A query is a chain of steps: start at Alice, go out to her team, go out to its decisions, keep the ones before the launch. Each step takes the set of things the previous step reached and hands a new set to the next one. TinkerPop calls the engine that runs it the Gremlin traversal machine.

For a person writing a query by hand, I'd pick GQL. For an agent, I'd pick Gremlin's model, for one reason: each step is something the agent can look at.

Watch how a capable agent actually uses memory. It doesn't write one perfect query. It finds Alice, looks at what came back, hops to her team, notices there are two teams called Platform, picks the right one, then reads the decisions. Every step is a small action with a visible result, followed by a choice. That's a Gremlin traversal, run one step at a time, with a model deciding the next step.

A pattern language hands back one finished answer and hides the plan inside the optimizer. If the answer is wrong, the agent can't tell which part of the pattern went wrong, and the next attempt is a guess.

One honest complication: TinkerPop itself is adding a declarative door. In the 4.0 beta, match() "takes a query string that could technically be any declarative graph query language", with a small GQL subset built in. The same release notes explain why the old declarative match() never caught on: "more often than not, it was more performant to simply write the imperative form of the query." The engineers who maintain Gremlin found that a written-out plan often beat the planner. Keep that in mind for the optimizer section.

Why a new language, grown from Gremlin

Adding a vector function to Gremlin isn't enough. What agent memory needs is a language whose steps were designed for a model reading the results. I'd build it on Gremlin's step model and make five things first-class:

  1. Similarity as a step. Not a procedure call and not a function inside a filter: a step that ranks the set the traversal has reached, by meaning, from plain text. The agent writes "about the pricing page", not a vector. If the traversal has reached nothing, the step should return nothing, not quietly search everything.
  2. Time as a step. Two different questions, both native: what was true at a given moment, and what the memory believed at that moment. The second is how you debug an agent that acted on stale facts. Yesterday's post argued that the graph's job is to be a good witness; this is how the language asks the witness.
  3. Provenance on every result. Each record that comes back says where it came from, so the agent can cite it or go and check it.
  4. Honest emptiness. "Nothing matched" and "this step couldn't run" must be different answers. An agent that gets an empty list from a failed call will read it as "there is no such fact" and answer with confidence.
  5. Cost before running. Each step should be able to say roughly how much it will return before it runs, so the agent can choose the narrow path first.

Scores should travel with results, and the traversal should decide what's eligible. That's the contract: the graph says what counts, similarity says what's closest, and the agent sees both.

A query as steps an agent can read: find Alice and get 1 person, follow MEMBER_OF and get 2 teams so the agent picks Platform, follow DECIDED and get 5 decisions, keep the 4 from before the Oct 1 launch, rank by meaning for pricing page with annual prices first at 0.83, and cite its provenance, meeting notes from Sep 12; similarity, time, provenance, no match versus failed, and cost before running are first-class steps, and the engine optimizes inside a step while the agent plans across steps.

The optimizer moves up to the agent

Since System R in 1979, the database consensus has been: declare what you want and let a cost-based optimizer decide how. It's one of the most successful ideas in computing. But an optimizer works from estimates. When the System R paper had no statistics for a range predicate, it used a fixed fraction: "F = 1/3 otherwise… There is no significance to this number."

Decades later the estimates are still the weak spot. Leis and colleagues tested real systems in "How Good Are Query Optimizers, Really?" (VLDB 2015): "For all systems we routinely observe misestimates by a factor of 1000 or more", and the errors grow exponentially as joins are added. Graph patterns are harder still: the G-CARE benchmark (SIGMOD 2020) found that "all existing techniques have serious problems in accuracy". Similarity predicates add another guess on top. Whether to filter first or search first depends on how selective the filter is, and a 2026 VLDB paper finds that the usual proxies "such as selectivity or attribute-vector correlation are frequently unstable".

The agent knows three things the optimizer never will:

  • what it's for: the current value or the whole history, one good answer or every match;
  • when it has enough, so it can stop;
  • what each step returned, because it saw the result before choosing the next step.

So my view is to split the job:

  • Inside a step, the engine optimizes. Index choice and the order of filtering and ranking: physical decisions the model shouldn't have to think about.
  • Across steps, the agent plans. Which hop to take next, whether to narrow by time first or by meaning first, and when to stop.

This doesn't let the engine off the hook. Each step has to be cheap, honest about what it returned, and able to say what it will cost, because a planner is only as good as what it can see.

Agents are expensive planners

Here's the case against my own thesis, and it's a strong one.

  • Agent traversal costs a lot of calls. Think-on-Graph needs up to 2ND + D + 1 model calls per question, which is 22 at its default width and depth. A 2025 study of Graph-CoT-style agents found runs "frequently exceeding 40,000 tokens per query", costing "over $3 per query", with "end-to-end latency ranging from 11s to 39s".
  • Agents repeat themselves. A 2025 paper on agent-first data systems found that the distinct sub-plans in agent workloads were often "less than 10-20%" of all the queries issued. The good news in the same paper: giving agents hints up front cut their queries by more than 20%.
  • A model is not an optimizer by default. In the LLM-R2 study, a model rewriting queries on its own made TPC-H slower than the rule-based baseline: 75.37 s against 40.98 s. It won only when the model chose among proven rewrite rules.

In my experience, a fixed first step is as good as an agent's own plan on most memory questions, and it takes one model call where the agent takes several. The agent earns its cost on exact lookups and on checking whether two facts contradict each other. It does worse on summaries, which need many records at once. And the failure I'd guard against hardest is the quiet one: a step fails, the agent sees nothing, and it reports that nothing exists.

So the practical answer isn't "let the agent plan everything". Start with a fixed first step, and let the agent take over when the first answer isn't enough. The balance will shift as models get better at planning. I expect it to shift faster than most database people think.

The strongest objections

"A user's memory is small. Just glue a vector store to a graph store." Size isn't the problem; correctness is. Drift between two writes, isolation rules kept in two places, and a global top-k cut that drops the answer all happen at any size.

"Just use Postgres." For a single hop with a filter, PostgreSQL with pgvector is a fine answer, and I'd start there. It strains when one question needs several hops, a point in time, and similarity ranked inside the traversal, all at once.

"Graph memory doesn't even beat simple baselines." This is the objection I take most seriously.

  • On MemoryAgentBench, plain BM25 keyword retrieval scored 41.5 overall. Mem0 scored 21.1, Cognee 20.6, Zep 24.0 and GraphRAG 23.4.
  • In Mem0's own paper, adding the graph raised the overall score from 66.88 to 68.44 but lowered multi-hop from 51.15 to 47.19, and the search p95 went from 0.200 s to 0.657 s. Putting the whole conversation in context scored 72.90.
  • The HippoRAG 2 authors found that "all previous structure-augmented methods underperform against the strongest embedding-based RAG methods".

My reading is that a lot of this is the stitching itself: the graph only ever sees what the vector search handed it. That's an interpretation, not a proven result. Either way, the bar is real: a graph has to earn its place on multi-hop questions and on "what was true then", not everywhere.

"LLMs write Cypher better, and there's no Gremlin benchmark." True, and I found no public benchmark that settles it for Gremlin. My answer is that agents shouldn't write query text at all. They should call steps and read results. A language built from steps is easier to hand to an agent as tools than a pattern language is.

"Nobody wants another query language." The alternative already exists: five incompatible vendor dialects for the one operation agent memory uses most.

Side by side

Two stores, gluedGraph DB with vectors bolted onOne engine for agent memory
Writetwo writes that can driftone databaseone write path
"Similar, among the connected"global top-k, then filtermostly search first, then filtersimilarity ranks what the traversal reached
Rankingfused by rule of thumbsimilarity score, then filterscore carried with each result; the traversal decides eligibility
Timedepends on the appproperties you query by handtrue-at and believed-at as steps
Languagetwo APIsa vendor dialectsteps an agent can inspect
Who plansthe glue codethe cost-based optimizerthe engine within a step, the agent across steps
Glued vs bolted on vs one engine for agent memory, side by side on six rows: the same comparison as the table above.

My bets for the end of Q1 2027

  1. Agent memory products stop stitching. They either fold the vector search into the graph engine or drop the graph.
  2. Memory APIs converge on a handful of steps: find by meaning, hop, filter, as-of, history. That's a traversal language, whatever it ends up being called.
  3. The next big gains in agent memory come from planning across steps, not from a better single query.

→Next

Run agents from any harness

Run supported harnesses through HarnessRouter and use task traces to inspect their execution.