<?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: Anzal Ansari</title>
    <description>The latest articles on DEV Community by Anzal Ansari (@anzal_ansari).</description>
    <link>https://dev.to/anzal_ansari</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1844363%2F25d75b23-cff8-40ab-8045-58325d75a22a.png</url>
      <title>DEV Community: Anzal Ansari</title>
      <link>https://dev.to/anzal_ansari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anzal_ansari"/>
    <language>en</language>
    <item>
      <title># Zero to Agent Swarm, Part 2: A Team of Agents</title>
      <dc:creator>Anzal Ansari</dc:creator>
      <pubDate>Sun, 22 Mar 2026 10:21:56 +0000</pubDate>
      <link>https://dev.to/anzal_ansari/-zero-to-agent-swarm-part-2-a-team-of-agents-58k7</link>
      <guid>https://dev.to/anzal_ansari/-zero-to-agent-swarm-part-2-a-team-of-agents-58k7</guid>
      <description>&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%2F687srdqg1yh7vce4b3ax.gif" 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%2F687srdqg1yh7vce4b3ax.gif" width="720" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the second part of the Zero-to-Agent-Swarm tutorial.&lt;br&gt;
In the first part, we went from zero to a working AI agent. If you want to check that out, it’s here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/tutorial.md" rel="noopener noreferrer"&gt;← Part 1: Birth and Upgrades&lt;/a&gt;&lt;/strong&gt; — building a single agent from scratch.&lt;/p&gt;



&lt;p&gt;This part is about going from one agent to an agent swarm — making agents work &lt;em&gt;together&lt;/em&gt; for us.&lt;/p&gt;

&lt;p&gt;We’ll need a new mental model. In Part 1, the model was about what an agent &lt;em&gt;is&lt;/em&gt; — Triggers + loop(LLM + Tools + Memory). Now we need to think about what agents &lt;em&gt;do&lt;/em&gt; when there are many of them. We need to consider them — I hate to say this — more like humans. Not because AI is sentient, no, not by a large measure. But because we’ve built computers to resemble human functions, and we have centuries of experience making human systems productive. We can steal a lot of that for agent systems.&lt;/p&gt;

&lt;p&gt;Here’s the progression:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Specialization&lt;/strong&gt; — same code, different agents&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delegation&lt;/strong&gt; — agents calling agents&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Workspace&lt;/strong&gt; — shared state for coordination&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project execution&lt;/strong&gt; — structured plans with parallel execution&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  1. Specialization — Same code, different agent
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: the **Genome&lt;/em&gt;* that defines each agent.*&lt;/p&gt;

&lt;p&gt;One agent is useful. But real work often needs specialists — a researcher, a coder, a reviewer — each with their own tools, memory, and responsibilities. A single agent can context-switch between roles, but it loses focus. Dedicated agents stay sharp — and they can work in parallel.&lt;/p&gt;

&lt;p&gt;What makes one agent different from another?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Its &lt;strong&gt;Thinking&lt;/strong&gt; (which model, what system prompt)&lt;/li&gt;
&lt;li&gt;Its &lt;strong&gt;Memory&lt;/strong&gt; (what it knows)&lt;/li&gt;
&lt;li&gt;Its &lt;strong&gt;Tools&lt;/strong&gt; (what it can do)&lt;/li&gt;
&lt;li&gt;Its &lt;strong&gt;Triggers&lt;/strong&gt; (what wakes it up)&lt;/li&gt;
&lt;li&gt;Its &lt;strong&gt;Container&lt;/strong&gt; (what it can see)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Package these together into a config — the agent’s &lt;strong&gt;genome&lt;/strong&gt; — and from one codebase you can spin up as many specialized agents as you need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/phase-3-step-1.md" rel="noopener noreferrer"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-3-step-1" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/.claude/skills/phase-3-step-1-agent-replication.skill" rel="noopener noreferrer"&gt;Skill&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But spinning up specialists isn’t enough — right now they’re isolated. Each one works alone. How do we get them to collaborate?&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Delegation — Agents calling agents
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: **ask_agent&lt;/em&gt;&lt;em&gt;, the simplest possible multi-agent pattern.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first step towards a team is asking for help when needed. If the &lt;strong&gt;coder&lt;/strong&gt; needs documentation, why write it itself when there’s a &lt;strong&gt;writer&lt;/strong&gt; agent that can do it better and cheaper?&lt;/p&gt;

&lt;p&gt;The simplest way: let an agent call another agent as a tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User → Researcher: "Get the weather in Toronto and have someone write a summary"
         ├── weather: checks Toronto weather
         ├── ask_agent("writer", "summarize the weather in Toronto")
         │     └── Writer runs → returns summary
         └── delivers: "Toronto weather summary"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The implementation is straightforward: we add a new tool &lt;code&gt;ask_agent&lt;/code&gt;. One agent’s loop runs inside another agent’s loop — the same pattern from Part 1, just nested.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/phase-3-step-2.md" rel="noopener noreferrer"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-3-step-2-new" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/.claude/skills/phase-3-step-2-delegation.skill" rel="noopener noreferrer"&gt;Skill&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This works, but it has a bottleneck: all information flows through the delegator. The researcher becomes a middleman, passing data between agents it doesn’t need to understand. What if agents could share data directly?&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Workspace — Shared state for coordination
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: a **Global Workspace&lt;/em&gt;* where agents coordinate through shared tasks and artifacts.*&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;global workspace&lt;/strong&gt; solves the middleman problem. It’s a shared directory on disk with two coordination primitives: &lt;strong&gt;Tasks&lt;/strong&gt; — a shared to-do list where the manager posts work and specialists claim it, and &lt;strong&gt;Artifacts&lt;/strong&gt; — a key-value store where agents drop research findings, drafts, or anything another agent might need. We also appoint a &lt;strong&gt;manager&lt;/strong&gt; agent — the bridge between the user and the specialists.&lt;/p&gt;

&lt;h3&gt;
  
  
  The manager loop
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;manager agent&lt;/strong&gt; drives the whole thing. Its identity is simple: break the goal into tasks, delegate each to a specialist, check progress, repeat until done. The manager never does the work itself — it orchestrates.&lt;/p&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%2Fjapfivu7gaxkjjk1gdj3.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%2Fjapfivu7gaxkjjk1gdj3.png" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Without the workspace, the manager has to micromanage — relaying data between agents like a middleman. With the workspace, agents self-serve: the manager says "check the workspace for open tasks" and each specialist claims work, reads artifacts for context, does the job, and marks it done. The manager doesn't relay data — it just points agents at the workspace and checks progress.&lt;/p&gt;

&lt;p&gt;This is the difference between a manager who dictates every detail and one who says "the work's on the board — go."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/phase-3-step-3.md" rel="noopener noreferrer"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-3-step-3" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/.claude/skills/phase-3-step-3-global-workspace.skill" rel="noopener noreferrer"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Checkpoint:&lt;/strong&gt; We now have a manager agent that breaks work into tasks, delegates to specialists who coordinate through a shared workspace, and loops until everything is done. That's a working swarm. But everything still runs one task at a time — even when tasks are independent.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3.5 Intermission — A web UI
&lt;/h2&gt;

&lt;p&gt;Before we tackle that, let's make the swarm easier to watch. Reading JSON files and terminal output gets old. A web dashboard gives you a live window into everything at once — tasks on a kanban board, agents chatting, artifacts appearing, log events streaming in.&lt;/p&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%2Fyfplnzgehhv057w22zhz.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%2Fyfplnzgehhv057w22zhz.png" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/phase-3-step-3-5.md" rel="noopener noreferrer"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-3-step-3-5" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/.claude/skills/phase-3-step-3-5-web-ui.skill" rel="noopener noreferrer"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Project execution — From flat task lists to DAGs
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: a **Task Tree&lt;/em&gt;* that captures dependencies, enabling parallel + serial execution.*&lt;/p&gt;

&lt;p&gt;The workspace gives us coordination, but the execution is flat. The manager posts tasks one-by-one, checks progress in a loop, and everything runs serially — even when tasks have nothing to do with each other. Real projects have structure: some things must happen in order, others can happen at the same time.&lt;/p&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%2F0phxq3rhj54o7pm8ktw5.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%2F0phxq3rhj54o7pm8ktw5.png" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&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%2F2msyh7l9jv4emm0uqtas.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%2F2msyh7l9jv4emm0uqtas.png" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;DAG&lt;/strong&gt; (Directed Acyclic Graph) captures what actually matters: &lt;em&gt;which tasks depend on which&lt;/em&gt;. Everything else can run simultaneously. The manager thinks in &lt;strong&gt;task trees&lt;/strong&gt; — nested groups marked as sequential or parallel — and the runtime flattens them into a dependency graph, executing waves of unblocked tasks with &lt;code&gt;Promise.all&lt;/code&gt;. Dependent tasks automatically inherit the results of their prerequisites, so agents never duplicate work.&lt;/p&gt;

&lt;p&gt;The difference: a flat plan says "check Toronto, then London, then compare" (serial — slow). A DAG says "check both cities at the same time, then compare" (parallel where possible — fast). The DAG finds the fastest path through the work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/tutorial_docs/phase-3-step-4.md" rel="noopener noreferrer"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-3-step-4" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/blob/main/.claude/skills/phase-3-step-4-dag-execution.skill" rel="noopener noreferrer"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hurray!&lt;/strong&gt; We now have a manager agent that decomposes goals into structured task trees, executes them as DAGs with maximum parallelism, passes context between dependent tasks, and visualizes the whole thing in a live web dashboard.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are many more concepts to explore — reliability, error recovery, human-in-the-loop, cost control, evaluation — and I'm planning to publish them as smaller, standalone pieces alongside this series.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Thanks for reading! &lt;a href="https://medium.com/@anzal.ansari" rel="noopener noreferrer"&gt;Follow me&lt;/a&gt; for more first-principles breakdowns of modern AI systems.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>agents</category>
      <category>programming</category>
    </item>
    <item>
      <title>Zero to Agent Swarm: A hands-on guide to building AI agents from scratch</title>
      <dc:creator>Anzal Ansari</dc:creator>
      <pubDate>Wed, 11 Mar 2026 13:13:34 +0000</pubDate>
      <link>https://dev.to/anzal_ansari/zero-to-agent-swarm-a-hands-on-guide-to-building-ai-agents-from-scratch-45im</link>
      <guid>https://dev.to/anzal_ansari/zero-to-agent-swarm-a-hands-on-guide-to-building-ai-agents-from-scratch-45im</guid>
      <description>&lt;h2&gt;
  
  
  Is this for you?
&lt;/h2&gt;

&lt;p&gt;This tutorial is for engineers who already know how to build software but want to understand the &lt;strong&gt;agent ecosystem&lt;/strong&gt;. The code is in &lt;strong&gt;TypeScript&lt;/strong&gt; / &lt;strong&gt;Node.js&lt;/strong&gt; — familiarity helps but isn't required. We'll use &lt;strong&gt;Docker&lt;/strong&gt; in Phase 2, and you'll need an &lt;strong&gt;LLM API key&lt;/strong&gt; (the default is Gemini, but any provider works — just swap the LLM call).&lt;/p&gt;

&lt;p&gt;The goal isn't to walk you through a codebase. It's to give you the thinking tools to design agent architectures, features, and systems — so that by the end, you understand how a single agent works and how multiple agents coordinate.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mental model
&lt;/h2&gt;

&lt;p&gt;Here is the model we'll build toward, one piece at a time:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Agent = Triggers → Loop(Thinking + Tools + Memory), inside a Container&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Triggers&lt;/strong&gt; are what start the loop. A user message is the obvious one, but triggers can also be a schedule, a webhook, a file appearing in a directory, or another agent handing off a task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thinking&lt;/strong&gt; is where the LLM lives. On each iteration, the agent looks at its goal, what it knows so far, and what just happened — then decides what to do next. This includes &lt;strong&gt;perceiving&lt;/strong&gt; the input (understanding what arrived before reasoning about it) and &lt;strong&gt;assembling context&lt;/strong&gt; — the system prompt, identity, memory, conversation history, and latest observation that get sent to the LLM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt; are how the agent acts on the world. In this model, the agent has no default output channel — it can't print, respond, or signal completion without a tool. Text generation is just internal reasoning until a tool carries it somewhere. That's a deliberate design choice: it forces you to think explicitly about every action the agent can take, because nothing happens implicitly. The set of tools you give an agent is its interface with the world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Memory&lt;/strong&gt; is what persists across iterations. Without it, each thinking step starts from scratch. With it, the agent can accumulate facts, track progress, and avoid repeating itself. Memory can live in the context window, in a file, or in a database — depending on how long it needs to last.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The container&lt;/strong&gt; is the environment the agent runs in. It's easy to overlook, but it matters: it defines what tools are available, what the agent can access, and — critically — what it can't damage. A well-designed container is what makes autonomy safe enough to actually grant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A note on loops:&lt;/strong&gt; The formula shows one loop — but real applications are rarely that flat. In practice, loops nest. A single agent might run an inner loop to complete a subtask, while sitting inside a larger loop that coordinates multiple agents, manages retries, or waits for external triggers. An agent swarm is really just loops containing loops, with handoffs between them. &lt;/p&gt;

&lt;h2&gt;
  
  
  The roadmap
&lt;/h2&gt;

&lt;p&gt;We build in three phases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;Goal&lt;/th&gt;
&lt;th&gt;What you'll have&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1. Birth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Build a single agent from scratch&lt;/td&gt;
&lt;td&gt;A local assistant that can explore your filesystem&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2. Upgrades&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Make it powerful and safe&lt;/td&gt;
&lt;td&gt;Memory, a Docker container, bash, autonomy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;3. Swarm&lt;/strong&gt; &lt;em&gt;(coming soon)&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Run multiple agents together&lt;/td&gt;
&lt;td&gt;Specialized agents coordinating on tasks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's build one.&lt;/p&gt;




&lt;h1&gt;
  
  
  Phase 1: Birth of an Agent
&lt;/h1&gt;

&lt;p&gt;We start even simpler than an LLM call — a plain input/output loop with no intelligence at all — and build up step by step until we have something that genuinely qualifies as an agent.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Fca595a11-5789-42f7-9922-75c7d87f63e9" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Fca595a11-5789-42f7-9922-75c7d87f63e9" width="560" height="284"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Make it talk. A Channel = 1 Trigger + 1 Tool
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: the first **Trigger&lt;/em&gt;&lt;em&gt;, the first **Tool&lt;/em&gt;&lt;em&gt;, and therefore the first **Channel&lt;/em&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A message arriving is a &lt;strong&gt;Trigger&lt;/strong&gt;. A reply going out is a &lt;strong&gt;Tool&lt;/strong&gt; — not in the API "tool use" sense, but in the first-principles sense: it's a capability the agent uses to act on the world. Together, a Trigger and a Tool form a &lt;strong&gt;Channel&lt;/strong&gt;: something that listens and something that speaks back.&lt;/p&gt;

&lt;p&gt;We start with the simplest possible version: a REPL. You type something, it prints it back. No LLM, no logic. Just the Channel: input in, output out.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2Fcff380fc-12b1-488d-a566-447ace9f997b" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Fcff380fc-12b1-488d-a566-447ace9f997b" width="772" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the scaffold everything else will hang on.&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-1-step-1.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-1-step-1" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-1-step-1-make-it-talk.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Make it think.
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: Thinking.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now we wire in the LLM — the &lt;strong&gt;Thinking&lt;/strong&gt; layer. The input still comes in through the same Channel, but instead of echoing it back, we send it to the model and return what comes out.&lt;/p&gt;

&lt;p&gt;Think of it like the association cortex — it takes input and transforms it. Tokens in, tokens out. The conversation history acts as working memory: the agent remembers what was said in this session, but nothing beyond it.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2Faccd0efb-aa1a-407a-8c87-71dbdc63fa23" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Faccd0efb-aa1a-407a-8c87-71dbdc63fa23" width="958" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this stage we have a Channel + Thinking — a traditional chatbot. It can reason and respond, but it has no persistent Memory and no Tools beyond replying.&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-1-step-2.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-1-step-2" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-1-step-2-make-it-think.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  3. Give it a choice. A second tool.
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: more Tools.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Replying to the user is already a &lt;strong&gt;Tool&lt;/strong&gt; — the first one. Now we add a second. This is what gives &lt;strong&gt;Thinking&lt;/strong&gt; a choice: based on the input, the LLM decides whether to reply directly or invoke the other Tool. If it doesn't invoke anything, the default action fires — reply to the user.&lt;/p&gt;

&lt;p&gt;For this step we'll use a &lt;code&gt;list_files&lt;/code&gt; Tool — it lists the contents of a directory. It's a good first Tool because it's read-only and relatively safe. The agent can look around but can't break anything.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2Fecac4d84-e220-48b9-9151-1e4ce86b152a" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Fecac4d84-e220-48b9-9151-1e4ce86b152a" width="812" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-1-step-3.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-1-step-3" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-1-step-3-another-tool.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  4. Give it a decision loop
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: the **Loop&lt;/em&gt;* that binds Thinking, Tools, and Memory.*&lt;/p&gt;

&lt;p&gt;Right now the agent thinks once and acts once. Without a loop, it shoots in the dark — it uses a &lt;strong&gt;Tool&lt;/strong&gt; and stops. It doesn't check whether the action worked. It doesn't know if the task is done. It doesn't report back. It just stops.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2F43b91766-c361-44e2-888c-6e3625ec13af" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2F43b91766-c361-44e2-888c-6e3625ec13af" width="560" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Loop&lt;/strong&gt; is the engine at the center of the model. A Trigger fires, and the Loop takes over: think, act, observe the result, think again. Tools act on the world from &lt;em&gt;inside&lt;/em&gt; the loop — every iteration can produce side effects. The loop exits when Thinking decides the task is done and replies to the user. If a tool call fails, the agent sees the error and adapts — retry, try something else, or give up and explain why.&lt;/p&gt;

&lt;p&gt;This is what separates a chatbot from an agent. The Loop turns Thinking + Tools + Memory from a one-shot into a sustained process. Memory is what gives the loop continuity — without it, each iteration would be blind to what the agent just tried.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stopping conditions.&lt;/strong&gt; The loop needs two exit mechanisms: the LLM decides the task is done (produces a final response instead of a tool call), and a &lt;strong&gt;hard cap&lt;/strong&gt; on iterations (&lt;code&gt;MAX_STEPS&lt;/code&gt;) so a confused agent can't loop forever.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Trigger
   │
   ▼
Think
   │
   ▼
Choose Tool
   │
   ▼
Execute Tool
   │
   ▼
Observe Result
   │
   ▼
Done? (or max steps?)
 ├─ yes → respond
 └─ no  → Think again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fgithub.com%2Fuser-attachments%2Fassets%2Fdbf8c8ff-8e0b-4ece-a84f-ec5be6aac490" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Fdbf8c8ff-8e0b-4ece-a84f-ec5be6aac490" width="1994" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-1-step-4.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-1-step-4" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-1-step-4-decision-loop.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Checkpoint:&lt;/strong&gt; We now have Triggers → Loop(Thinking + Tools + working memory). That's a working agent.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Phase 2: Upgrades
&lt;/h1&gt;

&lt;p&gt;Now that we have a basic agent, we'll fill in the rest of the model: upgrade &lt;strong&gt;Memory&lt;/strong&gt; from ephemeral to persistent, build the &lt;strong&gt;Container&lt;/strong&gt;, give the Loop more powerful &lt;strong&gt;Tools&lt;/strong&gt;, then add more &lt;strong&gt;Triggers&lt;/strong&gt; so it can act on its own.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Better memory
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Upgrading the model: persistent **Memory&lt;/em&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Loop already has working memory — the conversation history that accumulates as the agent thinks and acts. But it's ephemeral. Once the session ends, it's gone. Apart from the model's built-in knowledge and whatever is in the system prompt, the agent has nothing to draw on next time it wakes up.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2F91bd686d-7280-4292-8662-efa637c51ab5" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2F91bd686d-7280-4292-8662-efa637c51ab5" width="560" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We upgrade Memory with persistence in two ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Always loaded&lt;/strong&gt; — files that get injected into every session automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;identity.md&lt;/code&gt; — who the agent is, how it behaves. Human-curated. Stable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;notes.md&lt;/code&gt; — what the agent has learned across past sessions. Agent-curated. Grows over time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Retrieval-based&lt;/strong&gt; — when memory grows too large to load in full, the agent queries it instead. Embeddings and vector search let it pull only what's relevant to the current task. Out of scope for this tutorial, but the mechanism is straightforward: more Tools that query an embedding store.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2F20e58efb-2f0f-40a2-8f87-952df54be86f" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2F20e58efb-2f0f-40a2-8f87-952df54be86f" width="1054" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-2-step-1.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-2-step-1" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-2-step-1-better-memory.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Stronger containment
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Adding to the model: the Container.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With more &lt;strong&gt;Tools&lt;/strong&gt; comes more risk. As we give the agent more capabilities and more autonomy, mistakes get expensive. At the application level, we can restrict what the agent is allowed to do — but these controls are code, and code has bugs.&lt;/p&gt;

&lt;p&gt;The safer approach is an OS-level &lt;strong&gt;Container&lt;/strong&gt; — in our case, a Docker container. Here we define exactly what the world looks like for the agent: what filesystem it sees, what it can touch, what it can't. If the agent goes wrong and tries to delete everything it knows, your actual data stays safe.&lt;/p&gt;

&lt;p&gt;We set up the &lt;strong&gt;Container&lt;/strong&gt; now, &lt;em&gt;before&lt;/em&gt; giving the agent more power. Safety first.&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-2-step-2.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-2-step-2" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-2-step-2-containment.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Bash access — real power, safely contained
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Expanding the model: powerful Tools, safely contained.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that the &lt;strong&gt;Container&lt;/strong&gt; is in place, we can safely give the agent real power.&lt;/p&gt;

&lt;p&gt;Let's give it bash — the most versatile &lt;strong&gt;Tool&lt;/strong&gt; there is. The agent can now run the code it writes, do git operations, install packages, and — if we allow it — modify its own codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-2-step-3.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-2-step-3" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-2-step-3-more-tools.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. File watcher + clock — the agent wakes itself
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Expanding the model: more Triggers for autonomy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Currently, the agent wakes up when you message it, does its work, saves to &lt;strong&gt;Memory&lt;/strong&gt;, and goes back to sleep. Your message is the only &lt;strong&gt;Trigger&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What if you want more? We add two new &lt;strong&gt;Triggers&lt;/strong&gt;: a &lt;strong&gt;file watcher&lt;/strong&gt; that fires when something changes in the workspace, and a &lt;strong&gt;clock&lt;/strong&gt; that fires on a schedule. Both feed into the same Loop — the agent doesn't care which &lt;strong&gt;Trigger&lt;/strong&gt; woke it up.&lt;/p&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%2Fgithub.com%2Fuser-attachments%2Fassets%2Ffd6deab1-6881-4058-9960-fbcd87f3a50c" class="article-body-image-wrapper"&gt;&lt;img alt="image" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fuser-attachments%2Fassets%2Ffd6deab1-6881-4058-9960-fbcd87f3a50c" width="2560" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="//./phase-2-step-4.md"&gt;Explanation&lt;/a&gt; · &lt;a href="https://github.com/ordervschaos/zero-to-agent-swarm/tree/phase-2-step-4" rel="noopener noreferrer"&gt;Code&lt;/a&gt; · &lt;a href="//../.claude/skills/phase-2-step-4-more-triggers.skill"&gt;Skill&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Checkpoint:&lt;/strong&gt; Our agent now has all the pieces — Triggers → Loop(Thinking + Tools + Memory), inside a Container. Time to multiply it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Voilà - we now have a functional agent. The core building blocks are in place. From here you can extend it in many directions: add new channels like WhatsApp or Slack, give it more tools, introduce new triggers, or spin up additional agents that coordinate with it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Phase 3: A Party of Agents &lt;em&gt;(coming soon)&lt;/em&gt;
&lt;/h1&gt;

&lt;p&gt;One agent is useful. But real work often needs specialists — a researcher, a coder, a reviewer — each with their own &lt;strong&gt;Tools&lt;/strong&gt;, &lt;strong&gt;Memory&lt;/strong&gt;, and responsibilities. A single agent can context-switch between roles, but it loses focus. Dedicated agents stay sharp — and they can work in parallel.&lt;/p&gt;

&lt;p&gt;What makes one agent different from another? Its &lt;strong&gt;Thinking&lt;/strong&gt; (which model, what system prompt), its &lt;strong&gt;Memory&lt;/strong&gt; (what it knows), its &lt;strong&gt;Tools&lt;/strong&gt; (what it can do), its &lt;strong&gt;Triggers&lt;/strong&gt; (what wakes it up), and its &lt;strong&gt;Container&lt;/strong&gt; (what it can see). Package these together into a config — the agent's genome — and from one codebase you can spin up as many specialized agents as you need.&lt;/p&gt;

&lt;p&gt;Phase 3 will cover:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Agent genome&lt;/strong&gt; — Package the model into a config. Same code, different capabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Management&lt;/strong&gt; - Shared memory, context pruning, and thread persistence. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent teams&lt;/strong&gt; — Coordination patterns: serial handoffs, parallel work, shared context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing and orchestration&lt;/strong&gt; — An outer agent that reads a task, picks the right specialist, and manages the workflow.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Thanks for reading! &lt;a href="https://medium.com/@anzal.ansari" rel="noopener noreferrer"&gt;Follow me&lt;/a&gt; for the next part and more first-principles breakdowns of modern AI systems.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
