Opinionated guides for building with Threadline.
Never asks "what language are you using?" again.
What Threadline remembers:
Code style: naming conventions (snake_case vs camelCase), comment density, functional vs OOP preference
Work patterns: prefers code-only vs explanation, includes tests by default, error handling style
How it works:
Before every response, Threadline injects the developer's stack and style preferences into the system prompt. The agent generates code that matches their conventions without being told. Style conflicts (e.g. switching from snake_case to camelCase) are detected and the agent confirms before updating the stored preference.
const { injectedPrompt } = await tl.inject(userId, `
You are a coding assistant. Use the user's stored stack
and code style preferences when generating code.
Match their naming conventions exactly.
`)
// After response — Threadline learns their style over time
await tl.update({ userId, userMessage, agentResponse })Knows each customer's history before they say a word.
What Threadline remembers:
How it works:
When a returning customer opens a support chat, the agent already knows their tier, recent issues, and typical problems — and can open with a proactive offer instead of asking them to explain again. Sentiment is tracked across sessions so the agent adjusts tone accordingly.
const { injectedPrompt } = await tl.inject(userId, `
You are a customer support agent. The user's tier,
history, and past issues are provided in context.
Never ask them to repeat information you already have.
Open proactively if you can predict their issue.
`)Feels like a real assistant — knows your routine.
What Threadline remembers:
How it works:
Voice agents benefit most from Threadline's recurring request detection. When a user says "I always listen to news at 7am", that gets stored. The next morning at 7am, the agent proactively offers the briefing without being asked. Tone and pace adapt to stored speech preferences.
const { injectedPrompt } = await tl.inject(userId, `
You are a voice assistant. Respond concisely —
this will be converted to speech. Use the user's
stored schedule and recurring requests to be proactive.
`)User context travels between agents automatically.
What Threadline shares:
How it works:
Agent A and Agent B each have their own API key and agent ID, but both are granted access to the same user's context (with different scopes). When the user moves from Agent A to Agent B, Agent B calls inject() and already knows everything Agent A learned. No recap, no dropped context.
// Grant Agent B access to relevant scopes only
await tl.grant({
userId,
agentId: agentBId,
scopes: ["communication_style", "ongoing_tasks"]
})
// Agent B's system prompt is already enriched
const { injectedPrompt } = await tl.inject(userId,
"You are taking over this conversation. " +
"Do not ask the user to repeat anything."
)Sells like a senior rep who never forgets a detail.
What Threadline remembers:
Objections: categorised as price, timing, competitor, or authority — and how each was handled
How it works:
Before every sales call, the agent is briefed on the prospect's deal stage, open objections, and what was promised last time. It opens with the follow-up, not a cold intro. Objection patterns are tracked across deals to surface what works.
const { injectedPrompt } = await tl.inject(userId, `
You are a sales assistant. The prospect's deal stage,
objections, and previous conversation are in context.
Always follow up on promised actions before anything else.
Handle objections using patterns that have worked before.
`)Every session builds on the last.
What Threadline remembers:
How it works:
Mastery scores update after every session based on performance — improving when the student solves independently, declining when they struggle. The next session automatically reviews topics with low mastery using spaced repetition intervals. The tutor never re-teaches what the student already knows.
const { injectedPrompt } = await tl.inject(userId, `
You are a tutor. The student's mastery levels and
struggle points are in context. Review low-mastery
topics first. Adapt your explanation style to what
has worked for this student before.
`)Stops producing generic output from session one.
What Threadline remembers:
How it works:
After a few sessions, Threadline has extracted a style fingerprint: average sentence length, formality level, vocabulary clusters. New drafts automatically match this fingerprint. The agent asks "more formal or casual?" only when the stored preference is ambiguous.
const { injectedPrompt } = await tl.inject(userId, `
You are a writing assistant. Match the user's stored
tone and style exactly. Use their vocabulary level
and sentence length. Write for their typical audience
unless told otherwise.
`)Every session fully briefed. No starting from scratch.
What Threadline remembers:
How it works:
Each session opens with a brief recap of where things stand — portfolio, recent changes, open recommendations. The agent can proactively flag if stored risk tolerance conflicts with a new request, without the user having to restate their profile.
const { injectedPrompt } = await tl.inject(userId, `
You are a financial advisor. The user's goals,
risk tolerance, and portfolio context are provided.
Always reference past advice before giving new
recommendations. Flag conflicts with stored preferences.
`)Coaching that actually compounds.
What Threadline remembers:
How it works:
Every workout is logged. The next session plan is generated using progressive overload principles applied to stored history. If the user rated the last session "too hard", load reduces automatically. Injuries are permanent flags — the agent never suggests exercises that conflict with them.
const { injectedPrompt } = await tl.inject(userId, `
You are a fitness coach. The user's workout history,
injuries, and goals are in context. Apply progressive
overload to last session's data. Never suggest
exercises that conflict with stored injuries.
`)Picks up exactly where the user left off.
What Threadline remembers:
How it works:
When a user returns after abandoning an onboarding flow, the agent resumes at the exact step they left — with all previously entered data pre-filled. If they abandoned at a complex step before, the agent proactively offers a guided walkthrough instead of presenting the raw form.
const { injectedPrompt } = await tl.inject(userId, `
You are an onboarding assistant. The user's progress
and partial data are in context. Resume from where
they left off. Never ask for information they've
already provided.
`)Never loses context between rounds.
What Threadline remembers:
How it works:
Before every candidate touchpoint, the recruiter agent is briefed on where the candidate is in the pipeline, what feedback has been given, and what follow-up is pending. Cross-candidate comparison uses stored position requirements to surface top fits automatically.
const { injectedPrompt } = await tl.inject(userId, `
You are a recruiting assistant. The candidate's
profile, pipeline stage, and interview feedback
are in context. Surface pending follow-ups first.
Compare against stored position requirements
when ranking candidates.
`)Building your first memory-aware chatbot
system + messages and returns a reply. Prove out tone and behaviour before wiring in Threadline.Introduce tl.inject() at the system layer.
Replace your static system prompt with:
const { injectedPrompt } = await tl.inject(userId, basePrompt)Use injectedPrompt as the system message you send to your model. The response may include cacheHint for OpenAI 24h prompt caching.
await tl.update({ userId, userMessage, agentResponse })This keeps the user's context fresh and lets Threadline learn their style, tasks, and preferences over time.
/account so they can see, edit, and delete their context. This is a critical trust signal.Threadline is designed for multi-agent ecosystems: multiple assistants, tools, and products sharing a single user context.
agent_id). This keeps audit logs and rate limits clean.Scope grants narrowly. When sharing context between agents, use specific scopes:
await tl.grant({
userId,
agentId: supportAgentId,
scopes: ["communication_style", "ongoing_tasks"],
})Your support agent doesn't need access to emotional state or unrelated preferences.
preferences or emotional_state when it materially improves the experience.Migrating from Zep to Threadline
If you're already using Zep or another memory API, migration typically looks like this:
communication_style, domain_expertise, preferences.ongoing_tasks.Backfill via a one-time script. Write a script that:
POST /api/context/update or uses the admin SDK to seed context objects.Flip your runtime integration. Replace Zep's read/write calls with:
const { injectedPrompt } = await tl.inject(userId, basePrompt)
await tl.update({ userId, userMessage, agentResponse })Turn off writes to Zep, keep reads temporarily.
For a short window, you may want to read from both systems while only writing to Threadline, then fully cut over once you're confident in the migration.