Skip to main content
Contexts are the knowledge layer of IMP. This tutorial walks you through two complete context definitions that represent common real-world shapes: a large, externally synced collection that uses semantic retrieval, and a small, always-included memory collection where every item is injected on every request regardless of the query.

Prerequisites

What you will build

  1. support_tickets_context — a context backed by an embedding model and a BullMQ queue, with an enum status field and a file attachment field, using the markdown chunker and retrieval cutoffs.
  2. team_memory_context — a small context where items are always injected into the agent’s context window, independent of the query, using calculateVectors: "always" and a high maxRetrievalResults.
1

Register an embedder queue

Both contexts share the same embedding queue. Register it at the top of src/contexts/index.ts:
src/contexts/index.ts
See Queues and workers for the full sizing formula. See ExuluQueues — configuration for every parameter.
2

Define the support tickets context

This context models tickets pulled from a generic support system — a collection that grows to thousands of items and needs efficient semantic retrieval:
src/contexts/index.ts (continued)
A few points about the choices above:The attachment field holds a user-uploaded (or source-written) file. The processor reads it via a presigned URL and writes the derived fields (extracted_text, processed_hash) — those are the fields marked calculated: true. For file fields the actual column is attachment_s3key — IMP appends _s3key automatically.
3

Define the team memory context

The memory context stores short items — preferences, decisions, recurring instructions — that should always accompany the agent’s context window, regardless of what the user asked:
src/contexts/index.ts (continued)
calculateVectors: "always" means IMP embeds immediately whenever an item is created or updated, without needing a processor or manual trigger. Because items in this context are short and infrequent, inline embedding is fast enough; no queue is needed.
“Always include” behavior is a retrieval-side concern: the agent’s retrieval configuration controls whether a context is queried and how many results it injects. maxRetrievalResults: 50 with a large limit ensures the agent sees every item in the collection, which is small by design (keep it under a few hundred items). For the agent workbench configuration, see Knowledge.
4

Export and register both contexts

src/contexts/index.ts (continued)
src/exulu.ts
The contexts object key matches the context id by convention — the key itself is not used by the framework, but matching them makes the export readable and consistent.
5

Verify the contexts appear in the UI

Start the server:
Open the IMP admin interface and navigate to Build → Knowledge. Both support_tickets_context and team_memory_context appear in the library. The Pipeline tab for each shows the configured stages.

What you built

  • support_tickets_context — a semantic context with enum and file fields, a markdown chunker, a BullMQ embedder queue, and tight retrieval cutoffs.
  • team_memory_context — an always-available memory context that embeds inline on every write and returns up to 50 items per retrieval.

Next steps

Data sources and sync

Add a source that pulls tickets from an external API on a cron schedule.

Custom processors

Transform uploaded PDFs into structured fields and trigger embeddings.

ExuluContext — configuration

Full reference for every constructor option.