Runtime Connections
Anthropic / Claude
Archetype: AI (Actor) — returns AIAgentActor + AIActorDecision for governed engine.transition(...) submission.
What it does
@loop-engine/adapter-anthropic wraps the Anthropic Messages API as a Boss AI actor. The adapter calls Claude with loop context, parses the structured response, and returns an AIAgentActor plus AIActorDecision ready for runtime submission. Guards run after the adapter returns — Claude cannot bypass them.
Quick setup
-
Install
1npm install @loop-engine/adapter-anthropic2npm install @anthropic-ai/sdk -
Create the actor
1import { createAnthropicActorAdapter } from "@loop-engine/adapter-anthropic";23const adapter = createAnthropicActorAdapter({4 apiKey: process.env.ANTHROPIC_API_KEY!,5 model: "claude-opus-4-6"6}); -
Submit to a loop transition
1"cmt">// @no-typecheck2const { actor, decision } = await adapter.createSubmission({3 loopId: "procurement",4 loopName: "SCM Procurement",5 currentState: "pending_analysis",6 availableSignals: [7 {8 signalId: "submit_recommendation",9 name: "Submit Recommendation",10 allowedActors: ["ai-agent"]11 }12 ],13 instruction: "Analyze demand data and recommend a purchase order.",14 evidence: { demandForecast: 0.91, currentStock: 38 }15});1617await loopSystem.engine.transition({18 aggregateId: "procurement-1",19 transitionId: decision.transitionId,20 actor,21 evidence: decision22});
How it works
- Builds a structured prompt from
LoopActorPromptContext - Calls
client.messages.create(...)with loop context - Parses JSON and validates
signalId+confidence - Computes SHA-256
promptHash - Returns
AIAgentActor(provider: "anthropic") +AIActorDecision - Caller submits to runtime and guards evaluate after submission
Configuration reference
| Option | Type | Default | Description |
|---|---|---|---|
| modelId | string | claude-opus-4-6 | Anthropic model ID |
| maxTokens | number | 1024 | Max tokens in response |
| systemPrompt | string | — | Optional system prompt prepended to loop context |
| confidenceThreshold | number | 0.7 | Minimum confidence required (0–1) |
Troubleshooting
ActorDecisionError: INVALID_SIGNAL— Model returned a signal not present inavailableSignals; tighten instruction language around allowed signals.ActorDecisionError: INVALID_CONFIDENCE— Confidence was outside 0–1; include "confidence must be between 0 and 1" insystemPrompt.ActorDecisionError: API_ERROR— CheckANTHROPIC_API_KEYand model ID validity.