AQL, Explained
Every verb of AQL 0.13, the Agent Query Language, as one expanding tree. Open RECALL, STORE, LINK, BRANCH, MERGE, PIPELINE and the rest, clause by clause, each with an explanation and an example.
AQL is the query language agents use for their own memory: five memory types (working, episodic, semantic, procedural and tools) and a small set of verbs to store, recall, link and learn. Agent Memory Needs a Query Language explains why. This post is the reference.
Updated 18 Nov 2026 for AQL 0.13, which replaced the earlier versions with one smaller language. AQL 0.13: One Read, Thirteen Verbs explains what changed and why.
AQL is not YAML, so instead of keys the tree is built from verbs: 13 of them, plus USE. Every statement has the same shape:
VERB FROM|INTO MEMORY_TYPE predicate [modifiers...]
Each verb below opens into those parts in order: the memory it reads or writes, the predicate that picks records, then the modifiers that shape the result. Click + on any part to see what it does and an example.
AQL verbs-
RECALLread verbAQL › RECALL
Every read. Exact lookups, filters, similarity, the tools for a task, the session's latest state: one verb, and the engine picks the access path from what you ask.
RECALL FROM EPISODIC WHERE outcome = "success" ORDER BY confidence DESC LIMIT 5-
FROM memoryclause requiredAQL › RECALL › FROM memory
Which memory to read. ALL reads every type at once: "tell me everything about this URL".
RECALL FROM ALL WHERE url = "example.com/news"-
EPISODICmemoryAQL › RECALL › FROM memory › EPISODIC
What happened: events, incidents, decisions and their outcomes.
-
SEMANTICmemoryAQL › RECALL › FROM memory › SEMANTIC
What is known: records about things, and the links between them.
-
PROCEDURALmemoryAQL › RECALL › FROM memory › PROCEDURAL
How to do things: runbooks and strategies the agent runs.
-
TOOLSmemoryAQL › RECALL › FROM memory › TOOLS
What can be used: the tools the agent may call, with their rankings.
-
WORKINGmemoryAQL › RECALL › FROM memory › WORKING
The current session: what the agent is holding right now.
-
ALLmemoryAQL › RECALL › FROM memory › ALL
Every memory type at once. For RECALL and FORGET only.
-
-
WHEREpredicateAQL › RECALL › WHERE
Conditions on fields. A key is just a field: WHERE key = "person:ada" is an exact lookup. No WHERE reads everything, within LIMIT.
RECALL FROM EPISODIC WHERE pod = "payments-api" AND resolved = true-
= != < <= > >=operatorAQL › RECALL › WHERE › = != < <= > >=
Compare a field with a value. Strings in double quotes; numbers, true, false and null as they are.
RECALL FROM EPISODIC WHERE resolution_time > 300 -
BETWEEN a AND boperatorAQL › RECALL › WHERE › BETWEEN a AND b
A value in a range, both ends included. Also how to read a span of time.
RECALL FROM EPISODIC WHERE created_at BETWEEN "2026-11-01T00:00:00Z" AND "2026-11-08T00:00:00Z" -
IN ( … )operatorAQL › RECALL › WHERE › IN ( … )
The field equals any value in the list.
RECALL FROM EPISODIC WHERE pod IN ("payments-api", "checkout") -
CONTAINS STARTS_WITH ENDS_WITHoperatorAQL › RECALL › WHERE › CONTAINS STARTS_WITH ENDS_WITH
Match part of a text field.
RECALL FROM SEMANTIC WHERE key STARTS_WITH "person:" -
AND OR ( )logicAQL › RECALL › WHERE › AND OR ( )
Combine conditions. Brackets make the grouping explicit.
RECALL FROM EPISODIC WHERE (pod = "a" OR pod = "b") AND resolved = true -
{name} $namevalueAQL › RECALL › WHERE › {name} $name
A variable instead of a literal: bound by the request, or by an earlier stage of a PIPELINE.
RECALL FROM EPISODIC WHERE url = {url} LIMIT 10
-
-
LIKE "text" | $varpredicateAQL › RECALL › LIKE "text" | $var
Similarity: the records closest in meaning to some text or a vector, found by vector and word search together. Use it instead of WHERE.
RECALL FROM SEMANTIC LIKE $question CONFIDENCE 0.7 LIMIT 5-
CONFIDENCE cmodifierAQL › RECALL › LIKE "text" | $var › CONFIDENCE c
At least this similar, from 0 to 1. Without it you get the best matches, however weak.
RECALL FROM PROCEDURAL LIKE "pod OOMKilled restart" CONFIDENCE 0.6
-
-
WINDOW LAST n | durationmodifierAQL › RECALL › WINDOW LAST n | duration
The newest items: the last n, or everything from the last 30s, 5m, 1h… Works on anything that has a time.
RECALL FROM WORKING WINDOW LAST 30s-
LAST noptionAQL › RECALL › WINDOW LAST n | duration › LAST n
The n most recent items.
RECALL FROM WORKING WINDOW LAST 10 -
LAST durationoptionAQL › RECALL › WINDOW LAST n | duration › LAST duration
Everything from the last span of time: a number and ms, s, m, h or d.
RECALL FROM EPISODIC WHERE pod = "payments-api" WINDOW LAST 1h
-
-
shape the resultmodifiersAQL › RECALL › shape the result
Order, cut and trim what comes back, so the LLM gets a few useful rows instead of everything.
RECALL FROM EPISODIC WHERE outcome = "success" ORDER BY confidence DESC LIMIT 5 RETURN incident_id, action, confidence-
ORDER BY field [ASC | DESC]modifierAQL › RECALL › shape the result › ORDER BY field [ASC | DESC]
Sort by one field. Ascending unless you say DESC. With LIMIT, also how to take the top n by a field.
RECALL FROM WORKING ORDER BY attention_weight DESC LIMIT 3 -
LIMIT nmodifierAQL › RECALL › shape the result › LIMIT n
Return at most n records.
RECALL FROM EPISODIC WHERE pod = "payments-api" LIMIT 10 -
RETURN fieldsmodifierAQL › RECALL › shape the result › RETURN fields
Return only these fields, or * for all of them. Keeps the context small.
RECALL FROM SEMANTIC WHERE key = "service:payments-api" RETURN owner, memory_limit
-
-
summarisemodifiersAQL › RECALL › summarise
Turn many records into a few numbers. Often the LLM needs a signal, not fifty rows.
RECALL FROM EPISODIC WHERE strategy = "tech_news_premium" AGGREGATE COUNT(*) AS uses, AVG(ctr) AS avg_ctr HAVING uses > 10 AND avg_ctr < 0.01-
AGGREGATE f(field) AS namemodifierAQL › RECALL › summarise › AGGREGATE f(field) AS name
Compute COUNT, AVG, SUM, MIN or MAX over the matched records. COUNT(*) counts them. AS names the result.
RECALL FROM EPISODIC WHERE root_cause = "OOMKilled" AGGREGATE COUNT(*) AS incidents, AVG(resolution_time) AS avg_minutes -
GROUP BY fieldsmodifierAQL › RECALL › summarise › GROUP BY fields
With AGGREGATE: one result row per group instead of one overall.
RECALL FROM EPISODIC WHERE outcome = "won" AGGREGATE COUNT(*) AS wins GROUP BY url -
HAVING conditionmodifierAQL › RECALL › summarise › HAVING condition
Filter on the aggregated values. Needs AGGREGATE.
RECALL FROM EPISODIC WHERE outcome = "won" AGGREGATE COUNT(*) AS wins GROUP BY url HAVING wins > 5
-
-
read the graphmodifiersAQL › RECALL › read the graph
Records are connected by LINKs. These modifiers show the links behind a record, or walk along them to other records, even in another memory type. Links are read in both directions.
RECALL FROM SEMANTIC WHERE key = "concept:k8s-oom" FOLLOW LINKS TYPE "triggers" RETURN pattern_id, steps, confidence-
WITH LINKSmodifierAQL › RECALL › read the graph › WITH LINKS
Return each record with its evidence: its links of each type, and their weights.
RECALL FROM PROCEDURAL WHERE pattern_id = "oom-fix" WITH LINKS-
TYPE "t"optionAQL › RECALL › read the graph › WITH LINKS › TYPE "t"
One link type, by name. Without TYPE, every type.
RECALL FROM SEMANTIC WHERE key = "concept:k8s-oom" FOLLOW LINKS TYPE "triggers" -
TYPE ("a", "b")optionAQL › RECALL › read the graph › WITH LINKS › TYPE ("a", "b")
Several link types.
RECALL FROM SEMANTIC WHERE key = "person:ada" FOLLOW LINKS TYPE ("works_at", "based_in") -
WEIGHT woptionAQL › RECALL › read the graph › WITH LINKS › WEIGHT w
Only links with at least this weight.
RECALL FROM PROCEDURAL WHERE pattern_id = "oom-fix" WITH LINKS TYPE "applied_to" WEIGHT 0.8
-
-
FOLLOW LINKSmodifierAQL › RECALL › read the graph › FOLLOW LINKS
Walk along links and return the records at the other end. Starting in SEMANTIC and following "triggers" can return PROCEDURAL records. Links to a record's aliases count too.
RECALL FROM SEMANTIC WHERE key = "org:acme" FOLLOW LINKS TYPE "works_at"-
TYPE "t"optionAQL › RECALL › read the graph › FOLLOW LINKS › TYPE "t"
One link type, by name. Without TYPE, every type.
RECALL FROM SEMANTIC WHERE key = "concept:k8s-oom" FOLLOW LINKS TYPE "triggers" -
TYPE ("a", "b")optionAQL › RECALL › read the graph › FOLLOW LINKS › TYPE ("a", "b")
Several link types.
RECALL FROM SEMANTIC WHERE key = "person:ada" FOLLOW LINKS TYPE ("works_at", "based_in") -
WEIGHT woptionAQL › RECALL › read the graph › FOLLOW LINKS › WEIGHT w
Only links with at least this weight.
RECALL FROM PROCEDURAL WHERE pattern_id = "oom-fix" WITH LINKS TYPE "applied_to" WEIGHT 0.8 -
DEPTH noptionAQL › RECALL › read the graph › FOLLOW LINKS › DEPTH n
How many hops to walk. One by default.
RECALL FROM SEMANTIC WHERE key = "person:ada" FOLLOW LINKS TYPE "knows" DEPTH 2
-
-
-
read the pastmodifiersAQL › RECALL › read the past
UPDATE keeps the old version of a record. These modifiers read memory as it was, not just as it is. A time is a timestamp or a variable.
RECALL FROM SEMANTIC WHERE key = "person:ada" AS OF "2026-10-01T00:00:00Z"-
AS OF timemodifierAQL › RECALL › read the past › AS OF time
What memory held at that moment.
RECALL FROM SEMANTIC WHERE key = "product:x1" AS OF $quarter_end RETURN price -
WITH HISTORYmodifierAQL › RECALL › read the past › WITH HISTORY
Every version, current and replaced, oldest first.
RECALL FROM PROCEDURAL WHERE pattern_id = "deploy" WITH HISTORY -
WITH HISTORY BETWEEN a AND bmodifierAQL › RECALL › read the past › WITH HISTORY BETWEEN a AND b
Only the versions written in that span.
RECALL FROM SEMANTIC WHERE key = "person:ada" WITH HISTORY BETWEEN "2026-01-01T00:00:00Z" AND "2026-06-30T00:00:00Z"
-
-
whose memorymodifiersAQL › RECALL › whose memory
Every statement works in a namespace: its own NAMESPACE, else the USE in force. A read may list several namespaces.
RECALL FROM SEMANTIC LIKE $q NAMESPACE ("crm", "kb") LIMIT 5-
NAMESPACE "ns"modifierAQL › RECALL › whose memory › NAMESPACE "ns"
Whose memory: an agent, a project, a branch. A server may require it on every statement.
RECALL FROM EPISODIC WHERE pod = "payments-api" NAMESPACE "ops" -
NAMESPACE ("a", "b")modifierAQL › RECALL › whose memory › NAMESPACE ("a", "b")
One read across several namespaces, ranked together. Reads only: writes, links and topics are in one namespace.
RECALL FROM SEMANTIC LIKE "refund policy" NAMESPACE ("crm", "kb") LIMIT 5 -
IN SCOPE "s"modifierAQL › RECALL › whose memory › IN SCOPE "s"
A shared group inside the namespace, such as one team.
RECALL FROM SEMANTIC IN SCOPE "team:billing" WHERE kind = "customer"
-
-
-
STOREwrite verbAQL › STORE
Write a new memory. A write names one memory type: the agent decides whether this is an event, knowledge or a procedure.
STORE INTO EPISODIC (event = "login", user_id = "u123") TTL 7d-
INTO memoryclause requiredAQL › STORE › INTO memory
Exactly one memory type. STORE INTO ALL is an error.
STORE INTO PROCEDURAL (pattern_id = "oom-fix", steps = "raise limit, restart", confidence = 0.6)-
EPISODICmemoryAQL › STORE › INTO memory › EPISODIC
What happened: events, incidents, decisions and their outcomes.
-
SEMANTICmemoryAQL › STORE › INTO memory › SEMANTIC
What is known: records about things, and the links between them.
-
PROCEDURALmemoryAQL › STORE › INTO memory › PROCEDURAL
How to do things: runbooks and strategies the agent runs.
-
TOOLSmemoryAQL › STORE › INTO memory › TOOLS
What can be used: the tools the agent may call, with their rankings.
-
WORKINGmemoryAQL › STORE › INTO memory › WORKING
The current session: what the agent is holding right now.
-
-
( field = value, … )payload requiredAQL › STORE › ( field = value, … )
The record, as field = value pairs in brackets. Fields are free: the agent decides what to keep. Values can be strings, numbers, true, false, null, lists or variables.
STORE INTO EPISODIC (incident_id = "inc-001", pod = "payments-api", resolved = true, resolution_time = 420) -
TTL dmodifierAQL › STORE › TTL d
Forget this memory automatically after a duration: 30s, 15m, 12h, 7d.
STORE INTO EPISODIC (event = "login", user_id = "u123") TTL 7d -
whose memorymodifiersAQL › STORE › whose memory
A write works in exactly one namespace: its own NAMESPACE, else the USE in force.
STORE INTO EPISODIC (event = "called", customer = "person:ada") NAMESPACE "crm"-
NAMESPACE "ns"modifierAQL › STORE › whose memory › NAMESPACE "ns"
Whose memory: an agent, a project, a branch. A server may require it on every statement.
RECALL FROM EPISODIC WHERE pod = "payments-api" NAMESPACE "ops" -
IN SCOPE "s"modifierAQL › STORE › whose memory › IN SCOPE "s"
A shared group inside the namespace, such as one team.
STORE INTO SEMANTIC (key = "note:renewal", text = "renewal due") IN SCOPE "team:billing"
-
-
-
UPDATEwrite verbAQL › UPDATE
Change fields of records that exist. The old version is kept as history, so AS OF and WITH HISTORY can still read it. A value is a field: there are no separate facts.
UPDATE INTO SEMANTIC WHERE key = "person:ada" (age = 36)-
INTO memoryclause requiredAQL › UPDATE › INTO memory
One memory type, not ALL.
UPDATE INTO PROCEDURAL WHERE pattern_id = "oom-fix" (confidence = 0.94, success_count = 8) -
WHEREpredicate requiredAQL › UPDATE › WHERE
Which records to change. Required: an UPDATE never touches everything.
UPDATE INTO EPISODIC WHERE incident_id = "inc-001" (resolved = true) -
( field = value, … )payload requiredAQL › UPDATE › ( field = value, … )
The fields to set. Fields you leave out keep their values; set one to null to clear it.
UPDATE INTO SEMANTIC WHERE key = "person:ada" (title = null, team = "research") -
(aliases = [ … ])fieldAQL › UPDATE › (aliases = [ … ])
Two keys turn out to name one thing. Give the survivor the other key as an alias, then FORGET the duplicate: reads, links and stored links by the alias all reach the survivor. Nothing is rewritten. (This replaces MERGE ENTITY.)
UPDATE INTO SEMANTIC WHERE key = "person:ada" (aliases = ["person:ada-lovelace"]) NAMESPACE "crm"; FORGET FROM SEMANTIC WHERE key = "person:ada-lovelace" NAMESPACE "crm" -
TTL dmodifierAQL › UPDATE › TTL d
Forget this memory automatically after a duration: 30s, 15m, 12h, 7d.
STORE INTO EPISODIC (event = "login", user_id = "u123") TTL 7d -
whose memorymodifiersAQL › UPDATE › whose memory
A write works in exactly one namespace: its own NAMESPACE, else the USE in force.
STORE INTO EPISODIC (event = "called", customer = "person:ada") NAMESPACE "crm"-
NAMESPACE "ns"modifierAQL › UPDATE › whose memory › NAMESPACE "ns"
Whose memory: an agent, a project, a branch. A server may require it on every statement.
RECALL FROM EPISODIC WHERE pod = "payments-api" NAMESPACE "ops" -
IN SCOPE "s"modifierAQL › UPDATE › whose memory › IN SCOPE "s"
A shared group inside the namespace, such as one team.
STORE INTO SEMANTIC (key = "note:renewal", text = "renewal due") IN SCOPE "team:billing"
-
-
-
FORGETwrite verbAQL › FORGET
Erase memories. A forgotten record leaves a tombstone, so no read can still see it.
FORGET FROM WORKING WHERE stale = true-
FROM memoryclause requiredAQL › FORGET › FROM memory
One memory type, or ALL to forget a record wherever it is.
FORGET FROM ALL WHERE user_id = "u123" NAMESPACE "crm"-
EPISODICmemoryAQL › FORGET › FROM memory › EPISODIC
What happened: events, incidents, decisions and their outcomes.
-
SEMANTICmemoryAQL › FORGET › FROM memory › SEMANTIC
What is known: records about things, and the links between them.
-
PROCEDURALmemoryAQL › FORGET › FROM memory › PROCEDURAL
How to do things: runbooks and strategies the agent runs.
-
TOOLSmemoryAQL › FORGET › FROM memory › TOOLS
What can be used: the tools the agent may call, with their rankings.
-
WORKINGmemoryAQL › FORGET › FROM memory › WORKING
The current session: what the agent is holding right now.
-
ALLmemoryAQL › FORGET › FROM memory › ALL
Every memory type at once. For RECALL and FORGET only.
-
-
WHEREpredicateAQL › FORGET › WHERE
Which records to forget.
FORGET FROM EPISODIC WHERE pod = "payments-api" AND resolved = true -
no WHEREoptionAQL › FORGET › no WHERE
Forgets everything in the memory named. It must name its NAMESPACE, so it can never happen by accident. FORGET FROM ALL with a NAMESPACE drops the whole namespace, which is also how a branch is dropped.
FORGET FROM ALL NAMESPACE "crm-try" -
whose memorymodifiersAQL › FORGET › whose memory
A write works in exactly one namespace: its own NAMESPACE, else the USE in force.
STORE INTO EPISODIC (event = "called", customer = "person:ada") NAMESPACE "crm"-
NAMESPACE "ns"modifierAQL › FORGET › whose memory › NAMESPACE "ns"
Whose memory: an agent, a project, a branch. A server may require it on every statement.
RECALL FROM EPISODIC WHERE pod = "payments-api" NAMESPACE "ops" -
IN SCOPE "s"modifierAQL › FORGET › whose memory › IN SCOPE "s"
A shared group inside the namespace, such as one team.
STORE INTO SEMANTIC (key = "note:renewal", text = "renewal due") IN SCOPE "team:billing"
-
-
-
LINKgraph verbAQL › LINK
Connect records with a typed, weighted link: the evidence behind a procedure, an entity's relationships. Relationships are links: "Ada works at Acme" is a LINK. On a link that exists, LINK sets its weight.
LINK FROM SEMANTIC WHERE key = "person:ada" INTO SEMANTIC WHERE key = "org:acme" TYPE "works_at"-
FROM memory WHERE …clause requiredAQL › LINK › FROM memory WHERE …
The records the links start at. One memory type, not ALL.
LINK FROM PROCEDURAL WHERE pattern_id = "oom-fix" INTO EPISODIC WHERE incident_id = "inc-001" TYPE "applied_to" -
INTO memory WHERE …clause requiredAQL › LINK › INTO memory WHERE …
The records the links end at. It can be a different memory type.
LINK FROM SEMANTIC WHERE key = "concept:auth" INTO PROCEDURAL WHERE pattern_id = "rotate-keys" TYPE "applied_to" -
TYPE "name"clause requiredAQL › LINK › TYPE "name"
What the link means. Several links of one TYPE give several objects.
LINK FROM EPISODIC WHERE incident_id = "inc-001" INTO EPISODIC WHERE incident_id = "inc-005" TYPE "recurring" -
WEIGHT woptionAQL › LINK › WEIGHT w
How strong the link is, from 0 to 1. Run LINK again with a new WEIGHT to change it.
LINK FROM PROCEDURAL WHERE pattern_id = "oom-fix" INTO EPISODIC WHERE incident_id = "inc-001" TYPE "applied_to" WEIGHT 0.97 -
NAMESPACE "ns"modifierAQL › LINK › NAMESPACE "ns"
Both ends are in this namespace.
LINK FROM SEMANTIC WHERE key = "person:ada" INTO SEMANTIC WHERE key = "org:acme" TYPE "works_at" NAMESPACE "crm"
-
-
UNLINKgraph verbAQL › UNLINK
Remove links between records. The records themselves stay.
UNLINK FROM SEMANTIC WHERE key = "person:ada" INTO SEMANTIC WHERE key = "org:acme" TYPE "works_at"-
FROM memory WHERE …clause requiredAQL › UNLINK › FROM memory WHERE …
The records the links start at. One memory type, not ALL.
UNLINK FROM PROCEDURAL WHERE pattern_id = "oom-fix" INTO EPISODIC WHERE incident_id = "inc-001" TYPE "applied_to" -
INTO memory WHERE …clause requiredAQL › UNLINK › INTO memory WHERE …
The records the links end at. It can be a different memory type.
UNLINK FROM SEMANTIC WHERE key = "concept:auth" INTO PROCEDURAL WHERE pattern_id = "rotate-keys" TYPE "applied_to" -
TYPE "name"optionAQL › UNLINK › TYPE "name"
Remove only links of this type. Without it, every link between those records goes.
UNLINK FROM SEMANTIC WHERE key = "a" INTO SEMANTIC WHERE key = "b" -
NAMESPACE "ns"modifierAQL › UNLINK › NAMESPACE "ns"
Both ends are in this namespace.
UNLINK FROM SEMANTIC WHERE key = "person:ada" INTO SEMANTIC WHERE key = "org:acme" TYPE "works_at" NAMESPACE "crm"
-
-
BRANCHnamespace verbAQL › BRANCH
A new namespace that reads through its base at a point in time, plus its own writes. Nothing is copied, and writes stay in the branch. Use it to try something against real memory.
BRANCH FROM "crm" INTO "crm-try"-
FROM "ns" INTO "ns"clause requiredAQL › BRANCH › FROM "ns" INTO "ns"
FROM is the base; INTO is the new branch. A branch can be branched again. The two names must differ. USE doesn't apply: these verbs always name their namespaces.
BRANCH FROM "crm" INTO "crm-try" -
AS OF timeoptionAQL › BRANCH › AS OF time
Branch from the base as it was at that moment, not as it is now.
BRANCH FROM "crm" INTO "crm-before-import" AS OF "2026-11-01T09:00:00Z" -
drop a branchnoteAQL › BRANCH › drop a branch
A branch is a namespace, so FORGET drops it. Dropping a namespace that still has branches is refused, naming them.
FORGET FROM ALL NAMESPACE "crm-try"
-
-
FORKnamespace verbAQL › FORK
BRANCH with a full copy. The fork no longer reads through its base, so later changes to the base, or dropping it, don't reach it. It remembers where it came from, so it can still be merged either way.
FORK FROM "crm" INTO "crm-copy"-
FROM "ns" INTO "ns"clause requiredAQL › FORK › FROM "ns" INTO "ns"
FROM is copied into the new namespace INTO. The two names must differ. USE doesn't apply: these verbs always name their namespaces.
FORK FROM "crm" INTO "crm-try" -
AS OF timeoptionAQL › FORK › AS OF time
Copy the records as they were at that moment.
FORK FROM "crm" INTO "crm-nov-1" AS OF "2026-11-01T00:00:00Z"
-
-
MERGEnamespace verbAQL › MERGE
Apply the changes FROM made since the two parted to INTO, in one write. Merging a base into its branch moves the branch forward (what rebase did). Two namespaces with no common base can't be merged.
MERGE FROM "crm-try" INTO "crm"-
FROM "ns" INTO "ns"clause requiredAQL › MERGE › FROM "ns" INTO "ns"
FROM is the side whose changes are applied; INTO receives them. The two names must differ. USE doesn't apply: these verbs always name their namespaces.
MERGE FROM "crm" INTO "crm-try" -
PREFER SOURCE | TARGEToptionAQL › MERGE › PREFER SOURCE | TARGET
When both sides changed the same record, MERGE fails and lists the conflicts. PREFER says which side wins instead: SOURCE is FROM, TARGET is INTO.
MERGE FROM "crm-try" INTO "crm" PREFER SOURCE -
rebasenoteAQL › MERGE › rebase
Merge the base into the branch to bring in its newer changes before you test again.
MERGE FROM "crm" INTO "crm-try"
-
-
PIPELINEflow verbAQL › PIPELINE
Several reads in one request, in order, within a time budget, ending in one context for the LLM. The last stage may write, to keep what was learned.
PIPELINE bid TIMEOUT 80ms RECALL FROM TOOLS WHERE task = "bidding" LIMIT 3 | RECALL FROM SEMANTIC WHERE key = {url} | RECALL FROM EPISODIC WHERE url = {url} LIMIT 10-
nameoptionAQL › PIPELINE › name
An optional name, for logs and traces.
PIPELINE triage RECALL FROM WORKING WINDOW LAST 60s | RECALL FROM EPISODIC WHERE pod = {pod} LIMIT 5 -
TIMEOUT doptionAQL › PIPELINE › TIMEOUT d
The time budget for the whole pipeline. TIMEOUT exists only here.
PIPELINE TIMEOUT 200ms RECALL FROM WORKING WINDOW LAST 60s | RECALL FROM EPISODIC WHERE pod = {pod} LIMIT 5 -
stage | stageclause requiredAQL › PIPELINE › stage | stage
RECALLs separated by |. {name} uses a value from an earlier stage. Each stage may name its own NAMESPACE.
PIPELINE enrich RECALL FROM SEMANTIC WHERE key = {customer} NAMESPACE "crm" | STORE INTO EPISODIC (customer = {customer}, seen = true) NAMESPACE "ops" -
write lastoptionAQL › PIPELINE › write last
The last stage may be a STORE or UPDATE: read the experience, then write back what was learned (what REFLECT … THEN did).
PIPELINE learn RECALL FROM EPISODIC WHERE incident_id = {current} | RECALL FROM PROCEDURAL WHERE pattern_id = {matched} | STORE INTO PROCEDURAL (pattern_id = "learned", steps = "step1, step2", confidence = 0.6)
-
-
SUBSCRIBEflow verbAQL › SUBSCRIBE
Follow changes as they happen: messages on a topic, or a live query whose result updates as memory changes. A subscription starts now.
SUBSCRIBE TOPIC "orders" WHERE status = "paid" NAMESPACE "shop"-
TOPIC "name"clauseAQL › SUBSCRIBE › TOPIC "name"
Messages PUBLISHed to this topic. WHERE filters them.
SUBSCRIBE TOPIC "orders" WHERE status = "paid" NAMESPACE "shop" -
RECALL …clauseAQL › SUBSCRIBE › RECALL …
A live query (what WATCH was): any RECALL, delivered again whenever its result changes.
SUBSCRIBE RECALL FROM SEMANTIC WHERE kind = "customer" LIMIT 20 NAMESPACE "crm" -
deliverynoteAQL › SUBSCRIBE › delivery
Acknowledgements, resuming from a position and how often a live query re-runs are the server's API and settings, not AQL.
-
-
UNSUBSCRIBEflow verbAQL › UNSUBSCRIBE
Stop a subscription or a live query.
UNSUBSCRIBE "sub-7f3a"-
handleclause requiredAQL › UNSUBSCRIBE › handle
The id returned when the subscription was created: a string, a variable or a name.
UNSUBSCRIBE $sub
-
-
PUBLISHflow verbAQL › PUBLISH
Send a message to a topic, for every subscriber.
PUBLISH TOPIC "orders" (order_id = "o-1", status = "paid") TTL 7d NAMESPACE "shop"-
TOPIC "name"clause requiredAQL › PUBLISH › TOPIC "name"
Where to publish. Topics are in one namespace.
PUBLISH TOPIC "alerts" (pod = "payments-api", level = "high") -
( field = value, … )payload requiredAQL › PUBLISH › ( field = value, … )
The record, as field = value pairs in brackets. Fields are free: the agent decides what to keep. Values can be strings, numbers, true, false, null, lists or variables.
PUBLISH TOPIC "orders" (order_id = "o-1", status = "paid") -
TTL dmodifierAQL › PUBLISH › TTL d
How long the message is kept for subscribers.
PUBLISH TOPIC "orders" (order_id = "o-1", status = "paid") TTL 7d
-
-
USEsessionAQL › USE
Name the namespace once. Statements after it that name no namespace work there; a statement's own NAMESPACE still wins.
USE "crm"; RECALL FROM SEMANTIC WHERE key = "person:ada"; STORE INTO EPISODIC (event = "called", customer = "person:ada")-
scriptclauseAQL › USE › script
Statements separated by ; are one request. Its answer is the last statement's. A failing statement stops the script and is named by position; the ones before it stay done.
USE "ops"; STORE INTO EPISODIC (event = "deploy", service = "payments-api"); RECALL FROM EPISODIC WHERE service = "payments-api" ORDER BY created_at DESC LIMIT 3 -
sessionnoteAQL › USE › session
A connection that keeps state (MCP, Flight) keeps its USE between requests. A plain HTTP request uses a script.
-
own NAMESPACE winsnoteAQL › USE › own NAMESPACE wins
USE only fills in a missing namespace. BRANCH, FORK and MERGE always name theirs.
USE "crm"; RECALL FROM EPISODIC WHERE pod = "x" NAMESPACE "ops"
-
No key matches.
Three rules that hold everywhere
- One pair of direction words. Reads and
FORGETtakeFROMmemory;STOREandUPDATEwriteINTOit.LINK,BRANCH,FORKandMERGEsay both ends:FROMoneINTOthe other. - One read, any memory.
RECALLis the only read verb and works on every memory type.ALLworks withRECALLandFORGETonly; writes name one memory type and one namespace. - Modifiers come after the predicate, in any order.
LIMIT 5 ORDER BY created_at DESCandORDER BY created_at DESC LIMIT 5mean the same.
Every example in the tree parses with the AQL 0.13 reference parser.
Try it in the docsRun AQL in your browser: the parser and engine in WASMSources
- AQL on GitHub: the grammar (
grammar/aql.pest), the spec and the conformance suites - AQL v0.13 specification, which the tree follows