Solution skill
Agent long-term memory on Upstash Redis Search: idempotent index, per-turn recall
Complete solution
Build the long-term memory index once with an idempotent create, then query it per turn. Index creation is setup, not request path.
TL;DR: Build the long-term memory index once with an idempotent create, then query it per turn. Index creation is setup, not request path. Create the index once This is a setup script, not request code. Write facts On each turn, extract durable facts (preferences, decisions, events) and store them as JSON under memory:FACTID with the userId, kind, text, and createdAt fields the schema expects.
The fix
Agent long-term memory on Upstash Redis Search
1. Create the index once
This is a setup script, not request code. Make it idempotent so re-runs are safe:
from upstashredis import Redis redis = Redis.fromenv() redis.search.createindex( name="memories", datatype="json", prefixes="memory:", exists_ok=True, schema={ "text": "TEXT", "userId": "KEYWORD", "kind": "KEYWORD", "createdAt": "F64", }, )
Schema choices: text is full-text searchable, userId and kind are exact-match keywords for scoping, createdAt is a sortable number for recency.
2. Write facts
On each turn, extract durable facts (preferences, decisions, events) and store them as JSON under memory:FACTID with the userId, kind, text, and createdAt fields the schema expects.
3. Recall per turn
Query the index scoped to the user, sorted by recency, and feed the top hits into the prompt alongside the working-memory chat history. Working memory is the separate TTL-key pattern: one key per session, one-hour expiry.
Notes
Upstash Search indexes JSON, hash, string, and stream keys via its own SEARCH commands, separate from RediSearch FT commands.
Keep the index name stable across deploys: the SDK command references cover typed helpers, but the index itself persists in the database.
Verify
Store a test fact, query it back scoped to the right user and wrong user (wrong user must not see it), and re-run setup to confirm idempotency.
When to use this
- This covers exactly what the title says: Agent long-term memory on Upstash Redis Search.
- You are setting this up for the first time, or auditing an existing setup.
- You want the key gotchas in one place before you start.
When not to use this
- You are doing a different workflow with Agent; these steps are specific to the title above.
- You need the full reference docs; this is the short path, not the manual.
Compatibility
- Not pinned to a specific version; follows current Agent behavior.
Evidence
Verified against the Upstash agent-memory tutorial: create the memories index once in a setup script with existsok true (idempotent, safe to re-run); schema with text full-text, userId/kind keyword exact-match, createdAt sortable number; per-turn recall queries the index. Source: https://upstash.com/docs/redis/tutorials/agentmemory
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_wNPfA2xLQDG8-TLMmX00bw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Agent long-term memory on Upstash Redis Search: idempotent index, per-turn recall <span>— Vectle</span></a>