Public Defender Intelligence System
Six autonomous agents and a six-object ontology for case analysis, risk assessment, and precedent discovery on Palantir Foundry AIP
Overview
PDIS is a five-tab Workshop application built entirely on Palantir Foundry AIP. The system combines six autonomous agents with a six-object semantic ontology to enable public defenders to instantly retrieve case information, assess risk, discover applicable precedent, and predict outcomes with 93% grounding accuracy and 2.1-second end-to-end latency.
System Architecture
Six-Object Semantic Ontology
- Case: Master record including case_id, filing_date, jurisdiction, case_narrative, client_id, and narrative_embedding.
- Client: Defendant demographics, address, prior_record, conviction_count, and case_id (foreign key).
- Charge: Statute, severity, filing_date, statute_class, statute_text, and case_id (foreign key).
- Evidence: Type (physical, testimonial, documentary, digital), admissibility_status, chain_of_custody, and case_id (foreign key).
- Precedent: Citation, court, verdict, sentence_months, synopsis, synopsis_embedding, and applicability_tags.
- Outcome: Verdict (guilty/not guilty), sentence_months, sentence_type, and case_id (foreign key).
Five Workspaces
- Case Lookup: Master case details, timeline, links to charges, evidence, and outcomes.
- Charges: All charges filed against client, severity breakdown, statute text and history.
- Evidence: Evidence items, admissibility assessment, chain-of-custody validation, gaps flagged.
- Precedents: Applicable case law, court level, outcome, relevance ranking.
- Risk/Outcome: Risk score breakdown, confidence intervals, predicted outcome distributions, comparison to historical similar cases.
Six Autonomous Agents
Each agent is implemented as an AIP Action—a long-running, stateful workflow that chains Query Objects, Transform, Filter, Aggregate, and Join operations. Agents communicate via message passing through Foundry's event system.
Case Lookup Agent
Retrieves full case record by case_id. Executes JOIN across Case, Client, Charges, Evidence, Outcome. Returns denormalized view: case metadata, defendant history, all linked objects. Caches result for 60 minutes. Invoked first by every downstream agent.
Charge Assessment Agent
Classifies charge severity (MISDEMEANOR / FELONY) from statute code. Fetches statute text and prior conviction counts. Identifies applicable sentencing guidelines. Flags enhancements. Returns severity, applicable range, and prior-record context for risk scoring.
Evidence Synthesis Agent
Groups evidence by type (physical, testimonial, documentary, digital), validates chain of custody completeness, and assesses admissibility via field + rule-based heuristics. Ranks by impact (DNA > testimony > documentary). Invokes Risk Scoring Agent if gaps detected.
Precedent Discovery Agent
Performs hybrid search: structured match on applicability_tags + court level, semantic similarity on synopsis embeddings (0.75 threshold, 2x boost for tag matches). Ranks by composite score (0.4 × tags + 0.6 × similarity). Adapts threshold to 0.65 if fewer than 3 results.
Risk Scoring Agent
Computes numeric risk score (0–100) via: (prior_record × 0.30) + (charge_severity × 0.30) + (evidence_quality × 0.20) + (historical_outcome × 0.20). Derives confidence from k=5 nearest neighbors. Returns component breakdown and confidence interval. Every component traces back to ontology objects for explainability.
Outcome Prediction Agent
Identifies k=5 similar cases via semantic search, aggregates: P(guilty) = % of neighbors with guilty verdict. Estimates sentence via weighted median. Compares to risk scores; flags discrepancies for human review. Returns distribution with confidence intervals.
Inter-Agent Coordination
Agents communicate via message passing through Foundry's AIP event system. Example flow: User queries for outcome prediction → Outcome Prediction Agent invokes Case Lookup Agent (fetches case data) → Outcome Prediction Agent invokes Precedent Discovery Agent (finds relevant case law) → Outcome Prediction Agent invokes Risk Scoring Agent (computes risk factors) → agents aggregate results and return to Deal Room UI. Each agent call is logged with timestamp and input/output for auditability.
Deal Room Chatbot Integration
Users query via natural language in the Deal Room chat panel. NLU layer interprets intent and extracts entities (case_id, charge_type, etc.). Chatbot orchestrates agent invocation: if user says "What's the risk on this case?", chatbot passes case_ID to Risk Scoring Agent. If user says "Find similar cases", chatbot invokes Outcome Prediction Agent's similarity engine. Agents receive correct case context on every invocation via explicit case_ID parameter passing.
Technical Implementation
Platform: Palantir Foundry AIP
PDIS is built entirely within Foundry using:
- Ontology Objects: Six object types defined in Ontology Manager with enforced schemas. Link types enforce referential integrity (foreign keys at the Foundry level).
- Workspaces (AIP): Five custom Workspaces—Case Lookup, Charges, Evidence, Precedents, Risk/Outcome. Each Workspace composed of panels (cards, tables, charts) with live filtering and drill-down.
- Autonomous Agents (AIP Actions): Six agents implemented as AIP Actions. Each Action chains Query Objects, Transform, Filter, Aggregate, and Join steps. Actions are long-running (up to 5-minute timeout). State persisted between invocations.
- Vector Embeddings: OpenAI integration via AIP Connectors. Embeddings (1536-dim) computed for Case.case_narrative and Precedent.synopsis fields at ingest time using batch API. Stored as embedding fields in ontology objects.
- SQL Query Interface: Hybrid SQL + Vector Search. Query Objects support both structured SQL (SELECT, JOIN, WHERE) and vector similarity operations (COSINE_SIMILARITY, VECTOR_SEARCH).
SQL-Over-Embeddings Retrieval Architecture
Hybrid Query Engine: PDIS combines traditional SQL with vector similarity operations. The query planner chooses execution strategy based on predicate type:
Embedding & Performance
Batch Embeddings: At ingest, new Case/Precedent objects trigger batch embedding via OpenAI Batch API (not real-time, for cost efficiency). Vectors (1536-dim) are stored back to ontology objects. Foundry auto-indexes embedding fields with ANN search (faiss), enabling sub-100ms similarity queries on millions of vectors.
Agent Caching
Each agent maintains thread-safe LRU cache (1000 entries, TTL-based eviction). On cache miss, agents query Foundry and cache results.
Latency Optimization: 4.2s → 2.1s (50% Reduction)
- Baseline (4.2s): On-the-fly embeddings via OpenAI real-time API (~500ms per query).
- Opt 1 (3.1s): Pre-compute embeddings at ingest via Batch API. Save 1.1s.
- Opt 2 (2.5s): Vectorized similarity computation (numpy). Save 600ms.
- Opt 3 (2.1s): LRU agent-level cache (Case Lookup, Precedent Discovery). Save 400ms on 50% of queries. Parallel evidence/precedent fetching. Save 300ms.
Results & Validation
Grounding Accuracy (93%)
Test set: 15 representative cases across charge types (felony assault, theft, drug possession, DUI). For each case, agents executed in sequence:
- Case Lookup Agent returned correct Client, Charges, Evidence, Outcome.
- Charge Assessment Agent classified severity correctly and retrieved statutes.
- Evidence Synthesis Agent flagged admissibility issues matching discovery documents.
- Precedent Discovery Agent returned citations actually applicable to the charges.
- Risk Scoring Agent computed factors matching expert assessment.
- Outcome Prediction Agent produced distributions within 10% of actual verdict/sentence.
Failure modes (7% of predictions): Precedent misses when cases involved niche statutes without sufficient training precedent. Evidence synthesis sometimes over-flagged admissibility in complex chains. Risk scoring occasionally missed nuanced mitigating factors.
Latency: 2.1 Seconds
End-to-end: case selection → query → agent execution → display. Median 2.1s across 100 queries. P95: 3.2s, P99: 4.1s.
User Impact
- Case lookup: ~10 min manual search → <3s retrieval.
- Precedent discovery: hours of research → seconds of semantic search.
- Risk assessment: structured scoring for bail, plea, and trial strategy.
- Evidence gaps: automated flagging of missing items.
Deployment Status
Deployed to Foundry staging environment for evaluation. Five-tab Workshop live and tested with domain experts. Agentic workflows fully functional. Ready for integration into production public defender case management systems.
Technical Highlights
- Six-object semantic ontology with enforced relationships and embedding fields.
- Six autonomous agents orchestrated via Foundry AIP Actions with message-passing coordination.
- SQL-over-embeddings hybrid retrieval for structured + semantic search on case data.
- Agent-level LRU caching with configurable TTL (1000-entry cache per agent).
- Vectorized embedding operations using numpy batch processing (eliminating per-record Python loops).
- Parallel agent execution for evidence synthesis + precedent discovery (no data dependencies).
- 93% grounding accuracy validated on 15-case held-out test set.
- 2.1-second latency end-to-end (50% improvement via pre-computed embeddings, vectorization, and parallelization).
- Real-time collaboration via Deal Room chat with explicit case context passing.