l8agent

AI Agent

AI-powered chat orchestration with data masking.

Overview

l8agent provides AI-powered chat orchestration with built-in data masking, tool execution, and conversation persistence. Consumer projects integrate this library to add AI assistant capabilities to their systems. It connects to the Anthropic Claude API and exposes a tool loop that can query, create, update, and delete records through the Layer 8 service mesh.

Architecture

A client sends a message to the AgntChat endpoint. The chat orchestrator loads or creates a conversation, masks user input for PII and financial data, enters a tool loop (max 10 iterations), executes tool calls via the virtual NIC, masks tool results, unmasks the final response, persists messages to PostgreSQL, and returns the response.

Services

Conversations
AgntConvo -- Conversation metadata: title, status, timestamps. PostgreSQL backed.
Messages
AgntMsg -- Individual chat messages (user + assistant). PostgreSQL backed.
Prompts
AgntPrmpt -- Reusable system prompt templates. PostgreSQL backed.
Chat
AgntChat -- Orchestration facade. No direct persistence.

LLM Tools

The agent exposes 6 tools to the Claude model:

l8query
Execute SELECT queries with filtering, aggregates, GROUP BY
create_record
POST a new record to a service endpoint
update_record
PUT an updated record
delete_record
DELETE a record via query
list_modules
Return the service catalog (Tier 1 schema)
describe_model
Return field definitions for a model (Tier 2 schema)

Data Masking

All data flowing through the agent is classified and masked before reaching the LLM. Token maps are per-request -- masked values are unmasked only in the final response within the same request lifecycle.

Always Mask
SSN, tax ID, bank account. Replaced with [MASKED].
Mask Names
Names, emails, phones. Tokenized: [NAME_1], [NAME_2].
Mask Money
Salaries, amounts, prices. Tokenized: [MONEY_1], [MONEY_2].
Never Mask
IDs, dates, codes, enums. Passed through unchanged.

Integration

Initialization is split into two phases. Phase 1 activates ORM services (parallel with other services). Phase 2 activates the chat service after the introspector is fully populated, so the schema provider can build the system prompt with all registered types.

Requires the ANTHROPIC_API_KEY environment variable for Claude API access.

UI Components

Ships with desktop and mobile chat UI components:

l8agent-chat.js / l8agent-chat.css -- Desktop chat interface
l8agent-chat-m.js / l8agent-chat-m.css -- Mobile chat interface
Enum definitions, form configurations, and table column definitions for managing conversations and prompts