How to Build User Profiles for AI Agents with Supermemory
Problem
I wanted my AI assistant to greet returning users with something better than “Hello, how can I help you?” I needed it to know that Alex is a senior engineer, prefers dark mode, and is currently debugging a rate limit issue. But building a user profile database from scratch felt like overkill for a side project.
I tried querying a vector database for user facts. The problem was that I had to know what to ask. If I searched for “Alex preferences,” I got decent results. But if I searched for “what is Alex working on,” I sometimes missed key context because the embedding similarity was not high enough. Search requires you to guess the right query. Profiles do not.
The Profile API
Supermemory’s client.profile() endpoint returns a pre-built summary for any user. It splits context into two categories:
profile.static— long-term facts that rarely changeprofile.dynamic— recent activity and current context
Here is what a real response looks like:
const { profile } = await client.profile({ containerTag: "user_123" })
// profile.static// ["Senior engineer at Acme", "Prefers dark mode", "Uses Vim"]
// profile.dynamic// ["Working on auth migration", "Debugging rate limits"]One call. About 50 milliseconds. No query engineering required.
Injecting Profiles into System Prompts
The simplest way to use profiles is to inject them into your agent’s system prompt:
const { profile } = await client.profile({ containerTag: "user_123" })
const systemPrompt = `You are a helpful coding assistant.
About the user:${profile.static.map(f => `- ${f}`).join("\n")}
Current context:${profile.dynamic.map(f => `- ${f}`).join("\n")}`
// Now pass systemPrompt to your LLM callWhen I added this to my assistant, the quality of responses improved immediately. The agent stopped suggesting light-theme tools to a user who prefers dark mode. It knew to focus on authentication topics because that was the user’s current project.
Combining Profile and Search
The profile endpoint optionally accepts a query parameter. This lets you combine profile retrieval with semantic search in one call:
const { profile, searchResults } = await client.profile({ containerTag: "user_123", q: "What programming style does the user prefer?"})
// profile gives you who they are// searchResults give you specific memories matching the queryI use this when I need both general context (who is this user?) and specific context (what do they think about X?).
Python Equivalent
from supermemory import Supermemory
client = Supermemory()result = client.profile(container_tag="user_123")
print(result.profile.static) # ['Senior engineer at Acme', 'Prefers dark mode']print(result.profile.dynamic) # ['Working on auth migration']What I Got Wrong at First
I initially built a manual user profile table in PostgreSQL. I stored fields like role, editor, theme. Every time a user mentioned a new fact, I had to write custom parsing logic to decide whether to update a row. It was fragile and incomplete.
Supermemory replaces all of that. It extracts facts automatically, decides what is static versus dynamic, and keeps profiles current without any custom code on my end.
Summary
In this post, I showed how to build user profiles for AI agents using Supermemory’s profile API. The key point is that client.profile() gives you a ready-to-use summary of static facts and dynamic context in about 50ms. Inject that into your system prompt, and your agent stops treating every user like a stranger.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments