<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cristian Diaz Koziuk</title>
    <description>The latest articles on DEV Community by Cristian Diaz Koziuk (@crdkzk).</description>
    <link>https://dev.to/crdkzk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4004085%2F2de1b304-ab66-41ce-a676-051f35b05969.png</url>
      <title>DEV Community: Cristian Diaz Koziuk</title>
      <link>https://dev.to/crdkzk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/crdkzk"/>
    <language>en</language>
    <item>
      <title>Let your LLM take real-world actions — without giving it the last word</title>
      <dc:creator>Cristian Diaz Koziuk</dc:creator>
      <pubDate>Fri, 26 Jun 2026 13:35:02 +0000</pubDate>
      <link>https://dev.to/crdkzk/let-your-llm-take-real-world-actions-without-giving-it-the-last-word-3ab6</link>
      <guid>https://dev.to/crdkzk/let-your-llm-take-real-world-actions-without-giving-it-the-last-word-3ab6</guid>
      <description>&lt;p&gt;Most "AI agent" tutorials wire the model straight to execution:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;user asks → model decides → system runs&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's fine for a demo. It's dangerous the moment an action can charge a card,&lt;br&gt;
send over a paid channel, publish content, or breach a plan limit. "The model&lt;br&gt;
decided" is not an acceptable audit trail.&lt;/p&gt;

&lt;p&gt;I kept rebuilding the same guardrails across projects, so I extracted the&lt;br&gt;
pattern: &lt;strong&gt;Safe Automation Control Plane (SACP)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea, in one line
&lt;/h2&gt;

&lt;p&gt;The AI proposes.&lt;br&gt;
Hard rules decide what's allowed.&lt;br&gt;
Validators decide what may execute.&lt;br&gt;
Executors only run validated decisions.&lt;/p&gt;

&lt;p&gt;The model never has authority. It optimizes inside a box that deterministic&lt;br&gt;
rules draw for it, and every decision is validated, cached, costed and audited&lt;br&gt;
before anything runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three composable pieces
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decision Engine&lt;/strong&gt; — turns any action into a validated, audited decision.
Rules first, AI second, validators last.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Model Layer&lt;/strong&gt; — the only place the LLM lives: model selection, caching,
usage metering, circuit breaking, schema validation, prompt-injection defense.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbound Gateway&lt;/strong&gt; — one controlled door for every external API call:
tokens, idempotency, retries, breaker, rate limit, cost ledger.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The part worth reading first: what broke
&lt;/h2&gt;

&lt;p&gt;This came out of a production system, so there's a &lt;a href="https://github.com/cristiandkzk/SACP/blob/main/docs/lessons-learned.md" rel="noopener noreferrer"&gt;lessons-learned doc&lt;/a&gt;&lt;br&gt;
of real bugs, not theory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model returned &lt;code&gt;expiresAt&lt;/code&gt; dates from its &lt;strong&gt;training cutoff&lt;/strong&gt; — already in
the past. Lesson: the AI doesn't know real time; normalize time fields
server-side.&lt;/li&gt;
&lt;li&gt;The policy engine &lt;strong&gt;silently allowed everything&lt;/strong&gt; because a lazy registry was
never initialized in tests. A "fail open" default is a loaded gun.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;refresh-token race&lt;/strong&gt;: two workers refreshing in parallel, the second
consuming a token the first already rotated, leaving the account dead. Fixed
with an atomic lease.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of these aren't AI bugs — they're the bugs of putting a non-deterministic&lt;br&gt;
component inside a deterministic, audited system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
npm install sacp-core

import { DecisionEngine, PolicyEngine } from 'sacp-core';

const policy = new PolicyEngine();
policy.register('router_ai.campaign_send', (snap) =&amp;gt; {
  const ctx = snap.context as { balance: number; cost: number };
  return ctx.balance &amp;gt;= ctx.cost
    ? { allowed: true }
    : { allowed: false, reasonCode: 'BALANCE_INSUFFICIENT' };
});

// No model wired yet → a conservative rule-only decision, never an exception.
const engine = new DecisionEngine({ policy });
const { output } = await engine.decide({
  tenantId: 't_123',
  action: { type: 'campaign_send' },
  risk: { riskLevel: 'low' },
  context: { balance: 1000, cost: 200 },
});
// output.decision → 'allow' | 'block' | 'require_approval' | 'split'
Zero runtime dependencies, ports &amp;amp; adapters — your database and model provider
stay yours. There's a runnable Claude adapter example
with structured outputs and refusal handling.

Honest caveat: the token-savings numbers in the docs are an illustrative
cost model, not a measured benchmark — they ship with a formula you plug your
own rates into.

Repo (MIT, EN/ES docs): https://github.com/cristiandkzk/SACP

I'd love to hear how others handle "AI proposes, rules dispose."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>architecture</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
