Core Concepts
Agents and RAG
What Agent Frameworks Do
Agent frameworks like LangGraph, OpenAI Assistants, and custom agent loops focus on retrieving context, selecting tools, chaining operations, and generating recommendations from retrieved information.
They are excellent at reasoning. They are not designed to govern whether the resulting action is authorized, attributable, or auditable.
The Governance Gap
A typical agentic flow:
1Knowledge Base2 ↓3RAG Retrieval <- context retrieval4 ↓5LLM / Agent Reasoning <- recommendation6 ↓7Tool / API Execution <- actionThis works for low-risk autonomous tasks.
In enterprise production - supply chain, financial approvals, healthcare, infrastructure - the gap between "agent recommends" and "system executes" needs an explicit governance layer.
Where Loop Engine Fits
1Knowledge Base2 ↓3RAG Retrieval4 ↓5LLM / Agent Reasoning6 ↓7Loop Engine <- decision governance8 ↓9Workflow ExecutionThe agent's recommendation becomes a proposed transition in a Loop Engine loop. Guards evaluate it. A human approves when policy requires. The action executes only after the loop allows it.
RAG Outputs as Evidence
RAG systems already produce high-value evidence: retrieved documents, confidence scores, and graph relationships.
Loop Engine attaches this context directly to transitions as structured evidence, creating a permanent record of what the model used, what it recommended, and why the system allowed the action.
Code Example
1"cmt">// @no-typecheck2import Anthropic from "@anthropic-ai/sdk";3import { createAnthropicActorAdapter } from "@loop-engine/adapter-anthropic";4import { createLoopSystem } from "@loop-engine/sdk";5 6const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });7const adapter = createAnthropicActorAdapter(anthropic, { modelId: "claude-opus-4-6" });8const { engine } = await createLoopSystem({ loops: [/* procurement loop */] });9 10const ragResults = {11 retrievedDocs: 12,12 confidence: 0.84,13 ragSource: "vendor-policy-kb"14};15 16const { actor, decision } = await adapter.createSubmission({17 loopId: "procurement",18 loopName: "SCM Procurement",19 currentState: "pending_analysis",20 availableSignals: [{ signalId: "submit_recommendation", name: "Submit Recommendation" }],21 instruction: "Recommend whether to proceed with purchase order issuance.",22 evidence: { ...ragResults }23});24 25await engine.transition({26 aggregateId: "PO-10042" as never,27 transitionId: "submit_recommendation" as never,28 actor,29 evidence: { ...decision, ragResults }30});Commerce Chain and Loop Engine
Loop Engine is the runtime that powers the Commerce Chain platform. Each @betterdata/scm-* and module declares how it participates in loops using a from —a typed map of which domain events the module handles and which loop IDs it joins.