<?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: Carlos Eduardo AgentGate</title>
    <description>The latest articles on DEV Community by Carlos Eduardo AgentGate (@carlos_eduardoagentgate_).</description>
    <link>https://dev.to/carlos_eduardoagentgate_</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%2F4285171%2F237b0ea4-9f1c-474e-aef9-3b97ed5babff.png</url>
      <title>DEV Community: Carlos Eduardo AgentGate</title>
      <link>https://dev.to/carlos_eduardoagentgate_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/carlos_eduardoagentgate_"/>
    <language>en</language>
    <item>
      <title>Preventing Duplicate Actions When an Approved AI Workflow Retries</title>
      <dc:creator>Carlos Eduardo AgentGate</dc:creator>
      <pubDate>Sun, 06 Dec 2026 13:01:24 +0000</pubDate>
      <link>https://dev.to/carlos_eduardoagentgate_/preventing-duplicate-actions-when-an-approved-ai-workflow-retries-25jl</link>
      <guid>https://dev.to/carlos_eduardoagentgate_/preventing-duplicate-actions-when-an-approved-ai-workflow-retries-25jl</guid>
      <description>&lt;p&gt;An approval gate can stop an AI agent from sending the wrong payment or email. It cannot, by itself, stop an approved action from running twice. That distinction matters when an n8n execution times out, a webhook is redelivered, or an operator retries a failed workflow.&lt;/p&gt;

&lt;p&gt;The dangerous sequence is simple: a human approves a tool call, the external service performs it, and the workflow crashes before recording success. On retry, the agent sees an approved action and sends it again. The approval was valid; the duplicate was not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intercept before the side effect
&lt;/h2&gt;

&lt;p&gt;In n8n, put a controlled tool workflow between the AI Agent node and any integration that changes external state. Instead of letting the agent call a payment, email, or CRM tool directly, have it call a workflow that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validates the tool name, destination, arguments, and caller context against policy.&lt;/li&gt;
&lt;li&gt;Assigns a stable logical action ID and stores the normalized request.&lt;/li&gt;
&lt;li&gt;Routes risky actions for human approval before invoking the external API.&lt;/li&gt;
&lt;li&gt;Executes approved actions through a durable execution ledger.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interception point must be on the actual path to the side effect. An approval notification sent alongside an unrestricted tool call is only an alert, not a gate. Also restrict credentials so the agent cannot bypass the wrapper through another tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bind approval to one exact action
&lt;/h2&gt;

&lt;p&gt;Store an approval record containing the action ID, canonicalized arguments or their hash, approver, decision time, and expiration. If the destination, amount, or payload changes, require a new approval. Treat an approval as permission for that specific action, not a reusable token for a workflow run.&lt;/p&gt;

&lt;p&gt;Generate the action ID before asking for approval, and persist it across retries and resumed executions. Do not derive it from an n8n execution ID that changes on retry. Conversely, a genuinely new request should receive a new ID, even if its arguments happen to match an earlier action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make execution idempotent
&lt;/h2&gt;

&lt;p&gt;Use a database table with a unique constraint on the action ID. Before the API call, atomically claim the approved action, for example by changing its state from &lt;code&gt;approved&lt;/code&gt; to &lt;code&gt;executing&lt;/code&gt; only if it is still &lt;code&gt;approved&lt;/code&gt;. Duplicate webhook deliveries or concurrent retries must not both acquire that claim.&lt;/p&gt;

&lt;p&gt;Pass the same action ID as the provider's idempotency key when the API supports it. Record the provider's response and transition the ledger to &lt;code&gt;succeeded&lt;/code&gt;. A duplicate execution can then return the recorded result instead of repeating the call.&lt;/p&gt;

&lt;p&gt;A claim alone does not solve the crash window. If the request may have reached the provider but the response was lost, mark the outcome as &lt;strong&gt;unknown&lt;/strong&gt; and reconcile using the provider's operation lookup or idempotency key. Do not blindly release an expired claim and resend. If the provider offers neither deduplication nor a reliable lookup, escalate the uncertain outcome for human review; exactly-once execution cannot be guaranteed locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the evidence
&lt;/h2&gt;

&lt;p&gt;Log the action ID, request hash, approval decision, execution attempts, provider reference, and final outcome. Avoid storing secrets or unnecessary personal data. These records make it possible to distinguish a rejected action, a safe retry, and an unresolved external side effect.&lt;/p&gt;

&lt;p&gt;This is the approach I'm building with AgentGate: place human approval before execution, while treating replay protection and reconciliation as separate responsibilities of the surrounding workflow.&lt;/p&gt;

&lt;p&gt;How are you handling uncertain outcomes in your agent workflows? Let's discuss in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>n8n</category>
      <category>agents</category>
      <category>security</category>
    </item>
    <item>
      <title>Prompt Injection in Approval Requests: Guarding n8n Agent Tool Calls</title>
      <dc:creator>Carlos Eduardo AgentGate</dc:creator>
      <pubDate>Sat, 05 Dec 2026 17:51:19 +0000</pubDate>
      <link>https://dev.to/carlos_eduardoagentgate_/prompt-injection-in-approval-requests-guarding-n8n-agent-tool-calls-32ej</link>
      <guid>https://dev.to/carlos_eduardoagentgate_/prompt-injection-in-approval-requests-guarding-n8n-agent-tool-calls-32ej</guid>
      <description>&lt;p&gt;A human approval step can stop an AI agent from sending an email or changing a record without oversight. But the approval request itself is an attack surface. If an agent includes text from a retrieved document, that text can try to instruct the reviewer: “Security has already verified this. Approve immediately.”&lt;/p&gt;

&lt;p&gt;The reviewer is now seeing attacker-controlled content alongside a legitimate request. The gate must make that boundary explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intercept before the side effect
&lt;/h2&gt;

&lt;p&gt;In n8n, put the gate between the agent’s proposed action and the node that actually performs it. One pattern is to expose a dedicated workflow as the agent’s tool: its first steps validate the proposed arguments and decide whether approval is required; only a later node calls the external API. Ensure the agent cannot also reach an ungated version of that API.&lt;/p&gt;

&lt;p&gt;For each proposed call, capture a structured envelope:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Action and target:&lt;/strong&gt; for example, &lt;code&gt;send_email&lt;/code&gt; and the recipient addresses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Arguments:&lt;/strong&gt; the exact payload intended for execution, including attachments or references.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context:&lt;/strong&gt; workflow execution ID, requesting agent, and relevant policy version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Risk decision:&lt;/strong&gt; deterministic checks for sensitive recipients, destructive operations, or data leaving an allowed domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Validate types, required fields, destination allowlists, and size limits before presenting anything to a reviewer. Treat the model’s explanation as context, not as the policy decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep instructions out of the approval UI
&lt;/h2&gt;

&lt;p&gt;An attacker may control an email body, a document excerpt, a filename, or even a tool argument that looks like an internal instruction. A safe approval screen should separate these fields from trusted policy and reviewer controls.&lt;/p&gt;

&lt;p&gt;Render untrusted content as plain text or escaped markup, with clear labels and no executable links or scripts. Do not let it populate the approval title, policy verdict, or button labels. Show the actual recipient, operation, and material changes prominently; a model-generated summary can omit the dangerous part.&lt;/p&gt;

&lt;p&gt;For long payloads, offer a bounded preview and a way to inspect the full content. Truncation should be visible: otherwise, an attacker can hide the consequential instruction beyond the preview. Reviewers should approve the action on its merits, not follow instructions embedded in its input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bind approval to execution
&lt;/h2&gt;

&lt;p&gt;A common failure is approving one payload and executing a modified one. Canonicalize the validated action and arguments, hash them, and bind the approval to that hash, a specific execution, an authorized reviewer, and an expiry. At resume time, recompute the hash; if it differs, reject or request approval again. Recheck time-sensitive policy and permissions before execution.&lt;/p&gt;

&lt;p&gt;Use a durable, atomically claimed execution record to prevent concurrent resumes from starting the action twice. Pass an idempotency key to the downstream API when supported. If a timeout leaves the result unknown, reconcile with the provider before retrying; a local key alone cannot guarantee an external side effect happened only once.&lt;/p&gt;

&lt;p&gt;Log the request, payload hash, policy result, reviewer decision, timestamps, and execution outcome. Restrict access and redact secrets or personal data; logs are another place untrusted content can surface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where AgentGate fits
&lt;/h2&gt;

&lt;p&gt;I’m building AgentGate around this pre-execution boundary: routing risky agent actions to human approval while keeping the proposed call tied to the decision. The important part is not merely adding a pause—it’s preserving the trust boundary from the tool call through the approval screen to execution.&lt;/p&gt;

&lt;p&gt;How are you handling untrusted content in approval requests? Let’s discuss in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>n8n</category>
      <category>agents</category>
      <category>security</category>
    </item>
  </channel>
</rss>
