AIPCore ConceptsAug 1, 2026

How to Add Long-Term Memory to Foundry AIP Agents (Embedding + Retrieval )

In this video, "How to Add Long-Term Memory to Foundry AIP Agents (Embedding + Retrieval)" by Ontologize, former Palantir engineers demonstrate how to build a dynamic, self-improving AIP Agent in Palantir Foundry [00:00].

By combining AIP Logic, Vector Embeddings, and Ontology Actions, the agent captures human conversational preferences, generates vector embeddings on the fly, persists them as Ontology objects, and retrieves relevant historical context for future conversations [00:15, 01:36].


Architectural Process Map: Dynamic Memory & RAG Retrieval Flow

This architecture transforms ephemeral chat messages into persistent, vector-indexed memory records without batch pipeline overhead [02:51].

              PALANTIR AIP AGENT LONG-TERM MEMORY ARCHITECTURE
┌─────────────────────────────────────────────────────────────────────────────┐
│ [ 1. Conversational Input & Tool Execution ]                                 │
│   ├── User Chat: "Remember I'm picky about cheeses... hate blue cheese"     │
│   └── Agent Intent Recognition ──> Invokes Action Tool                       │
└──────────────────────────────────────┬──────────────────────────────────────┘
                                       │
                                       ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ [ 2. AIP Logic On-the-Fly Vectorization Pipeline ]                          │
│   ├── Step 2a: Convert Memory String ──> Array Block `[memory_text]`        │
│   ├── Step 2b: Call Embedding Function `text-embedding-ada-002`             │
│   ├── Step 2c: Flatten 2D Struct Array ──> `number[]` Vector Array           │
│   └── Step 2d: Execute Ontology Action `Create Agent Memory`                 │
└──────────────────────────────────────┬──────────────────────────────────────┘
                                       │
                                       ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ [ 3. Ontology Persistence Layer ]                                           │
│   └── Backing Edit-Only Object: `Agent Memory`                              │
│       ├── `memory_id`   : String (Primary Key)                              │
│       ├── `memory_text` : String                                            │
│       ├── `memory_title`: String (Generated by Agent)                       │
│       ├── `embedding`   : Vector (Model: `text-embedding-ada-002`)         │
│       └── `created_at`  : Timestamp                                         │
└──────────────────────────────────────┬──────────────────────────────────────┘
                                       │
                                       ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ [ 4. Downstream Semantic Retrieval (RAG Query) ]                            │
│   ├── User Query: "Recommend a tasty fruit and cheese salad for me"         │
│   ├── Real-Time Semantic Search over `Agent Memory` (Vector Match)          │
│   └── Informed Response: Recommends Goat/Feta, excludes Blue/Iceberg        │
└─────────────────────────────────────────────────────────────────────────────┘


Step-by-Step Guidance: Building Long-Term Agent Memory

  1. Create Memory Object Type in Ontology Manager: Construct an edit-only backing object type with vector properties.
  2. Open Palantir Foundry, press Ctrl + J (or J), and launch Ontology Manager [02:40].
  3. Click New $\rightarrow$ Object Type and select your target project folder (e.g., AIP Agents Project) [03:03].
  4. Name the backing dataset Memory Backing Data Set and display name Agent Memory (Icon: Brain) [03:11, 03:49].
  5. Define properties [03:58]:
  • memory_id (String) — Primary Key [03:58].
  • memory_text (String) [03:58].
  • memory_title (String) [04:25].
  • embedding (Vector) — Must select Vector data type [04:31].
  • created_at (Timestamp) [04:44].
  1. Configure Vector Model: Under property warnings, associate the embedding property with the embedding model text-embedding-ada-002 [05:11, 05:32].

  2. Doctor Out-of-the-Box Action: Open Create Agent Memory, set created_at to auto-populate via current time, and save changes [05:43, 06:16].

  3. Build Real-Time Embedding Pipeline in AIP Logic: Build logic block to wrap strings into arrays, embed, and flatten vectors.

  4. Press Ctrl + J and open AIP Logic [06:35].

  5. Click Create New Logic Function and name it embed_and_create_memory [06:44].

  6. Add Input Variables: memory_text (String) and memory_title (String) [06:54].

  7. Step A (Wrap Array): Search blocks for Create Array, set element to memory_text [08:24]. (Embedding models expect array inputs) [08:09].

  8. Step B (Generate Embedding): Search functions for ada-2 and select text-embedding-ada-002 (returns generic embedding response struct) [09:20]. Pass the array output from Step A as input [09:40].

  9. Step C (Flatten Array): Search blocks for Array Flatten [10:35]. Select the embeddings array field inside the returned struct to flatten the 2D array into a 1D number[] array [10:55].

  10. Step D (Trigger Edit Action): Add block Create Agent Memory action [11:22]:

  • memory_text $\rightarrow$ memory_text input [11:32].
  • memory_title $\rightarrow$ memory_title input [12:03].
  • embedding $\rightarrow$ Array Flatten output [11:43].
  1. Click Save and Publish $\rightarrow$ Click Create Action [13:14, 13:50]. Name the published action type Create and Embed Agent Memory and save to Ontology [14:05, 14:22].

  2. Configure AIP Agent Studio with Action & Retrieval: Bind vector action and semantic ontology retrieval context to agent.

  3. Press Ctrl + J and open AIP Agent Studio [14:29].

  4. Click Create New AIP Agent and name it Agent with a Long-Term Memory [14:48].

  5. Add Action Tool: Under Tools, click Add Action $\rightarrow$ Select Create and Embed Agent Memory [15:54]. Set input parameter to Agent Decides Value [16:27].

  6. Add Retrieval Context: Click Add Retrieval Context $\rightarrow$ Ontology Context $\rightarrow$ Select Agent Memory object type [17:14, 17:31].

  7. Write System Prompt [16:34]:

"You are a conversational agent. Answer questions based on the information you have available. When the user asks you to remember something, invoke the tool /Create and Embed Agent Memory to create a memory."

  1. Test Conversational Memory & Retrieval: Inject user preferences and test vector context retrieval.
  2. Inject Memory: In chat, type [17:40]:

"Remember I like pomegranates and persimmons. I really hate oranges and fruit salads, but they are okay for baking."

  1. Verify the agent triggers the action tool in real-time, generating a vectorized Agent Memory object visible in Object Explorer [18:12, 18:35].
  2. Inject Additional Memory: Type preference updates for salad vegetables (e.g., likes cherry tomatoes, hates iceberg lettuce/blue cheese) [18:55].
  3. Query RAG Memory: Ask "I'm looking for a fruit salad recipe, what do you recommend?" [19:26].
  4. Observe the agent running real-time semantic retrieval against the embedded memories to synthesize a tailored recommendation excluding disliked ingredients [19:33, 19:44].

Comprehensive Use Case Analysis

Beyond recipe recommendations, this pattern provides a blueprint for injecting human feedback into operational systems [20:09].

Real-World Enterprise Applications

DomainHuman Feedback IngestionAIP Agent Real-Time VectorizationDownstream Business Impact
Supply Chain & ProcurementPurchaser notes: "Supplier X frequently delays shipments during Q4 weather disruptions." [20:09]AIP Logic embeds notes and creates a Vendor Preference Memory object record [11:22].When querying routing recommendations, the agent automatically avoids at-risk suppliers during winter months.
Customer Service OperationsRepresentative notes: "Client prefers phone communication over email; highly sensitive to billing discrepancies." [01:03]Generates Client Interaction Memory with real-time vector embeddings [08:24].Agent summarizes account history for oncoming reps, highlighting communication protocols and sensitive topics.
Maintenance & Fleet EngineeringSupervisor notes: "Turbine Unit 4 requires manual pressure check prior to cold start sequence." [20:09]Writes vector-indexed Maintenance Exception Memory object [14:05].Agent alerts technicians during work order generation, embedding safety caveats into operational procedures.

Key Technical Trade-Offs: SQL vs. Vector Semantic Retrieval

The video highlights why vector semantic retrieval is preferred over standard SQL object queries for agent memory [15:26]:

                     MEMORY RETRIEVAL STRATEGY COMPARISON
┌────────────────────────────────────────┬────────────────────────────────────────┐
│   SQL OBJECT QUERY (`queryObjects`)    │      VECTOR SEMANTIC RETRIEVAL         │
├────────────────────────────────────────┼────────────────────────────────────────┤
│ • Requires exact string/column matches  │ • Captures intent, synonyms & context  │
│ • Hard to query unstructured text      │ • Matches queries like "salad ideas"   │
│ • Scale degrades with complex filters   │   to preferences like "hates iceberg"  │
│ • Rigid schema requirements            │ • High performance at scale (KNN)      │
└────────────────────────────────────────┴────────────────────────────────────────┘


Process Audit Report

================================================================================
                        PROCESS AUDIT & VERIFICATION REPORT
================================================================================
Audit Target: YouTube Guidance & Use Case Analysis (_g-syZO6A20)
Auditor Skill: Process Audit
Verification Status: PASSED (100% Accuracy & Detail Alignment)

--------------------------------------------------------------------------------
[AUDIT CHECKPOINT 1: ACCURACY OF TRANSCRIPT DETAILS]
--------------------------------------------------------------------------------
✔ OBJECT TYPE CONFIGURATION:
  - Backing dataset accurately identified (`Memory Backing Data Set`) [00:03:11].
  - Object naming (`Agent Memory`) and brain icon selection verified [00:03:49].
  - Required properties verified: `memory_id` (PK), `memory_text`, `memory_title`, `embedding` (Vector), `created_at` (Timestamp) [00:03:58, 00:04:44].
  - Associated model verified: OpenAI `text-embedding-ada-002` [00:05:32].

✔ AIP LOGIC PIPELINE DETAILS:
  - Input variables verified: `memory_text` and `memory_title` [00:06:54].
  - Array wrapping step verified: Create Array block used because embedding model expects array inputs [00:08:24].
  - Embedding block verified: `ada-2` generic embedding response [00:09:20].
  - Flattening block verified: Array Flatten on `embeddings` struct field to output 1D `number[]` array [00:10:35, 00:10:55].
  - Action wrapper name verified: `Create and Embed Agent Memory` [00:14:05].

✔ AGENT STUDIO WIRING & PROMPT:
  - Tool creation verified: Action tool with input set to "Agent Decides Value" [00:15:54, 00:16:27].
  - Context setup verified: Ontology retrieval context bound to `Agent Memory` [00:17:31].
  - Prompt instructions verified: Explicit instruction to invoke action tool upon detecting "remember" intent [00:16:34].

--------------------------------------------------------------------------------
[AUDIT CHECKPOINT 2: FORMAT & VISUAL COMPLIANCE]
--------------------------------------------------------------------------------
✔ STRUCTURAL LAYOUT:
  - Process map built with clear ASCII workflow diagrams.
  - Step-by-step guidance formatted using valid <Sequence> and <Step> tags with titles/subtitles.
  - Architectural comparison tables and use case breakdowns included.
  - Valid images rendered with self-closing <Image /> tags (Law 3a compliant).
================================================================================