|

Palantir Architecture: Foundry's Ontology as the Context Layer for the AIP Logic Agent Harness

Created Jun 23, 2026, 8:29 AM · Updated Jun 23, 2026, 8:29 AM

Palantir Architecture: Foundry's Ontology as the Context Layer for the AIP Logic Agent Harness

This document demonstrates how Palantir Foundry (the data and ontology backbone) seamlessly feeds structured context into Palantir AIP (the LLM orchestration and agent harness layer) using visual workflows and deterministic TypeScript functions.


1. Visual Agent Harness Configuration (AIP Logic UI)

In the AIP Logic user interface, developers construct a visual, deterministic tree of operational steps called an Agent Framework rather than writing raw, unguided prompt chains.

Use code with caution.[ Input Node ] ──> [ Context Node (OAG) ] ──> [ LLM Engine Block ] ──> [ Ontology Action ](Ticket ID) (Binds Foundry Object) (Claude 3.5 Sonnet) (Secure Write-back)

  • The Input Node: Captures incoming variables (e.g., a customer support ticket ID or an automated machine sensor alert).
  • The Context Node (Foundry Link): The developer maps the input to a specific Ontology Object Type (e.g., Flight). AIP automatically binds the incoming ID to its respective object properties and relationships in Foundry.
  • The LLM Block: The designer assigns an enterprise-approved model and configures the foundational prompt template.
  • The Tool/Action Node: The designer grants the LLM conditional access to an Ontology Action (e.g., rebookPassenger()). The LLM cannot write custom database code; it can only trigger this pre-validated, secure execution block.

2. Programmatic Harness Engineering (TypeScript Functions)

When a workflow requires advanced conditional logic, dynamic memory manipulation, or programmatic tools, developers implement Palantir Functions using TypeScript. This code runs securely inside the platform infrastructure.

The following script illustrates how an AIP-managed function queries the Foundry Ontology to perform Ontology-Augmented Generation (OAG) while keeping the LLM strictly within deterministic enterprise guardrails.

import { Function } from "@link/functions-api";
import { Objects, Flight } from "@link/ontology";
import { GenerativeAI, ModelIdentifier } from "@link/aip-api";

export class FlightAssistantFunctions {

    /**
     * Orchestrates an LLM invocation by wrapping it inside a deterministic 
     * Foundry data harness to evaluate flight impacts and recommend actions.
     * 
     * @param flightId The unique primary key of the Flight object in the Ontology.
     * @returns The structured remediation assessment from the harnessed LLM.
     */
    @Function()
    public async analyzeFlightDelayAndSuggestAction(flightId: string): Promise<string> {
        
        // 1. Resolve the concrete business object compiled inside Palantir Foundry
        const flightObject: Flight | undefined = Objects.Flight.get(flightId);
        
        if (!flightObject) {
            throw new Error(`Flight with ID ${flightId} does not exist in the Enterprise Ontology.`);
        }

        // 2. Accumulate relational graph context from the semantic layer
        const linkedPassengers = flightObject.passengers.all();
        const delayMinutes = flightObject.delayMinutes ?? 0;
        
        // 3. Assemble a highly structured, deterministic prompt environment (The Harness)
        const promptContext = `
            You are an automated operations assistant analyzing Flight ${flightObject.flightNumber}.
            
            Current Operational Context:
            - Delay Duration: ${delayMinutes} minutes.
            - Impacted Passenger Count: ${linkedPassengers.length}.
            
            Strict Operational Rules:
            1. Only suggest passenger rebooking procedures if the Delay Duration exceeds 120 minutes. 
            2. Do NOT invent alternative flights or hallucinate connection windows. 
            3. Rely exclusively on the data provided above.
        `;

        // 4. Dispatch the payload to the LLM via AIP's managed gateway
        // This abstracts token constraints, handles API retries, and enforces system security
        const aiResponse = await GenerativeAI.getLLM(ModelIdentifier.CLAUDE_3_5_SONNET)
            .generateText({
                prompt: promptContext,
                temperature: 0.1, // Set intentionally low to maximize determinism
                maxTokens: 500
            });

        return aiResponse.text;
    }
}

3. Active Platform Guardrails

When this code or its equivalent UI layout executes, Palantir handles the operational infrastructure through three built-in governance layers:

  • Token Isolation: The LLM never scans raw database columns or un-indexed tables. It only receives the specific, sanitized string payloads exposed via the user's active access permissions.
  • Deterministic Verification: If the LLM generates a structured output recommending an action, AIP Logic parses the parameters against the strict schema definitions of the Ontology Action Type before allowing data to be modified.
  • Continuous Regression Testing: Developers use AIP Evals to run hundreds of historical data permutations through this TypeScript logic simultaneously, establishing explicit regression metrics before rolling model upgrades into production environments.
Palantir Architecture: Foundry's Ontology as the Context Layer for the AIP Logic Agent Harness