PAI Architecture

Multi-Platform AI Orchestration with Cross-Engine Coordination

5-Engine Architecture

Each engine specialized for different workloads, coordinated through PAI

Engine Model Specialty Use Cases
PNC (Claude Code) Claude Sonnet 4.5 Primary DA, Algorithm runner Complex multi-step work, orchestration, 129 skills, 33 agents
PNK (OpenCode) Provider-agnostic Multi-file architecture Large refactors (10+ files), TUI planning
PNG (Antigravity) Gemini Web research Research, fast factual lookup, latest docs
PNX (Codex CLI) GPT-4 Sandboxed execution Verification, adversarial testing
PNO (Ollama) Local (Llama/Gemma/Qwen) Cost-free inference Classification, JSON extraction, summarization

Cross-Engine Coordination

Seamless delegation between engines with provenance tracking

TypeScript Example: Delegation Pattern
// PNC orchestrates research across PNG and PNX
const research = await Task({
  subagent_type: "GeminiResearcher",
  description: "Web research on topic",
  prompt: "Research latest AI developments"
});

// PNC delegates complex multi-file work to PNK
await Bash({
  command: `opencode run "Refactor auth system across 15 files"`,
  workdir: "/project"
});

// PNC routes classification to PNO (zero cost)
const classification = await Bash({
  command: `bun PAI/Tools/Inference.ts --task fast_classification "..."`,
  workdir: "~/.claude"
});

// Cross-engine handoff with provenance
await Bash({
  command: `bun PAI/Tools/RecordRouter.ts handoff \\
    --from PNC --to PNX \\
    --task "Verify security findings" \\
    --context "assessment-2024-07-08"`,
  workdir: "~/.claude"
});

ICM Memory System

Persistent cross-engine state with Qdrant vector database

Durable Memory

Survives context resets and engine switches

  • Vector embeddings for semantic search
  • Session logs with full provenance
  • Entity relationships tracked
  • Cross-session context recovery

Qdrant Integration

High-performance vector database

  • 1536-dimension OpenAI embeddings
  • Indexed metadata filtering
  • Sub-100ms retrieval
  • Automatic batch processing

Topics & Sessions

Structured memory organization

  • session-log: Recent work history
  • entity-graph: People/companies/ideas
  • decisions: Architecture choices
  • findings: Security/research results
ICM Query Example
// Query recent sessions
await Bash({
  command: `icm query session-log --limit 10 --filter "tag:security"`,
});

// Semantic search across all topics
await Bash({
  command: `icm search "authentication implementation" --k 5`,
});

// Write to entity graph
await Bash({
  command: `icm write entity-graph --data '{
    "type": "company",
    "name": "Anthropic",
    "tags": ["AI", "LLM"],
    "relationships": ["builds:Claude"]
  }'`,
});

Knowledge Graph

Typed entities with relationship tracking

Entity Types

Four core entity types

  • People: Individuals and roles
  • Companies: Organizations and products
  • Ideas: Concepts and frameworks
  • Research: Papers and findings

Relationships

8 relationship types

  • works-at, founded, built
  • influenced-by, related-to
  • cited-in, implements
  • collaborates-with

2-Hop Traversal

Deep relationship exploration

  • Find indirect connections
  • Discover influence chains
  • Map collaboration networks
  • BM25-lite retrieval
Knowledge Graph Operations
// Add entity with relationships
await Bash({
  command: `bun PAI/Tools/KnowledgeGraph.ts add \\
    --type company \\
    --name "Anthropic" \\
    --relationships "built:Claude,founded-by:Dario-Amodei"`,
  workdir: "~/.claude"
});

// 2-hop traversal
await Bash({
  command: `bun PAI/Tools/KnowledgeGraph.ts traverse \\
    --start "Claude" \\
    --depth 2`,
  workdir: "~/.claude"
});

// Search entities
await Bash({
  command: `bun PAI/Tools/KnowledgeGraph.ts search \\
    --query "LLM safety" \\
    --limit 5`,
  workdir: "~/.claude"
});
Search coming soon...