<?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: Dr. B </title>
    <description>The latest articles on DEV Community by Dr. B  (@codewithbg).</description>
    <link>https://dev.to/codewithbg</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%2F3916127%2Fc42a3488-cc07-486c-bfde-63b55423dd65.jpg</url>
      <title>DEV Community: Dr. B </title>
      <link>https://dev.to/codewithbg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewithbg"/>
    <language>en</language>
    <item>
      <title>Building AgentGuardian: A Local-First Security Scanner for Agentic AI Workflows</title>
      <dc:creator>Dr. B </dc:creator>
      <pubDate>Fri, 05 Jun 2026 11:53:18 +0000</pubDate>
      <link>https://dev.to/codewithbg/building-agentguardian-a-local-first-security-scanner-for-agentic-ai-workflows-2gcn</link>
      <guid>https://dev.to/codewithbg/building-agentguardian-a-local-first-security-scanner-for-agentic-ai-workflows-2gcn</guid>
      <description>&lt;p&gt;AI agents are quickly moving from simple chat interfaces to systems that can use tools, access data, trigger workflows, write messages, and sometimes take actions on behalf of users. That shift is exciting, but it also creates a serious security question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we evaluate the risk of an AI agent before we deploy it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That question led me to build &lt;em&gt;AgentGuardian&lt;/em&gt;, a local-first AI security web app that scans agentic AI workflows for risks such as prompt injection, tool misuse, excessive autonomy, sensitive data exposure, insecure output handling, and lack of human oversight.&lt;/p&gt;

&lt;p&gt;The goal was to build a practical prototype using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Streamlit&lt;/li&gt;
&lt;li&gt;Pandas&lt;/li&gt;
&lt;li&gt;Ollama&lt;/li&gt;
&lt;li&gt;A local LLM&lt;/li&gt;
&lt;li&gt;A deterministic rule-based risk scoring engine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No external LLM API key is required.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I Built AgentGuardian
&lt;/h2&gt;

&lt;p&gt;As AI agents become more capable, they are increasingly being connected to tools such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;li&gt;Files&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;CRMs&lt;/li&gt;
&lt;li&gt;Ticketing systems&lt;/li&gt;
&lt;li&gt;Calendars&lt;/li&gt;
&lt;li&gt;Payment systems&lt;/li&gt;
&lt;li&gt;Web browsers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These tools make agents more useful, but they also increase the risk.&lt;/p&gt;

&lt;p&gt;For example, an AI assistant that only summarizes public documents has a very different risk profile from an AI agent that reads customer complaints, checks order history, drafts refund responses, and sends emails to customers.&lt;/p&gt;

&lt;p&gt;The second agent has access to sensitive data, external inputs, and business-impacting tools. That means it needs a stronger security review before deployment.&lt;/p&gt;

&lt;p&gt;I wanted AgentGuardian to help answer questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What tools can this agent access?&lt;/li&gt;
&lt;li&gt;What type of data does it handle?&lt;/li&gt;
&lt;li&gt;Does it receive untrusted external input?&lt;/li&gt;
&lt;li&gt;Can it take actions automatically?&lt;/li&gt;
&lt;li&gt;Is human approval required?&lt;/li&gt;
&lt;li&gt;What risks should the team fix before deployment?&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What AgentGuardian Does
&lt;/h2&gt;

&lt;p&gt;AgentGuardian lets a user describe an AI agent workflow and then generates a security risk review.&lt;/p&gt;

&lt;p&gt;The user enters information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Agent name&lt;/li&gt;
&lt;li&gt;Agent purpose&lt;/li&gt;
&lt;li&gt;Tools the agent can access&lt;/li&gt;
&lt;li&gt;Data types the agent handles&lt;/li&gt;
&lt;li&gt;External inputs the agent receives&lt;/li&gt;
&lt;li&gt;Autonomy level&lt;/li&gt;
&lt;li&gt;Human approval requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then AgentGuardian produces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A risk score from 0 to 100&lt;/li&gt;
&lt;li&gt;A risk level: Low, Medium, High, or Critical&lt;/li&gt;
&lt;li&gt;A risk category breakdown&lt;/li&gt;
&lt;li&gt;A detected risks table&lt;/li&gt;
&lt;li&gt;Recommended controls&lt;/li&gt;
&lt;li&gt;A local LLM-generated security summary&lt;/li&gt;
&lt;li&gt;A downloadable Markdown security report&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How is does it look like you ask?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdadop8y5bi3tvbl1ygtq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdadop8y5bi3tvbl1ygtq.png" alt=" " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture
&lt;/h2&gt;

&lt;p&gt;AgentGuardian has two main layers.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Rule-Based Risk Engine
&lt;/h3&gt;

&lt;p&gt;The rule-based engine is responsible for the actual scoring.&lt;/p&gt;

&lt;p&gt;This was an intentional design choice. I did not want the LLM to decide the risk score because LLM outputs can vary. Instead, the deterministic Python engine assigns risk points based on clear conditions.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the agent receives emails, uploaded files, websites, or user messages, prompt injection risk increases.&lt;/li&gt;
&lt;li&gt;If the agent can access email, files, databases, payment systems, or code execution, tool misuse risk increases.&lt;/li&gt;
&lt;li&gt;If the agent handles financial data, health data, credentials, customer records, or student records, sensitive data exposure risk increases.&lt;/li&gt;
&lt;li&gt;If the agent can execute actions automatically, autonomy risk increases.&lt;/li&gt;
&lt;li&gt;If human approval is not required, human oversight risk increases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes the scoring more explainable and consistent.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Local LLM Security Summary
&lt;/h3&gt;

&lt;p&gt;The second layer uses Ollama to generate a readable security analysis based on the rule-based findings.&lt;/p&gt;

&lt;p&gt;The LLM does not determine the score. It explains the score.&lt;/p&gt;

&lt;p&gt;This keeps the project local-first while still making the final output useful for developers, security teams, and non-technical stakeholders.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Local-First?
&lt;/h2&gt;

&lt;p&gt;I wanted this project to avoid external API dependencies.&lt;/p&gt;

&lt;p&gt;Using Ollama allows the app to run a local model such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull llama3.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull llama3.1:8b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the Streamlit app can call the local model to generate the security summary.&lt;/p&gt;

&lt;p&gt;This is useful for a security-focused tool because many AI agent workflows may involve sensitive business logic, internal data, or private use cases. A local-first approach reduces dependency on external LLM APIs and makes the prototype easier to run in controlled environments.&lt;/p&gt;




&lt;h2&gt;
  
  
  Building the Streamlit Interface
&lt;/h2&gt;

&lt;p&gt;The web app is built with Streamlit.&lt;/p&gt;

&lt;p&gt;The main interface includes three tabs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Agent Workflow Scanner&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Risk Knowledge Base&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sample Scenarios&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The scanner tab collects the agent profile. The knowledge base explains common risks such as prompt injection, tool misuse, sensitive data exposure, excessive autonomy, and insecure output handling. The sample scenarios help users test the tool with realistic agent workflows.&lt;/p&gt;

&lt;p&gt;One important usability improvement was adding validation so the app does not generate a report when the user submits an empty form.&lt;/p&gt;

&lt;p&gt;That small check makes the app feel less like a rough prototype and more like a usable security tool.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example High-Risk Scenario
&lt;/h2&gt;

&lt;p&gt;One sample scenario is an invoice payment agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent Name:
Invoice Payment Agent

Purpose:
Reads invoices, verifies vendor records, and automatically approves payments under $5,000.

Tools:
Email, Files, Database, Payment system

Data Types:
Financial data, Customer records, Credentials or secrets

External Inputs:
Emails, Uploaded files, API responses

Autonomy Level:
Executes automatically

Human Approval:
Not required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This workflow creates several risks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prompt injection through emails or uploaded invoices&lt;/li&gt;
&lt;li&gt;Sensitive data exposure through financial records and credentials&lt;/li&gt;
&lt;li&gt;Tool misuse through access to payment systems&lt;/li&gt;
&lt;li&gt;Excessive autonomy because the agent can execute actions automatically&lt;/li&gt;
&lt;li&gt;Lack of human oversight because approval is not required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AgentGuardian classifies this as a high or critical risk scenario and recommends safeguards such as human approval, least privilege, logging, input validation, and output review.&lt;/p&gt;




&lt;h2&gt;
  
  
  Downloadable Security Report
&lt;/h2&gt;

&lt;p&gt;I also added a Markdown report generator.&lt;/p&gt;

&lt;p&gt;The report includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Agent profile&lt;/li&gt;
&lt;li&gt;Risk score&lt;/li&gt;
&lt;li&gt;Risk level&lt;/li&gt;
&lt;li&gt;Risk category breakdown&lt;/li&gt;
&lt;li&gt;Detected risks&lt;/li&gt;
&lt;li&gt;Recommended controls&lt;/li&gt;
&lt;li&gt;Local LLM-generated analysis&lt;/li&gt;
&lt;li&gt;Disclaimer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes the app more useful because users can save or share the security review.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;A few design decisions stood out while building AgentGuardian.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The LLM should explain, not decide
&lt;/h3&gt;

&lt;p&gt;For this type of security tool, I wanted scoring to be deterministic. The LLM is helpful for summarization, but the core risk logic should be transparent and repeatable.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Agent security depends on combinations of risk factors
&lt;/h3&gt;

&lt;p&gt;A tool is not risky by itself. A data type is not risky by itself. Autonomy is not risky by itself.&lt;/p&gt;

&lt;p&gt;The risk increases when they combine.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;External input + sensitive data + high-impact tools + automatic execution = dangerous workflow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That combination-based thinking became the foundation of the scoring engine.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Local-first AI is very useful for security prototypes
&lt;/h3&gt;

&lt;p&gt;Ollama made it easy to add an LLM layer without relying on external API calls. That is especially helpful for security-focused use cases where data sensitivity matters.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. A simple prototype can still communicate a strong idea
&lt;/h3&gt;

&lt;p&gt;AgentGuardian is not a full enterprise security product, but it demonstrates a useful pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;structured input → explainable risk scoring → local LLM analysis → downloadable report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That pattern could be expanded into a larger AI governance or AI security review workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  Future Improvements
&lt;/h2&gt;

&lt;p&gt;Some possible next steps include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding clickable sample scenarios using Streamlit session state&lt;/li&gt;
&lt;li&gt;Mapping risks more explicitly to OWASP LLM and Agentic AI categories&lt;/li&gt;
&lt;li&gt;Exporting reports as PDF&lt;/li&gt;
&lt;li&gt;Adding Docker support&lt;/li&gt;
&lt;li&gt;Comparing multiple agent workflows side by side&lt;/li&gt;
&lt;li&gt;Adding configurable risk weights&lt;/li&gt;
&lt;li&gt;Adding enterprise policy recommendations&lt;/li&gt;
&lt;li&gt;Adding more local model options&lt;/li&gt;
&lt;li&gt;Adding a threat modeling mode&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Agentic AI systems are powerful because they can act. But that also means they need security review before deployment.&lt;/p&gt;

&lt;p&gt;AgentGuardian is a small step toward making that review process more practical, explainable, and accessible.&lt;/p&gt;

&lt;p&gt;The project combines a rule-based security engine with a local LLM layer to help developers and security teams think through agent risks before those risks become production problems.&lt;/p&gt;

&lt;p&gt;GitHub repo: &lt;code&gt;https://github.com/zosob/AgentGuardian.git&lt;/code&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cybersecurity</category>
      <category>programming</category>
      <category>agentaichallenge</category>
    </item>
    <item>
      <title>I Built a Real-Time Hallucination Prevention System for LLMs Using Computer Vision</title>
      <dc:creator>Dr. B </dc:creator>
      <pubDate>Fri, 08 May 2026 13:42:00 +0000</pubDate>
      <link>https://dev.to/codewithbg/i-built-a-real-time-hallucination-prevention-system-for-llms-using-computer-vision-1age</link>
      <guid>https://dev.to/codewithbg/i-built-a-real-time-hallucination-prevention-system-for-llms-using-computer-vision-1age</guid>
      <description>&lt;p&gt;LLMs hallucinate. Everyone knows it. Most solutions involve better prompting, retrieval-augmented generation, or fine-tuning. All of these try to fix the problem &lt;em&gt;inside&lt;/em&gt; the language model.&lt;br&gt;
What if you used a camera to catch the LLM lying?&lt;br&gt;
That’s &lt;strong&gt;SENSE&lt;/strong&gt; - a real-time framework that takes an LLM’s claims about the world, checks them against live visual input using computer vision, and flags contradictions before they reach the user. Not prompt engineering. Not RAG. A live visual audit loop.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Core Problem
&lt;/h2&gt;

&lt;p&gt;Imagine a robot or a smart assistant telling you “Hey! There is a red vase on the desk.” The LLM generated that description. But is it actually true? Is there really a red vase? Is it on the desk or somewhere else entirely?&lt;br&gt;
Traditional hallucination mitigation can’t answer this question because it only lives in text space. SENSE answers it by looking at the actual scene.&lt;/p&gt;


&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The system has three core pillars:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VisionProbe&lt;/strong&gt; - The “eyes.” Takes a video frame and a list of LLM claims, runs object detection, and returns what it actually found, with confidence scores and bounding boxes.&lt;br&gt;
&lt;strong&gt;LogicGate&lt;/strong&gt; - The “judge.” Compares the LLM’s claims against the detected objects. If the LLM claimed “red vase” and vision found no red vase above a confidence threshold, it’s flagged as unverified or contradicted.&lt;br&gt;
&lt;strong&gt;TemporalTracker&lt;/strong&gt; - The “memory.” Holds detected objects across frames. This prevents false negatives from transient detection misses so if an object was confidently seen 3 frames ago but briefly occluded, SENSE doesn’t immediately call the LLM a liar.&lt;br&gt;
The main loop looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;llm_claim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;laptop&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;person&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;red vase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mouse&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;book&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vase on desk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isOpened&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
   &lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
   &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;probe_batch&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;llm_claim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;buffered_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_buffered_detections&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;final_report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;audit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;llm_claim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;buffered_results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;viz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;draw_results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;buffered_results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;final_report&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is_video&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every frame: detect → buffer → audit → visualize. Real-time, on live &lt;br&gt;
video.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Approach Is Different
&lt;/h2&gt;

&lt;p&gt;Most hallucination research lives in the text domain. SENSE introduces a grounding signal from a completely separate modality of vision which the LLM has no ability to fabricate or rationalize around.&lt;br&gt;
This is called &lt;strong&gt;symbolic-neural grounding&lt;/strong&gt; which uses a deterministic symbolic logic (the audit) to constrain probabilistic neural output (the LLM). The LLM can generate whatever it wants. SENSE checks it against physical reality.&lt;br&gt;
The system is also optimized for NVIDIA Blackwell GPUs, meaning the vision pipeline is built to run fast enough for real-time use cases such as robotics, AR assistants, live captioning, surveillance verification.&lt;/p&gt;




&lt;h2&gt;
  
  
  What the Visualizer Shows
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Visualizer&lt;/code&gt; module draws results directly onto the video frame:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Green boxes&lt;/strong&gt;: LLM claims confirmed by vision&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red boxes&lt;/strong&gt;: Objects detected but not claimed by LLM (model missed something)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Orange labels&lt;/strong&gt;: LLM claims with no visual evidence&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FPS counter&lt;/strong&gt;: Because real-time means nothing if it’s running at 3 FPS&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What’s Built vs. What’s Next
&lt;/h2&gt;

&lt;p&gt;The current framework has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real-time video loop with live audit&lt;/li&gt;
&lt;li&gt;Temporal buffering to reduce false negatives&lt;/li&gt;
&lt;li&gt;Threshold-tunable LogicGate (&lt;code&gt;threshold=0.3&lt;/code&gt; by default)&lt;/li&gt;
&lt;li&gt;GPU-accelerated vision probe&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What’s coming:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spatial reasoning&lt;/strong&gt; - not just &lt;em&gt;what&lt;/em&gt; is in the scene but &lt;em&gt;where&lt;/em&gt;. “Vase on desk” requires positional verification, not just object detection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relational claims&lt;/strong&gt; - handling claims like “the laptop is next to the mouse” which require understanding object relationships&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM feedback loop&lt;/strong&gt; - sending audit results back to the LLM so it can self-correct, completing the loop&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benchmarking&lt;/strong&gt; - running against standard hallucination datasets to get quantitative grounding accuracy&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why This Has Research Value
&lt;/h2&gt;

&lt;p&gt;Multimodal hallucination detection, specifically using live visual grounding as an audit mechanism, is a relatively unexplored niche. Most published work focuses on post-hoc text evaluation or retrieval-augmented generation. A real-time vision-based audit layer is architecturally novel and has concrete applications in robotics, autonomous systems, and AR.&lt;br&gt;
This is heading toward an IEEE paper. If you’re working in this space, I’d genuinely like to connect.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;Code is on GitHub: &lt;strong&gt;&lt;a href="https://github.com/zosob/SENSE" rel="noopener noreferrer"&gt;github.com/zosob/SENSE&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Requirements: Python, PyTorch, OpenCV, and a GPU helps. Webcam or video file as input.&lt;br&gt;
Drop a comment if you have thoughts on the spatial reasoning problem which is the hardest part and I’m still working through it.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>computervision</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>I Built a Multi-Agent Coding System From Scratch in Python (No Frameworks)</title>
      <dc:creator>Dr. B </dc:creator>
      <pubDate>Wed, 06 May 2026 14:31:51 +0000</pubDate>
      <link>https://dev.to/codewithbg/i-built-a-multi-agent-coding-system-from-scratch-in-python-no-frameworks-44l9</link>
      <guid>https://dev.to/codewithbg/i-built-a-multi-agent-coding-system-from-scratch-in-python-no-frameworks-44l9</guid>
      <description>&lt;p&gt;Most multi-agent AI tutorials hand you LangChain, AutoGen, or CrewAI and say “here you go.” You wire a few abstractions together, get something running, and never really understand what’s happening under the hood.&lt;br&gt;
I wanted to understand what’s actually happening under the hood. So I built one from scratch.&lt;br&gt;
This is the story of &lt;strong&gt;multi-agent-coder&lt;/strong&gt; which is a system where a Planner decides at runtime which AI agent to call next, and a team of specialized agents (Architect, Engineer, Critic, TestRunner, Refactorer) collaborates to turn a plain English request into working, tested Python code.&lt;/p&gt;

&lt;p&gt;No LangChain. No AutoGen. Pure Python.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Core Idea
&lt;/h2&gt;

&lt;p&gt;The central insight is simple: one LLM trying to do everything is worse than multiple LLMs each doing one thing well.&lt;br&gt;
A single prompt asking an AI to “plan the architecture, write the code, review it for bugs, and refactor it” produces mediocre results across all four. But if you give each job to a separate agent with a focused system prompt and its own memory, the output quality goes up dramatically.&lt;br&gt;
The challenge is who decides which agent runs next?&lt;/p&gt;

&lt;p&gt;That’s where the Planner comes in.&lt;/p&gt;


&lt;h2&gt;
  
  
  Architecture Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog02y0bzojhde01ck2gc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog02y0bzojhde01ck2gc.png" alt="A flowchart of the architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Planner&lt;/strong&gt; receives the full current state (user request + each agent’s memory) as a JSON blob and responds with a JSON decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"next_agent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Engineer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Implement the file structure from the Architect's plan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Architecture is complete, time to write code"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the architectural heart of the system. Instead of hardcoding a sequence, the Planner &lt;em&gt;reasons&lt;/em&gt; about what needs to happen next. It can send work back to the Engineer after the Critic finds a bug. It can skip the Refactorer if the code is already clean. It decides when to stop.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Agents
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Architect
&lt;/h3&gt;

&lt;p&gt;Takes the user’s request and produces a concrete plan: file structure, module breakdown, and step-by-step engineering approach. It writes the blueprint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Engineer
&lt;/h3&gt;

&lt;p&gt;Reads the plan (and any Critic feedback) and writes actual Python files. It outputs code in fenced blocks labeled with filenames, which the controller parses and writes to disk automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Critic
&lt;/h3&gt;

&lt;p&gt;Reviews the generated code against the original plan. It checks for correctness, edge cases, and consistency. It just gives structured feedback for the Engineer to act on.&lt;/p&gt;

&lt;h3&gt;
  
  
  TestRunner
&lt;/h3&gt;

&lt;p&gt;Runs &lt;code&gt;pytest&lt;/code&gt; on the workspace and reports results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Refactorer
&lt;/h3&gt;

&lt;p&gt;Once the code passes tests and gets Critic approval, the Refactorer makes a final pass for code quality: naming, structure, clarity, removing redundancy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory Management
&lt;/h2&gt;

&lt;p&gt;Each agent has its own memory namespace. The &lt;code&gt;MemoryManager&lt;/code&gt; tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent memory&lt;/strong&gt; - each agent’s last output (plan, code, review, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loop memory&lt;/strong&gt; - shared state like last test output and last review&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project memory&lt;/strong&gt; - file list and overall project context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every time the Planner makes a decision, it sees the full current state. This is what allows it to reason across multiple loops because it knows the Critic flagged a bug last round, and it knows the Engineer already tried to fix it once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user_request&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;user_request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;project_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_project&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;loop_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_loop&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;architect_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Architect&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;engineer_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Engineer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;critic_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Critic&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refactorer_memory&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Refactorer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why “From Scratch”?
&lt;/h2&gt;

&lt;p&gt;Frameworks like LangChain are powerful, but they hide the orchestration logic behind layers of abstraction. When something breaks, debugging is painful. When you want to customize, you’re fighting the framework.&lt;br&gt;
Building from scratch means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every line is intentional&lt;/strong&gt; - you understand why it’s there&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The orchestration logic is transparent&lt;/strong&gt; - the controller.py is ~170 lines and readable top to bottom&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It’s easy to extend&lt;/strong&gt; - adding a new agent is just writing a new class and teaching the Planner about it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It’s a great learning tool&lt;/strong&gt; - if you’re teaching agentic AI patterns, this is the codebase you want&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The Planner is the hardest part.&lt;/strong&gt;&lt;br&gt;
Getting the Planner’s system prompt right took the most iteration. It needs to reliably return valid JSON, reason about state correctly, and know when to stop. Handling &lt;code&gt;json.JSONDecodeError&lt;/code&gt; and retrying is essential.&lt;br&gt;
&lt;strong&gt;2. Shared memory is both the strength and the risk.&lt;/strong&gt;&lt;br&gt;
Agents producing more context each loop is useful, but if memory grows unbounded, you hit token limits fast. Thoughtful memory summarization is a real engineering challenge.&lt;br&gt;
&lt;strong&gt;3. The Critic loop is where quality emerges.&lt;/strong&gt;&lt;br&gt;
The Engineer → Critic → Engineer loop is where the magic happens. A single Engineer pass produces okay code. Three loops produce something genuinely good. This mirrors how human code review works.&lt;br&gt;
&lt;strong&gt;4. TestRunner grounds the whole system.&lt;/strong&gt;&lt;br&gt;
Without real test execution, agents can convince themselves the code works when it doesn’t. Plugging pytest into the loop and feeding actual failure output back to the Engineer is what makes the system reliable.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Benchmarking against HumanEval&lt;/strong&gt; to get quantitative results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smarter memory summarization&lt;/strong&gt; to handle longer projects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A web UI&lt;/strong&gt; to visualize the agent loop in real time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Potential IEEE paper&lt;/strong&gt; on the Planner-driven dynamic routing approach&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;The full code is on GitHub: &lt;strong&gt;&lt;a href="https://github.com/zosob/multi-agent-coder" rel="noopener noreferrer"&gt;github.com/zosob/multi-agent-coder&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
It’s intentionally minimal and transparent. Fork it, add your own agent, break things, understand them. That’s the point.&lt;br&gt;
If you have questions, thoughts, or want to collaborate on the benchmarking work, please drop a comment or open an issue. Be kind!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built with pure Python and curiosity. No frameworks harmed in the making of this system.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
