AI and Automation
AI as Actor
AI as an actor, not the controller
Loop Engine treats AI the same way it treats humans and automation: as an attributed actor constrained by transitions and guards.
What AI can do
- inspect loop state in your application layer
- recommend transitions with evidence
- execute transitions where
allowedActorsincludesai-agent
What AI cannot do
- bypass
allowedActors - bypass hard guards
- modify loop definitions at runtime
- execute indefinitely if circuit-breaker constraints block it
AIAgentActor shape
1interface AIAgentActor extends ActorRef {2 type: "ai-agent"3 agentId: string4 gatewaySessionId: string5 recommendedBy?: string6}AI submission flow
1import { actorId, transitionId } from '@loop-engine/core'2import { canActorExecuteTransition, buildActorEvidence, type AIAgentActor } from '@loop-engine/actors'3 4const agent: AIAgentActor = {5 type: 'ai-agent',6 id: actorId('agent:demand-forecaster'),7 agentId: 'claude-3-5-sonnet',8 gatewaySessionId: session.id9}10 11const auth = canActorExecuteTransition(agent, transition)12if (auth.authorized) {13 const evidence = buildActorEvidence(agent, {14 ai_confidence: 0.94,15 ai_reasoning: 'Stock level below reorder point; lead time elevated',16 recommended_qty: 50017 })18 19 await engine.transition({20 aggregateId,21 transitionId: transitionId('trigger_po'),22 actor: { type: agent.type, id: String(agent.id) },23 evidence24 })25}