<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by ARUN KUMAR PRAJAPATI on Medium]]></title>
        <description><![CDATA[Stories by ARUN KUMAR PRAJAPATI on Medium]]></description>
        <link>https://medium.com/@arunkrp122?source=rss-7f48d8d5994c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HDfY5rv8kN8hizd6</url>
            <title>Stories by ARUN KUMAR PRAJAPATI on Medium</title>
            <link>https://medium.com/@arunkrp122?source=rss-7f48d8d5994c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:29:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arunkrp122/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a ReAct AI Agent: State, Memory, and Execution Control]]></title>
            <link>https://medium.com/@arunkrp122/building-a-react-ai-agent-state-memory-and-execution-control-1893f5f0d53a?source=rss-7f48d8d5994c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1893f5f0d53a</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[ARUN KUMAR PRAJAPATI]]></dc:creator>
            <pubDate>Sat, 21 Feb 2026 10:37:29 GMT</pubDate>
            <atom:updated>2026-02-21T10:46:00.692Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXeb2oJUibZfhLG0jfDLyg.png" /></figure><p>I designed and implemented a simple AI agent from scratch to better understand how these systems actually work.</p><p>As someone working in infrastructure automation and designing solutions with tools like Python, SaltStack and Terraform, I have always thought in terms of:</p><ul><li>State</li><li>Control loops</li><li>Deterministic execution</li><li>Idempotency</li><li>Observability</li></ul><p>So when I started exploring Agentic AI, I did not approach it as prompt engineering.</p><p>I approached it as system design.</p><p>This article is a summary of what I learned while building a ReAct-style AI agent from scratch, without using frameworks like LangChain or AutoGen.</p><h3>Why ReAct?</h3><p>ReAct (Reason + Act) is simple in concept:</p><ol><li><strong><em>The agent thinks (Reason)</em></strong></li><li><strong><em>It decides an action</em></strong></li><li><strong><em>It executes the action</em></strong></li><li><strong><em>It observes the result</em></strong></li><li><strong><em>It decides what to do next</em></strong></li><li><strong><em>Learn from outcomes</em></strong></li></ol><p>It’s basically a control loop.</p><p>If you have worked in automation, it feels familiar.</p><p>It’s not magic. It’s orchestration with a language model in the loop.</p><h3>Building the first loop (ReAct pattern)</h3><p>I started with a simple cycle:</p><p><strong><em>Goal → Think → Act → Observe → Repeat</em></strong></p><p>The agent would:</p><ol><li><strong><em>Send the goal to the LLM</em></strong></li><li><strong><em>Get structured JSON with a command</em></strong></li><li><strong><em>Execute the command in Windows</em></strong></li><li><strong><em>Feed the output back</em></strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*Z2z_yClXyvP7a4ILPsooBA.png" /></figure><p>This shows:</p><ul><li>The control loop</li><li>The action execution</li><li>The observation feedback</li></ul><p>This is where it started to feel like writing a small automation engine.</p><h3>Tool safety — Same Discipline as Automation</h3><p>Very quickly, I realized something important:</p><p>You cannot let an LLM execute arbitrary shell commands.</p><p>That’s equivalent to running uncontrolled scripts in production.</p><p>So I added:</p><ul><li>working_commands in long-term memory</li><li>Validation before actual execution in execute_step()</li><li>Strict JSON-only responses</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*UsZhO52DKvxBmVGSwGcH-A.png" /></figure><p>Show:</p><pre>if command not in self.long_term_memory.get(&quot;working_commands&quot;, []):<br>            return f&quot;Command {command} not allowed&quot;</pre><p>This part is critical as it demonstrates engineering discipline, not experimentation.</p><h3>Memory: This is where it became real</h3><p>I separated memory into two layers.</p><p><strong>Short-Term Memory (Per Run)</strong></p><p>Stores:</p><ul><li>Thought</li><li>Action</li><li>Observation</li></ul><p>This helps the agent reason step-by-step.</p><p><strong>Long-Term Memory (Persistent JSON)</strong></p><p>Stored in a file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*SaTvdNU2KdHVL8rjgOK2Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*49wrYeNdBGSeQLtEF7Z-SA.png" /></figure><p>This is where I realized something:</p><p><strong><em>Agent memory is just state management.</em></strong></p><p>Very similar to how infrastructure tools track desired vs current state.</p><h3>From reactive to structured planning</h3><p>Initially, my agent reacted step-by-step.</p><p>Then I refactored it into:</p><p><strong><em>Goal → Plan → Execute → Reflect</em></strong></p><p>I introduced:</p><ul><li>create_plan()</li><li>execute_step()</li><li>reflect()</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*SbKgPEPkeJiZJFniBgpLMg.png" /></figure><p>The planner response example:</p><pre>{<br>  &quot;plan&quot;: [<br>    {&quot;step&quot;: 1, &quot;description&quot;: &quot;Check current user&quot;, &quot;command&quot;: &quot;whoami&quot;}<br>  ]<br>}</pre><p>This separation made debugging easier and reduced randomness.</p><p>It felt like splitting:</p><ul><li><strong><em>Control plane</em></strong></li><li><strong><em>Execution plane</em></strong></li></ul><p>Which is very familiar in infrastructure design.</p><h3>Reflection: Hybrid Intelligence</h3><p>At first, I relied fully on the LLM to confirm whether the goal was achieved.</p><p>That didn’t always work.</p><p>So I added deterministic validation for certain goal types.</p><p>For example:</p><p><em>If goal contains “user” and </em><em>whoami returns a value → goal achieved.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*rdYEjhpk3bYj42_yc65L3Q.png" /></figure><p>This hybrid approach (LLM + deterministic logic) significantly improved stability.</p><p>It mirrors real-world systems:</p><blockquote><strong>Do not rely entirely on probabilistic reasoning. Add guardrails.</strong></blockquote><h3>Debugging was the real learning</h3><p>I hit issues like:</p><ul><li><em>Finish action still executing tools</em></li><li><em>Plan completed but goal not confirmed</em></li><li><em>Memory not persisting correctly</em></li><li><em>Agent repeating commands unnecessarily</em></li></ul><p>Each one forced me to rethink the architecture.</p><p>This was not “AI magic.”</p><p>It was:</p><ul><li><em>Object-oriented design</em></li><li><em>Control flow correction</em></li><li><em>State consistency</em></li></ul><p>Exactly the same principles used in automation systems.</p><h3>What I realized about Agentic AI</h3><p>After building everything manually, here is my honest perspective:</p><p><strong>1. Agents Are Orchestrators</strong></p><ul><li><em>An LLM is just the decision engine.</em></li><li><em>The architecture around it matters more.</em></li></ul><p><strong>2. Memory = State</strong></p><ul><li><em>Persistent memory behaves like infrastructure state files.</em></li></ul><p><strong>3. Idempotency Matters</strong></p><ul><li>The agent should avoid repeating the same command blindly.</li></ul><p><strong>4. Safety Is Non-Negotiable</strong></p><ul><li>Tool execution must always be controlled.</li></ul><p><strong>5. Planning Improves Stability</strong></p><ul><li>Separating planning from execution reduces chaos.</li></ul><p><strong>6. The Biggest Lesson — Making AI Systems Reliable Through Better Control</strong></p><p><em>LLMs are probabilistic.</em></p><p><em>Infrastructure automation is deterministic.</em></p><p>Building a ReAct agent is about wrapping deterministic control around a probabilistic core.</p><p>That means:</p><ul><li><strong><em>Limit allowed commands</em></strong></li><li><strong><em>Validate output</em></strong></li><li><strong><em>Define clear success criteria</em></strong></li><li><strong><em>Restrict max execution steps</em></strong></li><li><strong><em>Log every action</em></strong></li><li><strong><em>Design memory carefully</em></strong></li></ul><p><strong><em>“An AI agent is not just intelligence — it’s architecture around intelligence.”</em></strong></p><p>The intelligence comes from the model.</p><p>The reliability comes from architecture.</p><p>And architecture is still our job.</p><h3><strong>Next, I plan to explore:</strong></h3><ul><li><em>Tool abstraction instead of raw shell calls</em></li><li><em>Safer execution boundaries</em></li><li><em>Better memory summarization</em></li><li><em>Multi-step planning</em></li><li><em>Deterministic plan validation and Approvals</em></li></ul><h3>Final thoughts</h3><p>If you come from an automation background, do not treat agentic AI as something completely new.</p><p>Think in terms of:</p><p><strong>- State<br>- Idempotency<br>- Control loops<br>- Observability<br>- Execution constraints</strong></p><p>The patterns are surprisingly familiar.</p><p>The difference is that now your orchestrator can think.</p><p><em>If you are building your own agent systems, I would be interested in hearing how you are handling memory and execution control.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1893f5f0d53a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SaltStack’s PostgreSQL Returner to Capture Missing Minions]]></title>
            <link>https://medium.com/@arunkrp122/saltstacks-postgresql-returner-to-capture-missing-minions-663df19ea9f4?source=rss-7f48d8d5994c------2</link>
            <guid isPermaLink="false">https://medium.com/p/663df19ea9f4</guid>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[saltstack]]></category>
            <category><![CDATA[configuration-management]]></category>
            <dc:creator><![CDATA[ARUN KUMAR PRAJAPATI]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 10:48:40 GMT</pubDate>
            <atom:updated>2025-04-01T12:56:59.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>SaltStack’s <strong>PostgreSQL returner</strong> is a powerful feature that stores job execution results in a database. The procedure to configure a salt master to send Return data to a PostgreSQL server can be found here: <a href="https://docs.saltproject.io/en/3006/ref/returners/all/salt.returners.postgres.html">https://docs.saltproject.io/en/3006/ref/returners/all/salt.returners.postgres.html</a></p><p>However, I observed a <strong>critical issue </strong>while implementing it:</p><p>👉 <strong>Minions that failed to return were not captured when using </strong><strong>lookup_jid(jid, missing=True).</strong></p><p>This blog post explains:<br> ✅ <strong>Missing Minions Not Captured in PostgreSQL.<br> ✅ Capturing Expected Minions for a Job.<br> ✅ Results &amp; Impact.<br> ✅ Pull Request to merge this fix into SaltStack.</strong></p><p>Let’s dive in! 🔍</p><h3>Issue: Missing Minions Not Captured in PostgreSQL</h3><p>When running a job in SaltStack, the Salt master sends execution requests to multiple minions. These minions are expected to return their results, which are then stored in the <strong>salt_returns</strong> table of the PostgreSQL returner. However, if a minion does not respond (due to network failures, system crashes, or high CPU load), it does not get recorded in the database.</p><p>Salt provides a way to check for <strong>missing minions</strong> by using:</p><pre>salt-run jobs.lookup_jid &lt;jid&gt; missing=True</pre><p>This should ideally return a list of minions that did not respond. However, with the default PostgreSQL returner, <strong>only the minions that successfully returned results were stored</strong> in the database, meaning that missing=True could not retrieve minions that failed to return.</p><p>This made troubleshooting difficult, as there was no way to determine which minions had received the job but failed to execute or return results.</p><p>The reason behind this behavior is that the PostgreSQL returner does not store the expected minion IDs. As a result, when executing lookup_jid, it cannot compare the expected minions with those that have actually returned.</p><p>The JID table entry looks like as shown below, the <strong>load</strong> dictionary lacks the key <strong>‘Minions’. </strong>In the local returner, this key contains the list of expected minion IDs, allowing it to track which minions were supposed to respond. Without this key, the PostgreSQL returner cannot determine the expected minions, preventing proper job tracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBI1TVjTsTg94BGJ1nJwMw.png" /></figure><h3>Enhancement: Capturing Expected Minions for a Job</h3><p>To fix this issue, I introduced a function that <strong>retrieves the list of minions expected to return for a job </strong>in the postgres returner. This ensures that when missing=True is used in lookup_jid, it correctly identifies and reports missing minions.</p><h4>Steps to Fix the Issue:</h4><p>In the postgres returner python file, create a function to extract the list of minions that were <strong>expected to return</strong> from the jids table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIHhboAUtjwPmDuJIs6rXg.png" /></figure><p>Enhance the <strong>save_load</strong> function to append the ‘<strong>load’</strong> dict variable with the minion ids in a key ‘<strong>[‘Minions’]</strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2TGcOMPMiz7ZMqqv5tOJA.png" /></figure><p>Save the postgres returner file and restart salt-master. The salt command to lookup jid with missing=true should be working as expected now.</p><p>The JID table will contain an entry for each JID, with the <strong>load</strong> dictionary including the key <strong>‘Minions’ — a list of expected minion IDs</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fx_Py7LaGJnQzreYE4gcoQ.png" /></figure><h3>Results &amp; Impact</h3><p>With this enhancement:</p><p>✅ <strong>Salt now correctly identifies missing minions when </strong><strong>missing=True is used.</strong><br> ✅ <strong>Users can track minions that fail to return, helping with debugging and troubleshooting.</strong><br> ✅ <strong>The PostgreSQL returner now provides more complete and reliable job execution data.</strong></p><h3>Pull Request to SaltStack</h3><p>After implementing and testing this enhancement, I had a discussion with the Salt-user community on the same and raised a <strong>pull request to SaltStack</strong> to merge this improvement into the <strong>PostgreSQL returner</strong>. This will ensure all Salt users benefit from a <strong>fully functional </strong><strong>missing=True option</strong>.</p><p>You can view the PR and track the progress here: <a href="https://github.com/saltstack/salt/pull/67930">https://github.com/saltstack/salt/pull/67930</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=663df19ea9f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>