Skip to content

Filters

Filters narrow the scope of a CTX query. They appear after the target and before the payload, prefixed with specific symbols.

PrefixTypeExampleDescription
#tag#codeFilter by semantic tag
@time@7dTime window constraint
^limit^3Maximum results
*project*my-projectScope to a project
&format&jsonResponse format

Tags categorize and filter content. Multiple tags narrow the search (logical AND).

?k "auth" #code Match knowledge tagged "code"
?m #architecture #decision @30d Match memories with both tags
+m lesson #my #fact Store with multiple tags

On the memory plane (m), certain tags are automatically promoted to typed filters:

Layer tags — scope to a memory tier:

TagLayer
#ephemeralSingle-session only
#myIndividual (per-agent)
#teamTeam-shared
#orgOrganization-wide
#globalPlatform-wide

Kind tags — classify the memory type:

#fact · #lesson · #preference · #spatial · #temporal · #social · #relation · #handoff

?m #my #lesson @7d ^5 My recent lessons
?m #team #decision Team decisions
+m note #ephemeral "expires after session"

Two special tags work on any plane:

?m #live Subscribe to live updates (SurrealDB LIVE SELECT)
?m #diff Return change deltas instead of full results

Time filters restrict results to a time window. Two formats:

Relative duration@{number}{unit}:

UnitMeaningExample
sseconds@30s
mminutes@15m
hhours@2h
ddays@7d
wweeks@4w
Mmonths@3M
yyears@1y
?m #architecture @7d Memories from the last 7 days
?k "deploy" @2h Knowledge accessed in the last 2 hours

Absolute date@YYYY-MM-DD or @YYYY-MM-DDTHH:MM:SSZ:

?m @2026-03-01 Memories since March 1st
?k "release" @2026-01-01T00:00:00Z Knowledge since start of year

Limits the number of results returned.

?k "auth" ^3 Return top 3 matches
?t github ^10 Return up to 10 tools
?m #my @30d ^5 Last 5 recent memories

Controls graph traversal depth (different from result limit):

?m @traverse auth-decision ^depth=3 Traverse 3 levels deep in the graph

Scopes the query to a specific project namespace.

?k "deploy" *my-project Knowledge from "my-project" only
?m #decision *agentctx Decisions in the agentctx project

Requests a specific response format.

?t github &json Return results as JSON
?k "auth" &compact Return compact format

Filters can be combined freely. Order doesn’t matter:

?k "authentication" #code #security @30d ^5 *my-project &json

This searches the knowledge plane for “authentication” with tags code AND security, within the last 30 days, limited to 5 results, in the my-project namespace, formatted as JSON.

The parser detects potential homograph attacks in tag values (mixing Latin, Cyrillic, and other scripts). When detected, the filter is flagged with mixedScript: true for downstream security checks.