Docs and articles

R-51

Technology

TQL Was Designed for LLMs to Write — Here's How It Works

Every AI agent on the planet is generating queries against your database. The query language they reach for matters more than most teams admit. Here's why we wrote a new one.

PAR2 Labs

August 29, 2026

2 min

TQL Was Designed for LLMs to Write — Here's How It Works

SQL is the most-generated text on Earth that nobody writes for fun. Cypher is denser but punishingly syntactic. Both predate LLM authoring by decades, and it shows in how often agents botch them. TQL is what we built when we got tired of debugging models' bad joins.

01

What goes wrong when LLMs write SQL

The failure modes are predictable: implicit Cartesian products from missed join conditions, ambiguous column references after multi-table joins, NULL semantics that models reason about incorrectly, and quoting rules that vary by dialect. Each one looks like a one-off bug; collectively they make agent-generated SQL unreliable past a few joins.

02

What TQL changes

TQL is declarative without being relational. Queries name what you want by type, not by table. There are no joins because the data model doesn't have foreign keys to chase — the participants in a fact are endpoints on the hyperedge, each identified by its role. And temporal, branch, and confidence context are first-class, so “high confidence, valid in the last 90 days” is a filter you attach, not a subquery you assemble.

The effect is that no clause depends on column-resolution order and there are no JOIN ON conditions to forget. That's the property that makes a language easy for a model to get right on the first try: fewer places where a plausible-looking query is silently wrong.

Languages that constrain the model towards right answers — not languages that maximally expose database internals — are what the next decade calls for.

03

Why this matters now

The job of an enterprise database in 2026 is to be queryable correctly by a non-deterministic process. The cost of an off-by-one in an LLM-generated WHERE clause shows up in regulator reports. Languages that constrain the model towards right answers — not languages that maximally expose database internals — are what the next decade calls for.

SQL was designed for humans to write rarely. TQL was designed for agents to write constantly. Same problem space, very different design constraints.

04

Compatibility

Tessera also accepts Cypher and SQL over the same data, so existing skills port and you're never locked into one language. But measure your agent's success rate across all three on the queries your application actually generates. We did, and TQL won by a margin that decided the project.

Key Takeaways

01

LLM-written SQL fails in predictable ways: missed join conditions, ambiguous columns, NULL semantics and dialect quoting.

02

TQL names data by type rather than table and has no joins, because a fact's participants are role-labelled endpoints.

03

Temporal, branch and confidence context are filters you attach, not subqueries you assemble.

04

Tessera also accepts Cypher and SQL over the same data, so existing skills port.


PAR2 Labs · Technology

Talk to us

One copy of the data, five ways to read it.