Pairing generative AI with Systematic Autonomous Machinery (SAM)—a fast, deterministic, typed decision layer for routing, scoring, confidence checks, and policy gates.
Large language models are extraordinary at open-ended reasoning, code generation, tool use, and explaining complex bugs. What they should not be doing is improvising routine routing, risk scoring, or policy enforcement in free-form prose.
Asking an LLM to repeatedly guess which terminal lane to use or whether a deployment is safe introduces latency, token waste, and unpredictability. AgentSam solves this by pairing generative AI with Systematic Autonomous Machinery (SAM)—a fast, deterministic, typed decision layer that handles routing, scoring, confidence checks, and policy gates before software takes action.
The Core Principle
Use the LLM for open-ended reasoning and generation; use typed decision primitives whenever the answer must fit a known shape and directly control system behavior.
user / repo / runtime / tool state
│
▼
AgentSam context
│
┌─────────┴─────────┐
│ │
▼ ▼
LLM reasoning typed decision
• explain • choose
• plan • score
• generate • gate
• edit • rank
• call tools • confidence
│ │
└─────────┬─────────┘
▼
action / tool
│
▼
terminal · skill · model
retrieval · workflow · deploy1. This Is Not Another Chat Model
The structured decision layer is never responsible for holding a conversation, scaffolding a React component, or authoring a database migration. Those remain pure LLM jobs.
Instead, its responsibility is tightly bounded: receive an explicit machine state, evaluate a constrained question, and return a typed result that software can execute immediately without parsing prose.
| Engineering Question | Execution Layer | Why |
|---|---|---|
| "Explain why this terminal session failed." | LLM | Requires open-ended synthesis and human-readable diagnosis. |
| "Which execution lane should handle this command?" | choice primitive | Finite set of known runtime targets (local, remote, sandbox). |
| "How risky is this deployment?" | score primitive | Maps observable repo and test metrics onto a bounded numeric rubric. |
| "Is confidence high enough to act without asking?" | gate primitive | Converts risk, reversibility, and policy into an explicit permission check. |
| "Rewrite this package boundary cleanly." | LLM + Tools | Requires multi-file code generation and architectural judgment. |
2. Where Typed Decisions Fit Inside AgentSam
Wherever possible outputs are constrained to a finite set or numeric rubric, AgentSam replaces open-ended generation with structured evaluation:
- Skills: Select the exact skill, slash route, or workflow from a known registry.
- Terminal: Choose between local, remote, or sandbox execution based on observed machine health.
- Retrieval: Route queries to memory, AST-RAG, documentation, repository indexes, or skip retrieval altogether.
- Models: Route tasks across fast, standard, heavy reasoning, or local offline models.
- Deploy: Score release readiness and enforce verification or human approval gates.
- Planning: Rank candidate actions during Goal-Oriented Action Planning (GOAP) or utility-based execution.
3. The Five Decision Primitives
Primitive 1: State
Decisions must be grounded in explicit, machine-readable facts rather than hidden prompt assumptions. A state object combines repository status, runtime health, user intent, tool availability, cost budgets, and security policies.
const state = {
intent: "inspect_repository",
repo: { dirty: true, tests: "unknown", packageCount: 31 },
terminal: { local: "healthy", remote: "healthy", sandbox: "available" },
policy: { allowProductionWrite: false }
};Primitive 2: Choice & Primitive 3: Score
A choice selects one winner from a finite candidate list, while a score maps current state onto a normalized 0..1 rubric so competing actions can be compared mathematically.
type ActionScore = {
action: string;
utility: number; // 0..1
risk: number; // 0..1
cost: number; // 0..1
reversibility: number; // 0..1
};Primitive 4: Gate & Primitive 5: Confidence
A gate turns a structured assessment into explicit permission to proceed, while confidence signals whether the agent should execute immediately, gather one more check, or escalate to the operator.
| Confidence Level | System Behavior |
|---|---|
| High | Proceed automatically when policy allows; record the decision and supporting evidence as a receipt. |
| Medium | Gather one additional piece of evidence, run a fast verification check, or compare top alternatives. |
| Low | Escalate to the user, defer execution, or route the problem to a stronger reasoning model. |
4. Eight Design Rules for Structured Systems
- 01. Constrain the output space: Use typed decisions only when legal outputs are genuinely bounded.
- 02. Keep state explicit: Never bury critical runtime facts inside sprawling system prompts.
- 03. Separate confidence from permission: High confidence never grants authority on its own—policy gates do.
- 04. Prefer deterministic checks: Never use learned judgment when a direct test or static check exists.
- 05. Reserve LLMs for synthesis: Keep generative models focused on code creation, explanation, and complex reasoning.
- 06. Record decisions as receipts: Every candidate set, chosen result, score, policy, and evidence source must remain inspectable.
- 07. Escalate uncertainty: Low confidence should automatically trigger evidence gathering, model escalation, or user input.
- 08. Decouple control from presentation: CLI, Studio, and mobile interfaces can render the exact same underlying decision receipt differently.

Written by InnerAnimalMedia
Architecting Systematic Autonomous Machinery (SAM), hybrid edge-to-local Go runtimes, and multi-domain editorial systems.



