Skip to content
HARBAN AI LABS

AI engineering

AI engineering, evaluation first

How we design LLM applications, agents and retrieval systems: the principles we hold to, three reference architectures, and the components each kind of system typically includes. These are our design defaults — not client case studies.

Status. Our engineering service lines are planned: we are designing them and are not yet taking engagements. Each one shows its status on its service page.

Principles

Five principles we design to

They apply to every system on this page and settle many design trade-offs in advance.
  1. Evaluation first

    Agree how success will be measured before building — a representative test set, a held-out split and acceptance thresholds — then check every prompt, model or code change against them.

  2. Least privilege for agents

    Agents get the smallest tool surface that does the job: typed tool inputs, scoped credentials, explicit stop conditions, and a person’s approval before anything irreversible.

  3. Observability

    Every model call and tool call is traced with inputs, outputs, cost and latency, so a failure can be reproduced, explained and added to the test set.

  4. Simplest design that works

    Deterministic code where it is enough, a fixed workflow before an agent, one model call before a chain. When a simpler design meets the requirement, we recommend it.

  5. Provenance

    Model identifiers, prompts, data versions and settings are recorded with every result, so any number we report can be traced back to how it was produced.

Reference architectures

Three systems, drawn minimally

The shapes we start from. Each diagram shows structure and control points, not a specific product or vendor; real designs add what the requirements demand and nothing more.

Reference architecture 1

Agent loop with explicit controls

An agent is a loop: the model proposes an action, the system decides whether it may run, and the result feeds the next step. The controls are enforced in code outside the model, so nothing the model writes can switch them off.

Agent loop with a stop check, a permission check, human approval for irreversible actions, and a trace lognoyesallowedapprovedrepeat until stopTask or requestModelproposes the next actionStop condition met?done · budget spent · errorFinal answeror hand-offto a personPermission checktool allowed · args validHuman approvalirreversible actionsTool callleast-privilege credentialsObservationresult returned to the modelTrace logevery step recorded

Dashed outline: a control point the agent cannot skip.

Figure 1 Agent loop. The stop check, permission check and human approval are enforced in code, outside the model.

Text description

  1. A task or request starts the loop.
  2. The model proposes the next action.
  3. Stop check: if the task is done, the step or cost budget is spent, or an error occurs, the loop ends with a final answer or a hand-off to a person.
  4. Permission check: the action must use an allow-listed tool with arguments that pass validation. Irreversible actions first go to a person for approval; a declined action is reported back to the model instead of running.
  5. The tool runs with least-privilege credentials.
  6. The result returns to the model as an observation, and the loop repeats.
  7. Every step — model calls, tool calls, approvals, cost and latency — is recorded in a trace log.

Reference architecture 2

RAG pipeline with citations

Retrieval-augmented generation gives the model passages retrieved from your documents at answer time, so it does not rely only on what it learned in training. A wrong answer can come from retrieval (the right passage never reached the model) or from generation, so the two are measured separately.

Retrieval-augmented generation pipeline: offline indexing, per-query answering with citations, and evaluationIndexing · offlineAnswering · per queryanswerspassagesIngestparse · keep permissionsChunkpassages + source metadataIndexLexicalVectorRetrievehybrid · permission-filteredQuestionRe-rankkeep the most relevant passagesGenerate with citationsrefuse without evidenceEvaluate on every changeretrieval: right passages found?answers: faithful to citations?
Figure 2 RAG pipeline. Indexing runs offline; answering runs per query; evaluation checks retrieval and answers separately.

Text description

  1. Ingest: source documents are parsed, keeping their access permissions.
  2. Chunk: documents are split into passages with source metadata.
  3. Index: each passage is indexed twice — lexically (by keywords) and as a vector (by meaning).
  4. Retrieve: for each question, candidates come from both indexes, filtered to what the person asking is allowed to see.
  5. Re-rank: candidates are re-scored and only the most relevant passages are kept.
  6. Generate: the answer cites the passages it used, or the system declines when the evidence is missing.
  7. Evaluate on every change: did the right passages come back, and is each answer faithful to the passages it cites?

Reference architecture 3

Evaluation harness

The harness that turns “it seems better” into a measurement. In our design it comes first: it is built before the system it measures, and handed over with it.

Evaluation harness: versioned test set, runner with fixed settings, validated graders, results store with logs, and a report whose failures become new test casesfailures become new test casesTest setversioned · held-out splitRunnerfixed, recorded settingsrepeated runsSystemunder testGradersexact checks where possibleLLM judges only once validatedHumanlabelsResults storescores + settingsfull run logsReportscores with uncertaintyfailure analysis
Figure 3 Evaluation harness. Settings are fixed and recorded; failures found in reports become new test cases.

Text description

  1. Test set: versioned cases, with a held-out split that is never used for tuning.
  2. Runner: executes the system under test with fixed, recorded settings, repeating runs to measure variation.
  3. Graders: exact checks wherever possible; an LLM judge is used only after its agreement with human labels has been checked.
  4. Results store: scores, settings and full run logs, so every number can be traced.
  5. Report: scores with uncertainty and an analysis of failures.
  6. Failures found in reports are added to the test set.

Capability matrix

What each kind of system would include

The components our design would typically include in each kind of system. It records our defaults, not past client work; the engineering service lines are planned, and any future engagement would be scoped individually.
Kinds of system, by the components our design would typically include. Each cell reads Always, When needed or Rarely.
Kind of systemModel API layerstructured output, retries, fallbacksRetrievallexical + vector index, re-rankingTools & permissionstyped tools, scoped credentialsHuman reviewapprovals or exception queueEvaluation suitetest set, graders, CI gateTracing & monitoringfailures, cost, latencyProvenanceversioned prompts, data, model IDs
LLM features & applicationsLLM application developmentPlannedAlwaysWhen neededWhen neededWhen neededAlwaysAlwaysAlways
Tool-using agentsAI agent engineeringPlannedAlwaysWhen neededAlwaysWhen neededAlwaysAlwaysAlways
RAG & knowledge systemsRAG & knowledge systemsPlannedAlwaysAlwaysRarelyWhen neededAlwaysAlwaysAlways
Automation & document workflowsAI automation & data workflowsPlannedAlwaysWhen neededWhen neededAlwaysAlwaysAlwaysAlways
Evaluation harnessesLLM & model evaluationPlannedAlwaysRarelyRarelyWhen neededAlwaysAlwaysAlways
PrototypesPrototypes & proofs of conceptPlannedAlwaysWhen neededWhen neededWhen neededAlwaysWhen neededAlways
Always
Part of our default design for this kind of system.
When needed
Included when the requirements call for it.
Rarely
Not usually part of this kind of system.
Planned
Being designed. Not yet offered — register interest via Work with us.

Related reading

Research and guides behind this practice

Paper breakdowns and insights on AI engineering, agents, retrieval and evaluation.
All insights

Model registry/models
Benchmarks/benchmarks
Paper breakdowns/research
AI tools directory/tools
Work with us/work-with-us