Skip to content

Core AI Employees

antonyrag edited this page Aug 15, 2026 · 1 revision

Core Engine — AI Employees

Scope note: this page documents ragleap-core's engine (core/, channels/), not the ragleap-rag/ragleap-graph pip packages covered by the rest of this wiki. See Home for the packages wiki index.

Nine role-based AI agents (manager, secretary, CEO, sales, support, HR, finance, marketing, operations), each with its own personality and its own persistent, learned memory — single-tenant, BYOK, open in this repo since #130/#133.

What it actually is

Not a static system prompt per role. Each role has:

  • A personality — a fixed instruction block defining tone and focus
  • Role-scoped context — retrieved from a real pgvector-backed memory store (employee_memory table), combining owner instructions, business profile data, and learned patterns from past interactions
  • A business profile — owner-fillable fields (description, products, tone, language) plus an auto-learned summary that rebuilds from activity over time

How it wires into /chat

POST /chat?question=&role=support

When role is set, core/chat.py's _build_system_prompt() layers the role's personality and context on top of the standard grounding instructions — it doesn't replace them, so citation/no-hallucination behavior is preserved regardless of role.

Real gotcha found during development

A model's recency bias in long prompts means an instruction stated once near the top is often ignored in favor of instructions near the actual question. The fix (core/chat.py's _augment_query_with_reminder()) appends a short reminder directly onto the query text sent to generation — separate from the query used for embedding/retrieval. Full debugging writeup: Discussion #137.

Module layout

File What it does
core/employees/defaults.py 9 default roles, personalities, starter memory seeds
core/employees/profile.py Single-row business profile (get/update/auto-learned)
core/employees/roles.py Role CRUD, seeded on first /employees call
core/employees/memory.py pgvector-backed learned memory — semantic + tag search, DB-level dedup
core/employees/skills.py Role-scoped context retrieval for prompt injection
core/employees/learning.py Every learn_from_* entry point + auto_learn_from_all()

API routes

Route Purpose
GET /employees List roles (seeds 9 defaults on first call)
GET /employees/{role} Get one role
PATCH /employees/{role} Update a role's personality/channels/etc.
GET /employees/{role}/context See exactly what context a role would inject — useful for debugging
GET /profile Get the business profile
PATCH /profile Update owner-filled fields
POST /profile/learn Manually trigger a profile rebuild from current activity

What's still hosted-only

Multi-tenant per-workspace seeding, and integration with Manager AI (not yet open — see ROADMAP.md).

Open good-first-issues

  • #134 — test coverage for /chat with-role and without-role cases
  • #135 — example scripts

Clone this wiki locally