Skip to content

AI Pipeline Architecture

LeanCore's AI pipeline uses a multi-model architecture where each stage has a specific role, just like a well-run team.

Pipeline Stages

StageRolePurpose
CoordinatorThe Manager PlansDeep thinking, intent analysis, retrieval planning
ExpertThe Employee WorksTool calling, data retrieval, answer assembly
ValidatorThe Manager ReviewsQuality gating, structured pass/fail assessment
GroundingThe Manager Fact-ChecksClaim extraction, evidence matching, answer repair

How It Flows

1. Coordinator (Planning)

The Coordinator receives the user's message and:

  • Analyses the complexity of the request
  • Identifies which data sources and tools will be needed
  • Creates a structured plan for the Expert to follow
  • Determines if the task requires tool usage or can be answered from context

2. Expert (Execution)

The Expert follows the Coordinator's plan:

  • Calls connected system tools to retrieve real data
  • Can make multiple tool calls in sequence
  • Assembles an evidence-backed response
  • Has access to all tools assigned to the specialist's role

3. Validator (Quality Review)

The Validator checks the Expert's work:

  • Evaluates completeness -- does it answer what was asked?
  • Checks quality -- is the response well-structured and professional?
  • Makes a structured pass/fail decision
  • If it fails, the Expert gets another attempt

4. Grounding (Fact-Checking)

The Grounding pipeline is LeanCore's hallucination defense:

  • Breaks the response into individual claims
  • Verifies each claim against the actual data retrieved during execution
  • Supported claims pass through unchanged
  • Unsupported claims are rewritten using actual evidence
  • Contradicted claims are removed entirely

Tool Routing

When a request comes in, the system automatically selects the right tools:

  1. The user's query is analysed for intent
  2. A vector search finds relevant tools from the specialist's toolkit
  3. Tools are ranked by relevance using routing cards (structured metadata)
  4. The most relevant tools are provided to the Expert

This means specialists don't need to be told which system to check -- the routing system finds the right tools automatically.

Observability

Every pipeline execution is traced end-to-end:

  • Each stage is logged with timing, model usage, and token counts
  • Tool calls are recorded with inputs and outputs
  • Quality scores and grounding results are captured
  • Full traces are available for debugging and performance analysis

LeanCore AI - Hire smarter. Not more.