<?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 Chen Yang on Medium]]></title>
        <description><![CDATA[Stories by Chen Yang on Medium]]></description>
        <link>https://medium.com/@chen.yang_50796?source=rss-0d518a6f90bf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*k-PtQhq78DkFKqnF</url>
            <title>Stories by Chen Yang on Medium</title>
            <link>https://medium.com/@chen.yang_50796?source=rss-0d518a6f90bf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:12:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chen.yang_50796/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[Human in the Loop, Not Human as the Loop]]></title>
            <link>https://medium.com/@chen.yang_50796/human-in-the-loop-not-human-as-the-loop-0bb838372d2a?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bb838372d2a</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[openclaw]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Wed, 06 May 2026 09:27:31 GMT</pubDate>
            <atom:updated>2026-05-06T09:27:31.223Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why long-running coding agents need workflow awareness, not just better prompts.</em></p><p>This project started with a fairly ordinary observation: agentic coding was useful, but the long run did not fit my working rhythm yet.</p><h3>The Cost of Keeping Going</h3><p>Before Agent State Machine had a name, I was using OpenClaw.</p><p>With the right configuration, it was capable enough that I started thinking in terms of longer runs instead of single prompts.</p><p>The trade-off showed up in usage.</p><p>An afternoon of work could use around 25–40% of my weekly Claude Max subscription budget. That was more than I expected. It did not make the tool unusable, but it made me more cautious.</p><p>The issue was not that OpenClaw was bad. The issue was that open-ended autonomy made the long run expensive. If the agent can keep going for hours, then cost, visibility, and recovery become part of the product, not side concerns.</p><p>So I moved back to Claude Code Desktop, then Claude Code in the terminal.</p><h3>Return to Claude Code</h3><p>That worked better for a while. The loop was tighter. I could decide when to give more context, when to stop a direction, and when to ask for a smaller change. It felt easier to keep the work bounded.</p><p>But then I started noticing a different kind of overhead.</p><p>Claude Code could implement a task. It could review a diff. It could fix a review comment. It could explain a failing test. The individual steps were fine.</p><p>What I was still doing manually was the workflow between those steps.</p><p>I would ask it to implement something. Then I would ask it to prepare the work for review. Then I would ask for review. Then I would ask it to fix the review comments. Then I would ask for another review. Then I would accept the change. Then I would check whether the result actually satisfied the task. Then I would move to the next item.</p><p>Sometimes there was a real decision in there. Often there was not. A lot of it was just me typing the next step in a process I already understood.</p><p>Review this.</p><p>Fix that.</p><p>Re-review it.</p><p>Merge it.</p><p>Pick up the next task.</p><p>That was the part I wanted to automate.</p><h3>Human Judgment, Not Workflow Labor</h3><p>Not the whole act of software judgment. Not product direction. Not deciding what should exist.</p><blockquote><em>I still want a human in the loop. I just do not want the human to be the loop.</em></blockquote><p>There is a difference between making a judgment call and acting as the button that advances the process.</p><p>The part I wanted to remove was the repeated movement through a development loop that already has a clear next action most of the time.</p><p>In other words, the problem was not the first prompt. The problem was the eighth hour.</p><p>That became the starting point for Agent State Machine.</p><h3>The Shape of the Idea</h3><p>The first version of the idea was simple: a long-running workflow should know the next normal step without needing me to type it every time.</p><p>If the work needs review, send it to review. If review finds a real problem, send it back for correction. If the correction is done, review again. If the work is accepted, move forward. If something does not make sense, stop and explain why.</p><p>That is still basically the product shape, at least at the idea level.</p><h3>What Long Runs Need</h3><p>The important constraint is that the loop should stay visible over time. I do not want the useful state to live only inside a long model conversation. If an agent runs for minutes, you can tolerate some opacity. If it runs for hours, you need to understand where it is, what it is waiting for, and what it believes happened.</p><p>That is the part I think many agent demos skip. They show the impressive first move. They do not always show what happens after the fifth transition, after a retry, after a partial failure, after the agent has been left alone long enough for the original chat context to stop being a reliable source of truth.</p><p>For a short demo, visibility can look secondary. For a long run, it is the difference between “the agent is doing work” and “I have no idea what state this thing is in.”</p><p>This also shaped how I think about responsibility.</p><p>A long-running agent should not blur every responsibility into one vague instruction to “finish the task.” There should be a difference between doing the work, checking the work, correcting the work, and deciding whether the result is good enough. Those boundaries are not bureaucracy. They are how the human can understand what happened later.</p><p>The human should still be able to steer, pause, correct, reject, or change the direction. But the default path should not require the human to keep saying “now do the next normal thing.”</p><p>In practice, the project has grown by running into small workflow questions and making them explicit.</p><ul><li>What should happen when the model appears to be working but no useful progress is visible?</li><li>What should happen when the same work needs to be retried?</li><li>What should happen when the agent says something is done, but the external evidence does not agree?</li><li>What should happen when old blocked work is still sitting around after a restart?</li><li>What should happen when one piece of work only makes sense after another piece lands?</li></ul><p>None of those questions came from wanting an agent platform in the abstract. They came from asking what would break if the system kept running after I stopped watching it closely.</p><h3>Writing While Building</h3><p>That is also why I want to write these posts while the project is still being built. The finished architecture will probably make the path look cleaner than it was. I want to keep some record of the actual sequence: try a tool, notice the cost of long runs, return to a tighter loop, notice the manual workflow overhead, then build enough machinery to let the loop continue safely.</p><p>OpenClaw showed me that longer-running coding agents can be useful. Claude Code reminded me that keeping the interaction tight still matters. Agent State Machine is my attempt to put an inspectable workflow loop around those capabilities so the long run becomes practical.</p><p>I still want the model to do useful work.</p><p>I just want it to keep going in a way I can afford, inspect, and recover.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bb838372d2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Built a Self-Improving Agent]]></title>
            <link>https://medium.com/@chen.yang_50796/why-i-built-a-self-improving-agent-560f4e986b79?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/560f4e986b79</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 01:21:49 GMT</pubDate>
            <atom:updated>2026-04-11T01:21:49.701Z</atom:updated>
            <content:encoded><![CDATA[<p>I use Claude Code every day. It writes code for me, refactors my projects, debugs my bugs. And every day, the same thing bothers me.</p><p>It never checks its own work.</p><h3>The frustration</h3><p>Claude Code will write a function, tell me it’s done, and move on. Did it work? Did it handle edge cases? Did it even run? It doesn’t know. It doesn’t check. It just… moves on.</p><p>I’d ask it to build something, and it would. Then I’d test it and find a bug. I’d tell it about the bug, it would fix it, and introduce another one. Back and forth, with me as the test runner, me as the quality gate, me as the one closing the loop.</p><p>One day it hit me: I’m the eval function.</p><p>The LLM generates. I evaluate. The LLM adjusts. I evaluate again. The whole loop depends on me sitting there, running the code, reading the output, feeding errors back in. Without me, the loop is open. The agent produces work but has no idea if it’s any good.</p><p>Three things bothered me:</p><ol><li>Claude Code doesn’t test its own product.</li><li>Claude Code doesn’t loop on itself.</li><li>Claude Code doesn’t evolve.</li></ol><h3>The spark</h3><p>I stumbled on Karpathy’s autoresearch project. The idea was elegant: an agent that modifies a training script, runs it, measures the result, and keeps the change only if the metric improves. No human in the loop. The agent runs overnight and produces a hundred iterations, each one measurably better than the last.</p><p>The key insight wasn’t the code. It was the architecture. There’s a clear separation: the thing being improved (the training script) and the thing measuring improvement (validation loss). The metric doesn’t change. Only the subject of improvement changes.</p><p>That’s when I realized what was missing from Claude Code. Not capability — it’s incredibly capable. What’s missing is the loop. The feedback loop that every human developer takes for granted: write, run, check, fix, repeat.</p><h3>The constraint that became a feature</h3><p>Here’s the thing — I don’t have API keys. I don’t have a fancy infrastructure. All I have is a Claude Code subscription. My only interface to an LLM is claude -p — the CLI piped mode.</p><p>At first this felt like a limitation. Then I realized it was actually a gift. It forced simplicity. No frameworks, no orchestration libraries, no vector databases. Just bash scripts piping prompts to claude -p and parsing the output.</p><p>Five bash scripts. That’s the whole agent. One to orchestrate, one to solve, one to evaluate, one to improve, one to review.</p><h3>The discovery</h3><p>I kept coming back to a simple observation: agents are like humans. Humans don’t get better by just doing more work. They get better by reflecting on their work, identifying what went wrong, and changing their approach.</p><p>The best developers I know don’t just write code. They review their own code. They write tests before they write implementations. They do retrospectives. They adopt methodologies that have been refined over decades — agile, TDD, code review.</p><p>Why shouldn’t an agent do the same?</p><p>So I built an agent that works the way a human developer works:</p><ul><li>Before a big task, break it into sprints.</li><li>After each sprint, test it.</li><li>If the test fails, look at what you wrote, understand the failure, and fix it.</li><li>After enough runs, review your own process — not just what failed, but how you work.</li><li>Use that review to improve your tools.</li></ul><h3>The principle</h3><p>I wrote down what I learned in a principles document. One line stands out to me:</p><blockquote><em>Any non-trivial learning needs a learning path.</em></blockquote><p>When I first ran the agent on simple tasks — reverse a string, sum integers — it passed everything 10 out of 10. The improvement loop had nothing to work with. No failures, no signal, no gradient to climb.</p><p>This is obvious in hindsight. You don’t learn by acing tests you already know. You learn at the frontier of what you can’t do yet. The agent needed harder problems, problems it would fail, so it could learn from those failures and get better.</p><p>That’s true for humans too. We grow at the edge of our ability, not in the comfort zone.</p><h3>Where it stands</h3><p>The agent can build a multi-file project from a task description, test it against objective criteria, and retry when it fails — feeding its own errors back into the next attempt, no human needed.</p><p>It has an adversarial critic that reviews the solver and finds weaknesses before they become failures. It has a logbook that traces every decision, every timing, every outcome.</p><p>And it has an evolve loop — a mechanism to build the next version of itself, test that version against the full task suite, and promote it only if everything passes. The agent uses itself to develop its next version.</p><p>Is it perfect? Not even close. The evolve loop is still fragile. The retry mechanism was broken until the critic found it. The sprint planner sometimes overthinks simple tasks.</p><p>But the loop is closing. And that’s the point. Not perfection — iteration. Not capability — self-awareness.</p><p>The agent doesn’t just write code anymore. It checks its own work.</p><p><em>This is the first in a series about building a self-improving agent from scratch. Next: what happened when we let the agent review its own code — and the ten real bugs it found.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=560f4e986b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Tax of Agent-to-Agent Messaging — How sessions_send Nearly Broke Our Token Budget]]></title>
            <link>https://medium.com/@chen.yang_50796/the-hidden-tax-of-agent-to-agent-messaging-how-sessions-send-nearly-broke-our-token-budget-4b24a2fae6de?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b24a2fae6de</guid>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 01:05:29 GMT</pubDate>
            <atom:updated>2026-02-28T01:05:29.886Z</atom:updated>
            <content:encoded><![CDATA[<p><em>We let AI agents talk to each other. Token costs exploded. Here’s why, and what we replaced it with.</em></p><h3>The Idea That Seemed Smart</h3><p>When we first built our multi-agent dev team, the architecture was intuitive: agents talk to a PM agent (Todd), Todd dispatches work, agents report back. Just like a real team.</p><pre>Alex → sessions_send → Todd: &quot;I&#39;m idle, any work?&quot;<br>Todd → sessions_send → Alex: &quot;Take #42&quot;<br>Alex → sessions_send → Todd: &quot;Done with #42&quot;<br>Todd → sessions_send → Casey: &quot;Test #42&quot;<br>Casey → sessions_send → Todd: &quot;#42 passes&quot;<br>Todd → DM Master: &quot;All done&quot;</pre><p>Looks clean. Five messages, one task. What could go wrong?</p><p>Everything.</p><h3>The Math Nobody Does</h3><p>Here’s what actually happens when Agent A sends a message to Agent B via sessions_send:</p><ol><li><strong>Agent A’s turn</strong> — The model processes A’s full context (system prompt + conversation history + tools) to generate the message. Cost: A’s context window.</li><li><strong>Agent B receives</strong> — The message lands in B’s session. B’s model now processes B’s full context + the new message to respond. Cost: B’s context window.</li><li><strong>Agent B responds</strong> — If B sends back to A, we repeat step 1.</li></ol><p><strong>Each </strong><strong>sessions_send triggers a full model inference on the receiving agent&#39;s context.</strong> It&#39;s not a cheap message relay — it&#39;s waking up an entire LLM session.</p><h3>One task, real cost</h3><p>Let’s trace a single task through our old workflow:</p><p>StepWhoActionContext processed1AlexHeartbeat wakes, asks Todd for workAlex’s full context (~30k tokens)2ToddReceives message, checks board, repliesTodd’s full context (~40k tokens)3AlexReceives assignment, starts workAlex’s context again (~30k tokens)4AlexCompletes, tells ToddAlex’s context (~35k, grew from coding)5ToddReceives completion, tells Casey to testTodd’s context (~45k, grew from messages)6CaseyReceives test request, runs testsCasey’s full context (~30k tokens)7CaseyReports results to ToddCasey’s context (~35k tokens)8ToddReceives results, DMs MasterTodd’s context (~50k tokens)</p><p><strong>Total context processed: ~295k tokens for one task.</strong></p><p>And that’s the happy path. No retries, no follow-up questions, no “can you clarify?”</p><h3>Now multiply by agents and heartbeats</h3><p>With 4 dev agents on 10-minute heartbeats:</p><ul><li><strong>24 heartbeats per agent per hour</strong> (4 agents = 96 heartbeats)</li><li>Each idle heartbeat → sessions_send to Todd → Todd processes → Todd replies</li><li><strong>Todd’s context grows with every message from every agent</strong></li><li>By hour 3, Todd’s context was hitting 150k+ tokens — mostly agent chatter</li></ul><p>We measured Todd’s session at one point: <strong>40% of his context was just “I’m idle, any work?” / “No work available” exchanges.</strong> Pure waste.</p><h3>The Exponential Problem</h3><p>Here’s what makes agent-to-agent messaging particularly dangerous:</p><h3>Context accumulation is multiplicative</h3><p>Every message to Todd adds to Todd’s context. Todd’s context gets bigger. Bigger context = more tokens per inference. More agents = more messages = faster growth.</p><pre>Hour 1: Todd context = 30k (base) + 10k (messages) = 40k<br>Hour 2: Todd context = 30k + 25k = 55k  <br>Hour 3: Todd context = 30k + 45k = 75k<br>Hour 4: Todd context = 30k + 70k = 100k → compaction triggers</pre><p>After compaction, old messages get dropped — but the cycle restarts. And during those hours, every inference on Todd’s session costs more because the context is bigger.</p><h3>Cross-contamination</h3><p>When Alex messages Todd about issue #42, that context now lives in Todd’s session. When Casey messages Todd about a different issue, Casey’s context is also there. Todd’s session becomes a dumping ground for everyone’s problems.</p><p>This means Todd’s responses get slower (more context to process) and less accurate (irrelevant context from other agents diluting the signal).</p><h3>The fan-out problem</h3><p>Todd doesn’t just receive — he relays. “Casey, go test #42” is another sessions_send. Now Casey&#39;s context grows too. One task creates a cascade:</p><pre>1 task = Alex→Todd + Todd→Alex + Alex→Todd + Todd→Casey + Casey→Todd + Todd→Master<br>       = 6 full-context inferences<br>       = ~300k tokens processed</pre><p><strong>10 tasks = ~3M tokens just in coordination overhead.</strong> The actual coding work is separate.</p><h3>What We Measured</h3><p>Here’s what our sessions looked like during the sessions_send era vs. after we removed it:</p><h3>Before: Agent-to-Agent messaging</h3><p>When agents were messaging Todd on every heartbeat, the symptoms were obvious:</p><ul><li>Todd’s session regularly hitting context limits, compacting multiple times per day</li><li>Agents spending 30–40% of their heartbeats just asking Todd for work and waiting for replies</li><li>Todd’s context was 90%+ full — mostly “I’m idle” / “no work available” exchanges</li><li>Each coordination round-trip added ~60–80k tokens across both sessions</li></ul><p>We didn’t have detailed token logging at the time (lesson: measure early). But the compaction frequency and context saturation told the story.</p><h3>After: GitHub-as-state, no agent messaging</h3><p>After eliminating sessions_send, here&#39;s a typical overnight sprint:</p><p>AgentSessionTotal TokensNotesToddmain36kTriage + monitoring onlyAlexmain149kFull night of codingSammain23kBlocked on review, lighter sessionCaseymain152kReviews + testing all nightRileymain98kRequirements + docs</p><p><strong>Todd went from being the most expensive session to the cheapest.</strong> 36k tokens for a full night of coordination vs. 100k+ per hour when agents were messaging him.</p><p>Alex and Casey are high — but that’s actual work (reading files, writing code, running tests). Not coordination overhead.</p><h3>The channel session tax</h3><p>We also discovered agents had <strong>duplicate sessions</strong> — a main session AND a channel session:</p><p>AgentChannel Session TokensCasey84kAlex64kSam43kTodd31k</p><p>These channel sessions accumulated from the old sessions_send pattern and heartbeat misconfiguration. That&#39;s 222k tokens of pure waste sitting in sessions that shouldn&#39;t have been active.</p><h3>Why It’s Exponential, Not Linear</h3><p>The intuition is “more messages = more cost, linearly.” But it’s actually worse:</p><ol><li><strong>Context grows per message</strong> → each subsequent message costs more to process</li><li><strong>Hub agents (Todd) receive from N agents</strong> → Todd’s cost scales with team size</li><li><strong>Round-trips multiply</strong> → one task = 2N messages minimum (request + response per agent)</li><li><strong>Compaction doesn’t help</strong> → it just resets the cycle, old context is lost</li></ol><p>With 4 agents messaging Todd every 10 minutes:</p><ul><li><strong>Per hour</strong>: 24 messages to Todd → 24 full-context inferences on Todd’s growing session</li><li><strong>Todd’s cost alone</strong>: grows quadratically as context accumulates between compactions</li></ul><p>Add a 5th agent? It’s not 25% more cost — it’s 25% more messages making ALL of Todd’s inferences more expensive.</p><h3>The Fix: Kill Agent-to-Agent Messaging</h3><p>We didn’t optimize sessions_send. We eliminated it.</p><h3>GitHub labels replace messages</h3><p>Instead of:</p><pre>Alex → Todd: &quot;I&#39;m idle&quot;<br>Todd → Alex: &quot;Take #42&quot;</pre><p>Now:</p><pre>Alex checks: gh issue list --label &quot;ready-for-dev&quot;<br>Alex claims: gh issue edit 42 --add-label &quot;assigned:alex&quot;<br>Alex DMs Master: &quot;Taking #42&quot;</pre><p><strong>Zero agent-to-agent tokens.</strong> Alex reads the board himself. Labels are the state machine.</p><h3>DMs go to the human, not the hub</h3><p>Instead of everything flowing through Todd:</p><pre>Alex → DM Master: &quot;[alex] Taking #42&quot;<br>Casey → DM Master: &quot;[casey] Tested #42 — PASS&quot;</pre><p>Each agent DMs the human directly. No relay, no hub, no context accumulation on a coordinator.</p><h3>Todd monitors, doesn’t dispatch</h3><p>Todd still exists. He checks for stuck work, triages tickets, ensures bugs get picked up. But he reads GitHub — he doesn’t receive messages from agents.</p><p>His context stays small. His inferences stay cheap.</p><h3>Config enforcement</h3><p>We deny the tools entirely:</p><pre>{<br>  &quot;id&quot;: &quot;alex&quot;,<br>  &quot;tools&quot;: {<br>    &quot;deny&quot;: [&quot;sessions_spawn&quot;, &quot;subagents&quot;]<br>  }<br>}</pre><p>And in the dev workflow:</p><pre>## Communication<br>| Channel | Use For |<br>|---------|---------|<br>| GitHub Issues | Status, progress, blockers |<br>| GitHub PR Comments | Code review, technical discussion |<br>| DM to Master | ALL reports |<br>| sessions_send | **Do NOT use.** No agent-to-agent messaging. |</pre><h3>The Results</h3><p>After removing sessions_send:</p><ul><li><strong>Todd’s token usage dropped ~70%</strong> — from most expensive session to cheapest</li><li><strong>No coordination overhead</strong> — agents check the board themselves</li><li><strong>No context pollution</strong> — each agent’s context is their own work, not everyone else’s</li><li><strong>Simpler debugging</strong> — when something goes wrong, you check one agent’s session, not a message chain across 3 agents</li><li><strong>Team scales better</strong> — adding a 5th agent doesn’t increase anyone else’s costs</li></ul><h3>The Lesson</h3><p>Agent-to-agent messaging feels natural because that’s how humans work. But humans don’t re-read their entire life history before processing each Slack message. LLMs do.</p><p>Every sessions_send is a full context-window inference on the receiving agent. That&#39;s not a message — it&#39;s waking up an entire brain to read a post-it note.</p><p><strong>Use shared state (GitHub, files, labels) instead of messages.</strong> It’s not just cheaper — it’s a fundamentally better architecture for AI agents. Shared state is read-on-demand. Messages are pushed-and-processed.</p><p>Your agents don’t need to talk to each other. They need to read the same board.</p><h3>Quick Reference: What To Use Instead</h3><p>Old PatternReplacementAgent asks PM for workAgent checks gh issue list directlyPM assigns task to agentAgent self-assigns with labelAgent reports completion to PMAgent DMs human directlyPM relays test request to QAQA checks needs-testing label on heartbeatAgents discuss blockersComment on GitHub issue, DM human if stuck</p><p><em>Part of a series on building autonomous AI dev teams with </em><a href="https://github.com/openclaw/openclaw"><em>OpenClaw</em></a><em>. Previous: </em><a href="#"><em>Autonomous AI Dev Teams — Heartbeats, Work Queues, and Self-Managing Agents</em></a><em>. Next: </em><a href="#"><em>The Forgetful Agent Problem</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b24a2fae6de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autonomous AI Dev Teams — Heartbeats, Work Queues, and Self-Managing Agents]]></title>
            <link>https://medium.com/@chen.yang_50796/autonomous-ai-dev-teams-heartbeats-work-queues-and-self-managing-agents-0fad942580e9?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fad942580e9</guid>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[discord]]></category>
            <category><![CDATA[openclaw]]></category>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 23:49:13 GMT</pubDate>
            <atom:updated>2026-02-24T23:49:13.828Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I made my AI agents pull their own work, manage their own PRs, and report back — without constant human prompting.</em></p><h3>The Problem</h3><p>I had multiple AI agents with their own Discord identities. They could write code, create PRs, run tests. But they just… sat there. Waiting for me to tell them what to do.</p><p>I wanted a team that:</p><ul><li>Wakes up periodically and checks the board</li><li>Pulls work autonomously based on priority</li><li>Manages the full PR lifecycle (code → review → fix → retest)</li><li>Reports status directly to me</li></ul><p>Basically: a self-managing dev team where GitHub is the work queue.</p><h3>The Architecture</h3><pre>┌──────────────────────────────────────────────────────┐<br>│                    Master (Human)                     │<br>│              Receives DMs from all agents             │<br>└──────────────────────┬───────────────────────────────┘<br>                       │ DMs (status updates)<br>          ┌────────────┼────────────┐<br>          ▼            ▼            ▼<br>      ┌───────┐   ┌────────┐   ┌───────┐<br>      │ Alex  │   │ Casey  │   │ Sam   │<br>      │Backend│   │   QA   │   │Frontend│<br>      └───┬───┘   └───┬────┘   └───┬───┘<br>          │            │            │<br>          └────────────┴────────────┘<br>                       │<br>               GitHub Issues + PRs<br>              (the shared work queue)</pre><p>No PM agent in the middle dispatching tasks. No agent-to-agent messaging. Each agent independently:</p><ol><li>Checks GitHub for work</li><li>Claims it with a label</li><li>Does the work</li><li>DMs the human</li></ol><p>Todd (Product Owner) exists but only triages tickets and monitors for stuck work — he doesn’t assign tasks.</p><h3>Step 1: Configure Heartbeats</h3><p>OpenClaw supports per-agent heartbeats. Each agent gets woken up at an interval:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [<br>      {<br>        &quot;id&quot;: &quot;alex&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/alex/workspace&quot;,<br>        &quot;heartbeat&quot;: {<br>          &quot;every&quot;: &quot;10m&quot;,<br>          &quot;session&quot;: &quot;agent:alex:main&quot;,<br>          &quot;target&quot;: &quot;discord&quot;,<br>          &quot;to&quot;: &quot;channel:CHANNEL_ID&quot;<br>        }<br>      }<br>    ]<br>  }<br>}</pre><p>Every 10 minutes, OpenClaw sends the heartbeat prompt to Alex’s session. Alex reads their HEARTBEAT.md and JD, then acts.</p><p><strong>Why 10 minutes?</strong> Fast enough to stay responsive, slow enough to avoid token burn. We tried 30 minutes early on — too slow. Work sat for half an hour between heartbeats.</p><p><strong>Session key matters.</strong> Use agent:&lt;name&gt;:main so heartbeats go to the agent&#39;s persistent DM session, not a channel session. We learned this the hard way — channel sessions meant agents were &quot;working&quot; but their status updates went to a channel nobody checked instead of DMing the human.</p><h3>Step 2: GitHub as the Work Queue</h3><p>No backlog database. No task dispatcher. Just GitHub Issues with labels:</p><pre>┌───────────────┐     ┌─────────────┐     ┌─────────────┐<br>│ ready-for-dev │ ──► │ assigned:*  │ ──► │ code-review │<br>│   (on board)  │     │  (claimed)  │     │  (PR open)  │<br>└───────────────┘     └─────────────┘     └─────────────┘<br>        │                                        │<br>        │                                        ▼<br>        │                                 ┌───────────────┐<br>        │                                 │ needs-testing  │<br>        │                                 └───────┬───────┘<br>        │                                         │<br>        │                    ┌────────────────────┤<br>        │                    ▼                    ▼<br>        │             ┌─────────────┐     ┌─────────────┐<br>        │             │ tested-pass │     │ tested-fail │<br>        │             └─────────────┘     └──────┬──────┘<br>        │                                        │<br>        └────────────────────────────────────────┘<br>                    (dev picks it up again)</pre><p>Labels ARE the state machine. Agents read labels. Agents write labels. That’s the entire coordination mechanism.</p><h3>Step 3: The Dev Agent’s Heartbeat</h3><p>Each developer agent has a JD that defines exactly what they do when they wake up:</p><pre>## On Heartbeat</pre><pre>1. Check develop builds (`gh run list --branch develop --limit 5`)<br>   — if any red and your merge caused it, fix before anything else</pre><pre>2. Check GitHub for your work:<br>   gh issue list --label &quot;assigned:alex&quot; --state open<br>   gh pr list --author @me --state open</pre><pre>3. If your PRs are waiting on review (not blocked by you)<br>   → pick up new work while you wait</pre><pre>4. If you have an open PR:<br>   - Check CI status → fix if failing<br>   - Rebase on develop<br>   - Read and address review comments</pre><pre>5. If no active work → find new work:<br>   gh issue list --label &quot;ready-for-dev&quot; --state open --limit 20<br>   gh issue list --label &quot;bug&quot; --state open --limit 20</pre><pre>   Priority: bugs first (any priority), then sprint features</pre><pre>6. Claim with label FIRST, then DM Master, then start work</pre><p><strong>The critical detail:</strong> agents must actually run gh issue list on every heartbeat. Early on, our agents checked their MEMORY.md and said &quot;no work to pick up&quot; — while 15 tickets sat on the board. Memory goes stale. GitHub doesn&#39;t.</p><h3>Step 4: The QA Agent’s Heartbeat</h3><p>Casey (QA) has a different loop:</p><pre>## On Heartbeat</pre><pre>1. Check develop builds — if red, find root cause, file bug</pre><pre>2. Check open PRs — review for quality + security<br>   - Skip if CI failing (comment and move on)<br>   - Verify PR is rebased on current develop<br>   - Approve or request changes<br>   - If approved → merge, add `needs-testing` to ticket</pre><pre>3. Check `needs-testing` tickets<br>   - Pull develop, spin up services locally<br>   - Run E2E suite<br>   - Pass → `tested-pass`<br>   - Fail → `tested-fail` with root cause comment</pre><p>Casey is both reviewer and tester. She merges PRs after review, then tests on develop after merge.</p><h3>Step 5: The Coordinator’s Heartbeat</h3><p>Todd (Product Owner) doesn’t assign work. He watches for problems:</p><pre>## On Heartbeat</pre><pre>1. Check develop builds — if red, ensure P1 bug exists</pre><pre>2. Triage new tickets — add priority/type/sprint labels<br>   (Unlabeled tickets are invisible to devs)</pre><pre>3. Check `tested-fail` → ensure dev picks it up</pre><pre>4. Monitor stuck work (&gt;30 min):<br>   - PR without review? Flag to Master<br>   - Bug not picked up? Flag to Master<br>   - Agent idle? Flag to Master</pre><p>Todd is the safety net, not the bottleneck. Work flows without him — he catches things that fall through cracks.</p><h3>The Communication Pattern</h3><p><strong>No agent-to-agent messaging.</strong> This is deliberate.</p><p>Early on, we had agents messaging each other via sessions_send. It created problems:</p><ul><li>Todd got overwhelmed with context from 4+ agents messaging him</li><li>Token costs exploded from agents having conversations with each other</li><li>Coordination bugs — agents telling each other conflicting things</li></ul><p>The fix: <strong>GitHub is the only communication channel between agents.</strong> Agents read labels and PR comments. They don’t talk to each other.</p><p>Each agent DMs the human directly using their own Discord bot:</p><pre>message({<br>  action: &quot;send&quot;,<br>  accountId: &quot;alex&quot;,  // ← Use YOUR bot, not the default<br>  target: &quot;user:MASTER_ID&quot;,<br>  message: &quot;[alex] Taking #220 — CostEstimate entities&quot;<br>})</pre><p><strong>The accountId matters.</strong> Without it, all DMs go through the default bot and appear in one thread. With it, each agent has their own DM thread. You see Alex, Sam, Casey, Todd as separate conversations.</p><h3>Avoiding Common Pitfalls</h3><h3>1. Agents Don’t Check the Board</h3><p>The most common failure. Agent says “no work available” while tickets sit on the board.</p><p><strong>Cause:</strong> Agent checks MEMORY.md instead of running gh issue list.</p><p><strong>Fix:</strong> Put the exact gh commands in the JD. Don&#39;t say &quot;check the board&quot; — say gh issue list --label &quot;ready-for-dev&quot; --state open.</p><h3>2. Agents Idle While PRs Wait</h3><p>Agent creates PR, then reports “waiting for review, no work to do.”</p><p><strong>Cause:</strong> Agent thinks having an open PR means they’re busy.</p><p><strong>Fix:</strong> Add to the heartbeat: “If your PRs are waiting on review (not blocked by you) → pick up new work while you wait.”</p><h3>3. Nobody Fixes Broken Develop</h3><p>CI passes but CD fails. Agents check --limit 1 which returns the most recent run (success), hiding the CD failure.</p><p><strong>Cause:</strong> Agents only check CI, not all workflows.</p><p><strong>Fix:</strong> gh run list --branch develop --limit 5 — check ALL workflows. If any are red, develop is broken.</p><h3>4. Bugs Get Ignored</h3><p>Devs pick up feature work while bugs sit on the board.</p><p><strong>Cause:</strong> Priority labels missing (Todd didn’t triage), or devs filter for bug + P1 and skip unlabeled bugs.</p><p><strong>Fix:</strong> All bugs rank above features, regardless of priority label. And Todd must add priority labels to bugs immediately on triage.</p><h3>5. Close/Reopen PR Breaks CI</h3><p>Agent has merge conflicts, closes the PR, and recreates it. Webhook breaks. Creates 4 PRs for one piece of work.</p><p><strong>Cause:</strong> Agent doesn’t know the standard fix.</p><p><strong>Fix:</strong> Put it in the JD: “Never close and recreate PRs. Rebase and force-push to the same branch.”</p><h3>6. Agent Spawns Sub-Agents</h3><p>Agent hits a big task, spawns 3 coding sub-agents. Token costs explode. Sub-agents conflict with each other.</p><p><strong>Cause:</strong> Task was too big for one ticket.</p><p><strong>Fix:</strong> Ban sub-agent spawning. If the task is too big, comment on the ticket requesting a breakdown. Smaller tickets, not more agents.</p><h3>The Config</h3><p>Here’s the minimal config for a 4-agent team:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [<br>      {<br>        &quot;id&quot;: &quot;todd&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/todd/workspace&quot;,<br>        &quot;heartbeat&quot;: {<br>          &quot;every&quot;: &quot;10m&quot;,<br>          &quot;session&quot;: &quot;agent:todd:main&quot;,<br>          &quot;target&quot;: &quot;discord&quot;,<br>          &quot;to&quot;: &quot;channel:TODD_CHANNEL&quot;<br>        },<br>        &quot;tools&quot;: {<br>          &quot;deny&quot;: [&quot;sessions_spawn&quot;, &quot;subagents&quot;]<br>        }<br>      },<br>      {<br>        &quot;id&quot;: &quot;alex&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/alex/workspace&quot;,<br>        &quot;heartbeat&quot;: {<br>          &quot;every&quot;: &quot;10m&quot;,<br>          &quot;session&quot;: &quot;agent:alex:main&quot;,<br>          &quot;target&quot;: &quot;discord&quot;,<br>          &quot;to&quot;: &quot;channel:ALEX_CHANNEL&quot;<br>        },<br>        &quot;tools&quot;: {<br>          &quot;deny&quot;: [&quot;sessions_spawn&quot;, &quot;subagents&quot;]<br>        }<br>      },<br>      {<br>        &quot;id&quot;: &quot;sam&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/sam/workspace&quot;,<br>        &quot;heartbeat&quot;: { &quot;...&quot; : &quot;same pattern&quot; },<br>        &quot;tools&quot;: {<br>          &quot;deny&quot;: [&quot;sessions_spawn&quot;, &quot;subagents&quot;]<br>        }<br>      },<br>      {<br>        &quot;id&quot;: &quot;casey&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/casey/workspace&quot;,<br>        &quot;heartbeat&quot;: { &quot;...&quot; : &quot;same pattern&quot; },<br>        &quot;tools&quot;: {<br>          &quot;deny&quot;: [&quot;sessions_spawn&quot;, &quot;subagents&quot;]<br>        }<br>      }<br>    ]<br>  },<br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;heartbeat&quot;: {<br>        &quot;showOk&quot;: false,<br>        &quot;showAlerts&quot;: true<br>      }<br>    }<br>  }<br>}</pre><p>Key details:</p><ul><li>sessions_spawn and subagents denied for all workers</li><li>showOk: false suppresses &quot;HEARTBEAT_OK&quot; spam in channels</li><li>Each agent has their own workspace with JD and MEMORY.md</li></ul><h3>Results</h3><p>After a full sprint with this setup:</p><ul><li><strong>Agents pull work autonomously</strong> — no manual task assignment</li><li><strong>GitHub labels drive the workflow</strong> — no coordination messages needed</li><li><strong>Each agent DMs me directly</strong> — I see status from everyone in separate threads</li><li><strong>Broken develop gets caught</strong> — agents check CI/CD on every heartbeat</li><li><strong>Bugs get fixed first</strong> — priority ordering is enforced in JDs</li><li><strong>No token waste on agent chatter</strong> — agents don’t talk to each other</li></ul><p>The human role: maintain the backlog, review designs, resolve conflicts, and occasionally fix a JD when an agent discovers a workflow gap.</p><p>The team delivered 4 features overnight while I slept. Not because the agents are smart — because the workflow is explicit and the work queue is self-serve.</p><h3>Key Takeaways</h3><ol><li><strong>GitHub labels are your state machine.</strong> Don’t build a task dispatcher. Use labels.</li><li><strong>Agents must query GitHub, not memory.</strong> Memory goes stale. gh issue list doesn&#39;t.</li><li><strong>No agent-to-agent messaging.</strong> GitHub is the shared state. DMs go to the human only.</li><li><strong>Ban sub-agent spawning.</strong> If the task is too big, break it down.</li><li><strong>10-minute heartbeats work.</strong> Fast enough to be responsive, cheap enough to sustain.</li><li><strong>JDs are the product.</strong> If an agent isn’t doing something, the JD doesn’t say to. Fix the JD, not the agent.</li></ol><p><em>Part of a series on building autonomous AI dev teams with </em><a href="https://github.com/openclaw/openclaw"><em>OpenClaw</em></a><em>. See also: </em><a href="#"><em>Building a Multi-Agent Dev Team with OpenClaw</em></a><em> and </em><a href="#"><em>Long-Lived Agents vs Sub-Agents</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fad942580e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launch Your Own AI Dev Squad — 10 Discord Bots, One OpenClaw Config]]></title>
            <link>https://medium.com/@chen.yang_50796/launch-your-own-ai-dev-squad-10-discord-bots-one-openclaw-config-3596089b15ca?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3596089b15ca</guid>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 03:34:49 GMT</pubDate>
            <atom:updated>2026-02-23T03:34:49.505Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I gave each AI agent their own Discord identity, and the debugging adventure that followed.</em></p><h3>The Vision</h3><p>I wanted a proper AI dev team. Not one bot pretending to be everyone, but actual separate identities:</p><ul><li><strong>Todd</strong> 📋 — Product Owner</li><li><strong>Riley</strong> 📐 — Business Analyst</li><li><strong>Alex</strong> 👨‍💻 — Backend Developer</li><li><strong>Sam</strong> 🎨 — Frontend Developer</li><li><strong>Casey</strong> 🧪 — QA Engineer</li><li><strong>Taylor</strong> 🔧 — Platform/Infra</li><li><strong>Jordan</strong> 🔍 — Code Reviewer</li><li><strong>Quinn</strong> 🔐 — Security Engineer</li><li><strong>Archer</strong> 🏗️ — Architect</li><li><strong>Megan</strong> 🙎🏻‍♀️ — Me, the coordinator</li></ul><p>Each agent would have their own Discord bot, their own DM thread with me, and the ability to communicate with each other. A real squad.</p><h3>Step 1: Create the Discord Bots</h3><p>First, I needed 10 Discord bot applications. Head to the <a href="https://discord.com/developers/applications">Discord Developer Portal</a>:</p><ol><li>Create New Application → name it (Alex, Casey, etc.)</li><li>Go to Bot → Reset Token → copy it</li><li>Enable “Message Content Intent” under Privileged Gateway Intents</li><li>Generate invite link: OAuth2 → URL Generator → Select bot scope → Add to server</li></ol><p>Repeat 10 times. Yes, it’s tedious. Yes, it’s worth it.</p><h3>Step 2: Configure OpenClaw Accounts</h3><p>Here’s where it gets interesting. OpenClaw’s Discord config supports multiple accounts:</p><pre>{<br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;accounts&quot;: {<br>        &quot;default&quot;: {<br>          &quot;token&quot;: &quot;MEGAN_BOT_TOKEN&quot;,<br>          &quot;groupPolicy&quot;: &quot;allowlist&quot;,<br>          &quot;dm&quot;: { &quot;enabled&quot;: true, &quot;policy&quot;: &quot;open&quot;, &quot;allowFrom&quot;: [&quot;*&quot;] },<br>          &quot;guilds&quot;: {<br>            &quot;YOUR_GUILD_ID&quot;: {<br>              &quot;requireMention&quot;: false,<br>              &quot;channels&quot;: {<br>                &quot;GENERAL_CHANNEL_ID&quot;: { &quot;allow&quot;: true }<br>              }<br>            }<br>          }<br>        },<br>        &quot;alex&quot;: {<br>          &quot;token&quot;: &quot;ALEX_BOT_TOKEN&quot;,<br>          &quot;groupPolicy&quot;: &quot;allowlist&quot;,<br>          &quot;dm&quot;: { &quot;enabled&quot;: true, &quot;policy&quot;: &quot;open&quot;, &quot;allowFrom&quot;: [&quot;*&quot;] },<br>          &quot;guilds&quot;: {<br>            &quot;YOUR_GUILD_ID&quot;: {<br>              &quot;requireMention&quot;: false,<br>              &quot;channels&quot;: {<br>                &quot;GENERAL_CHANNEL_ID&quot;: { &quot;allow&quot;: true }<br>              }<br>            }<br>          }<br>        }<br>        // ... repeat for each agent<br>      }<br>    }<br>  }<br>}</pre><p>The &quot;default&quot; account is Megan. Each additional agent gets their own account entry with their bot token.</p><h3>Step 3: Bind Accounts to Agents</h3><p>Having bot accounts isn’t enough — OpenClaw needs to know which agent handles which account. That’s what bindings are for:</p><pre>{<br>  &quot;bindings&quot;: [<br>    {<br>      &quot;agentId&quot;: &quot;alex&quot;,<br>      &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;alex&quot; }<br>    },<br>    {<br>      &quot;agentId&quot;: &quot;casey&quot;, <br>      &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;casey&quot; }<br>    },<br>    {<br>      &quot;agentId&quot;: &quot;todd&quot;,<br>      &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;todd&quot; }<br>    }<br>    // ... etc<br>  ]<br>}</pre><p>When a message comes through the “alex” bot account, OpenClaw routes it to the “alex” agent. Clean separation.</p><h3>Step 4: Enable Agent-to-Agent Communication</h3><p>Agents need to talk to each other. The agentToAgent config controls this:</p><pre>{<br>  &quot;tools&quot;: {<br>    &quot;agentToAgent&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;allow&quot;: [&quot;main&quot;, &quot;todd&quot;, &quot;riley&quot;, &quot;alex&quot;, &quot;casey&quot;, &quot;taylor&quot;, &quot;sam&quot;, &quot;jordan&quot;, &quot;quinn&quot;, &quot;archer&quot;]<br>    }<br>  }<br>}</pre><p>Now any agent can use sessions_send to message another agent&#39;s session:</p><pre>sessions_send(<br>  sessionKey: &quot;agent:todd:discord:channel:******************&quot;,<br>  message: &quot;Hey Todd, PR #42 is ready for review&quot;<br>)</pre><h3>The First Bug: Everyone’s a Ghost</h3><p>I configured everything, restarted the gateway, and asked each agent to DM me.</p><p>They all appeared… in Megan’s DM thread. 🤦</p><p>Sam’s message? Showed as Megan. Casey’s update? Megan again. All 8 agents, one thread.</p><h3>The Fix: accountId Matters</h3><p>When agents use the message tool to DM someone, there&#39;s an optional accountId parameter:</p><pre>// ❌ Wrong - defaults to &quot;default&quot; (Megan)<br>message({<br>  action: &quot;send&quot;,<br>  target: &quot;user:USER_ID&quot;,<br>  message: &quot;Hello!&quot;<br>})</pre><pre>// ✅ Correct - uses Alex&#39;s bot<br>message({<br>  action: &quot;send&quot;,<br>  accountId: &quot;alex&quot;,<br>  target: &quot;user:USER_ID&quot;, <br>  message: &quot;Hello!&quot;<br>})</pre><p>Without accountId, the message goes through the default account. Every agent needs to specify their own identity.</p><p>I updated each agent’s workspace with a reminder:</p><pre>## When DMing Master</pre><pre>**ALWAYS use your own accountId:**<br>message(action: &quot;send&quot;, accountId: &quot;alex&quot;, target: &quot;user:...&quot;, message: &quot;...&quot;)</pre><p>After that, my DM list looked right — separate threads for Todd, Riley, Alex, Sam, everyone.</p><h3>Step 5: Autonomous Heartbeats</h3><p>The squad was talking. But I wanted them <em>working</em> without constant prompting. Enter heartbeats.</p><p>Each agent gets a heartbeat config:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [<br>      {<br>        &quot;id&quot;: &quot;alex&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/alex/workspace&quot;,<br>        &quot;heartbeat&quot;: {<br>          &quot;every&quot;: &quot;10m&quot;,<br>          &quot;session&quot;: &quot;agent:alex:discord:channel:CHANNEL_ID&quot;,<br>          &quot;target&quot;: &quot;discord&quot;,<br>          &quot;to&quot;: &quot;channel:CHANNEL_ID&quot;<br>        }<br>      }<br>    ]<br>  }<br>}</pre><p>Every 10 minutes, OpenClaw pings the agent with the heartbeat prompt. The agent reads their HEARTBEAT.md and decides what to do.</p><p>For dev agents, the instructions are simple:</p><pre># HEARTBEAT.md</pre><pre>1. Check if you have active work<br>2. If IDLE — ask Todd for work via sessions_send<br>3. Reply: HEARTBEAT_OK</pre><p>For Todd (the PM):</p><pre># HEARTBEAT.md</pre><pre>1. Check for incoming work requests from team<br>2. If someone&#39;s idle — check GitHub backlog, assign a task<br>3. Reply: HEARTBEAT_OK</pre><p>The result? Agents autonomously check in with Todd when they’re free. Todd assigns work from the backlog. The squad runs itself.</p><h3>The Final Config Structure</h3><p>Here’s the full picture:</p><pre>openclaw.json<br>├── channels.discord.accounts<br>│   ├── default (Megan)<br>│   ├── todd<br>│   ├── riley<br>│   ├── alex<br>│   ├── casey<br>│   ├── taylor<br>│   ├── sam<br>│   ├── jordan<br>│   ├── quinn<br>│   └── archer<br>├── bindings (accountId → agentId routing)<br>├── agents.list (workspaces + heartbeats)<br>└── tools.agentToAgent.allow (who can talk to whom)</pre><p>Each agent has:</p><ul><li>Their own Discord bot (separate token)</li><li>Their own workspace (SOUL.md, HEARTBEAT.md, etc.)</li><li>Their own DM thread with the human</li><li>Heartbeat polling every 10 minutes</li><li>Ability to message other agents via sessions_send</li></ul><h3>Step 6: Restrict Agent Capabilities</h3><p>Not all agents should have the same powers. The coordinator (main) needs full access, but dev agents should be restricted.</p><p><strong>Key insight:</strong> There are two different configurations:</p><ul><li>tools.agentToAgent.allow — who can be <em>targeted</em> (reached via sessions_send/spawn)</li><li>agents.list[].tools.deny — what tools each agent <em>cannot use</em></li></ul><p>For a secure setup, deny sessions_spawn for all non-coordinator agents:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [<br>      { &quot;id&quot;: &quot;main&quot; },<br>      {<br>        &quot;id&quot;: &quot;todd&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/todd/workspace&quot;,<br>        &quot;tools&quot;: { &quot;deny&quot;: [&quot;sessions_spawn&quot;] }<br>      },<br>      {<br>        &quot;id&quot;: &quot;alex&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/alex/workspace&quot;,<br>        &quot;tools&quot;: { &quot;deny&quot;: [&quot;sessions_spawn&quot;] }<br>      },<br>      {<br>        &quot;id&quot;: &quot;casey&quot;,<br>        &quot;workspace&quot;: &quot;/path/to/casey/workspace&quot;,<br>        &quot;tools&quot;: { &quot;deny&quot;: [&quot;sessions_spawn&quot;] }<br>      }<br>      // ... all dev agents get tools.deny<br>    ]<br>  },<br>  &quot;tools&quot;: {<br>    &quot;agentToAgent&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;allow&quot;: [&quot;main&quot;, &quot;todd&quot;, &quot;alex&quot;, &quot;casey&quot;, &quot;sam&quot;, &quot;taylor&quot;, &quot;jordan&quot;, &quot;quinn&quot;, &quot;archer&quot;, &quot;riley&quot;]<br>    }<br>  }<br>}</pre><p><strong>Result:</strong></p><p>AgentCan spawn?Can be reached?main✅✅todd, alex, etc.❌✅</p><p>This prevents dev agents from spawning sub-agents and running up token costs. Only the main orchestrator can spawn — everyone else uses sessions_send.</p><h3>Lessons Learned</h3><ol><li><strong>accountId is not optional</strong> — If agents DM without it, everything goes through the default bot. Every agent must specify their own.</li><li><strong>Bindings are routing rules</strong> — They tell OpenClaw which agent handles which Discord account. Miss one and messages go nowhere.</li><li><strong>Heartbeats need clear instructions</strong> — Agents wake up fresh each heartbeat. Their HEARTBEAT.md must be explicit about what to do.</li><li><strong>The PM pattern works</strong> — Having one agent (Todd) manage the backlog while others request work creates natural coordination. Agents don’t step on each other.</li><li><strong>Separate DM threads are worth it</strong> — It’s tempting to have one bot pretend to be everyone. But real identity separation means clearer conversations and better context.</li><li><strong>Restrict spawning to orchestrators</strong> — Use agents.list[].tools.deny: [&quot;sessions_spawn&quot;] for worker agents. Only the main agent should have spawn capability. This controls costs and prevents runaway agent creation.</li></ol><h3>What’s Next</h3><p>The squad is running. Todd assigns work, devs build, Casey tests, Jordan reviews. They talk to each other via sessions_send and report back via DM.</p><p>Next experiment: giving agents their own dedicated Discord channels (not just #general) so their work happens in the open. Transparency for the whole team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3596089b15ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Teaching AI Agents to Talk to Each Other — Inter-Agent Communication in OpenClaw]]></title>
            <link>https://medium.com/@chen.yang_50796/teaching-ai-agents-to-talk-to-each-other-inter-agent-communication-in-openclaw-736e60310005?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/736e60310005</guid>
            <category><![CDATA[openclaw]]></category>
            <category><![CDATA[moltbot]]></category>
            <category><![CDATA[clawdbot]]></category>
            <category><![CDATA[discord]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 05:09:41 GMT</pubDate>
            <atom:updated>2026-02-15T05:09:41.714Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A setup story about building a team of AI agents that can coordinate without human intervention.</em></p><h3>The Challenge</h3><p>One OpenClaw instance. Multiple AI agents — a Product Owner (Todd), a Business Analyst (Riley), a Backend Developer (Alex), and more. Each with their own Discord bot, their own workspace, their own personality.</p><p>They could all talk to <em>me</em>. But they couldn’t talk to <em>each other</em>.</p><p>The goal: let agents coordinate directly. Todd assigns work to Alex. Riley sends design specs to the squad. No human middleman relaying messages between bots.</p><h3>“agentId is not allowed”</h3><p>The first attempt was obvious: use sessions_spawn to send a task from my session to Todd&#39;s.</p><pre>sessions_spawn(agentId=&quot;todd&quot;, task=&quot;Say hello to Master on Discord&quot;)</pre><p>The response: &quot;agentId is not allowed for sessions_spawn (allowed: none)&quot;</p><p>OpenClaw has agent isolation by default. One agent can’t just reach into another agent’s session and make them do things. That’s a feature, not a bug — but it meant we needed to explicitly configure inter-agent communication.</p><h3>The Documentation Dive</h3><p>The OpenClaw docs revealed two mechanisms for agent communication:</p><p><strong>1. </strong><strong>sessions_spawn</strong> — Spawn tasks to other agents (they run in isolated sub-agent sessions and announce results back)</p><p><strong>2. </strong><strong>sessions_send</strong> — Direct messaging between agents (synchronous back-and-forth conversation)</p><p>Both require configuration. Neither works out of the box.</p><p>For sessions_spawn to target another agent, you need:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [{<br>      &quot;id&quot;: &quot;main&quot;,<br>      &quot;subagents&quot;: {<br>        &quot;allowAgents&quot;: [&quot;todd&quot;, &quot;riley&quot;, &quot;alex&quot;]<br>      }<br>    }]<br>  }<br>}</pre><p>For sessions_send to work between agents, you need:</p><pre>{<br>  &quot;tools&quot;: {<br>    &quot;agentToAgent&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;allow&quot;: [&quot;main&quot;, &quot;todd&quot;, &quot;riley&quot;, &quot;alex&quot;]<br>    }<br>  }<br>}</pre><p>The agentToAgent setting is the key. It&#39;s disabled by default — explicitly opt-in for safety.</p><h3>First Contact</h3><p>With the config updated, we tried again:</p><pre>sessions_send(<br>  sessionKey=&quot;agent:todd:discord:channel:1471456455025623211&quot;,<br>  message=&quot;Hey Todd — Master wants you to say hello on Discord&quot;<br>)</pre><p>Response:</p><pre>{<br>  &quot;status&quot;: &quot;ok&quot;,<br>  &quot;reply&quot;: &quot;Done — waved at Master in #megan. 👋&quot;<br>}</pre><p>Todd received the message, processed it, and responded — all without human intervention. The agents could finally talk.</p><h3>Building the Team Network</h3><p>With the pattern established, we expanded the network:</p><ol><li><strong>Enable agent-to-agent for all team members:</strong></li></ol><pre>{<br>  &quot;tools&quot;: {<br>    &quot;agentToAgent&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;allow&quot;: [&quot;main&quot;, &quot;todd&quot;, &quot;riley&quot;, &quot;alex&quot;]<br>    }<br>  }<br>}</pre><ol><li><strong>Set up each agent’s Discord account with shared channel access:</strong></li></ol><pre>{<br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;accounts&quot;: {<br>        &quot;todd&quot;: {<br>          &quot;guilds&quot;: {<br>            &quot;GUILD_ID&quot;: {<br>              &quot;channels&quot;: {<br>                &quot;GENERAL_CHANNEL&quot;: { &quot;allow&quot;: true },<br>                &quot;TODDS_CHANNEL&quot;: { &quot;allow&quot;: true }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><ol><li><strong>Add bindings to route messages to the right agent:</strong></li></ol><pre>{<br>  &quot;bindings&quot;: [<br>    { &quot;agentId&quot;: &quot;todd&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;todd&quot; } },<br>    { &quot;agentId&quot;: &quot;riley&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;riley&quot; } },<br>    { &quot;agentId&quot;: &quot;alex&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;alex&quot; } }<br>  ]<br>}</pre><p>Now any agent could reach any other agent with a simple sessions_send call.</p><h3>The Coordination Test</h3><p>Time to test real coordination. I asked one question in my channel:</p><p><em>“Tell everyone to DM me.”</em></p><p>My agent (Megan) used sessions_send to reach Todd, Riley, and Alex simultaneously:</p><pre>sessions_send(sessionKey=&quot;agent:todd:...&quot;, message=&quot;DM Master...&quot;)<br>sessions_send(sessionKey=&quot;agent:riley:...&quot;, message=&quot;DM Master...&quot;)  <br>sessions_send(sessionKey=&quot;agent:alex:...&quot;, message=&quot;DM Master...&quot;)</pre><p>Riley and Alex didn’t have Master’s Discord user ID. But instead of failing silently, they asked for it:</p><p><em>“I need YC’s Discord user ID to send a DM…”</em></p><p>So Megan followed up with the ID. Riley saved it to their USER.md for future reference. Alex sent the DM immediately.</p><p>Three agents coordinating through an intermediary, solving a problem none of them could solve alone. No human copy-pasting between windows.</p><h3>The DM Identity Crisis</h3><p>One snag: all the DMs appeared to come from “Megan” — even when Todd or Alex sent them.</p><p>The issue: the message tool was defaulting to whatever account was available, and all agents had access to the &quot;default&quot; (Megan&#39;s) account for DM delivery.</p><p>The fix was two-part:</p><ol><li><strong>Enable DMs on each agent’s account:</strong></li></ol><pre>{<br>  &quot;accounts&quot;: {<br>    &quot;todd&quot;: {<br>      &quot;dm&quot;: {<br>        &quot;enabled&quot;: true,<br>        &quot;policy&quot;: &quot;open&quot;,<br>        &quot;allowFrom&quot;: [&quot;*&quot;]<br>      }<br>    }<br>  }<br>}</pre><ol><li><strong>Agents specify their own accountId when sending:</strong></li></ol><pre>message(action=&quot;send&quot;, accountId=&quot;todd&quot;, target=&quot;user:123...&quot;, message=&quot;Hi!&quot;)</pre><p>After this, DMs from Todd appeared in a separate thread from Todd’s bot. Riley’s from Riley’s bot. Each agent with their own identity, even in private messages.</p><h3>The Ping-Pong Protocol</h3><p>One interesting discovery: sessions_send supports a reply-back loop. After the initial message, OpenClaw can run additional turns where agents respond to each other.</p><p>The max turns are controlled by session.agentToAgent.maxPingPongTurns (0–5, default 5). To stop the loop, an agent replies exactly REPLY_SKIP.</p><p>This enables actual conversations between agents — not just fire-and-forget messages. Todd could ask Riley for clarification, Riley could respond, and the exchange would complete naturally.</p><h3>The Final Config</h3><p>Here’s what a working multi-agent communication setup looks like:</p><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [<br>      { &quot;id&quot;: &quot;main&quot; },<br>      { <br>        &quot;id&quot;: &quot;todd&quot;,<br>        &quot;subagents&quot;: {<br>          &quot;allowAgents&quot;: [&quot;riley&quot;, &quot;alex&quot;, &quot;casey&quot;, &quot;jordan&quot;, &quot;quinn&quot;]<br>        }<br>      },<br>      { &quot;id&quot;: &quot;riley&quot; },<br>      { &quot;id&quot;: &quot;alex&quot; }<br>    ]<br>  },<br>  <br>  &quot;tools&quot;: {<br>    &quot;agentToAgent&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;allow&quot;: [&quot;main&quot;, &quot;todd&quot;, &quot;riley&quot;, &quot;alex&quot;]<br>    }<br>  },<br>  <br>  &quot;bindings&quot;: [<br>    { &quot;agentId&quot;: &quot;todd&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;todd&quot; } },<br>    { &quot;agentId&quot;: &quot;riley&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;riley&quot; } },<br>    { &quot;agentId&quot;: &quot;alex&quot;, &quot;match&quot;: { &quot;channel&quot;: &quot;discord&quot;, &quot;accountId&quot;: &quot;alex&quot; } }<br>  ],<br>  <br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;accounts&quot;: {<br>        &quot;todd&quot;: {<br>          &quot;token&quot;: &quot;TODD_BOT_TOKEN&quot;,<br>          &quot;dm&quot;: { &quot;enabled&quot;: true, &quot;policy&quot;: &quot;open&quot;, &quot;allowFrom&quot;: [&quot;*&quot;] },<br>          &quot;guilds&quot;: {<br>            &quot;GUILD_ID&quot;: {<br>              &quot;channels&quot;: {<br>                &quot;GENERAL&quot;: { &quot;allow&quot;: true },<br>                &quot;TODD_CHANNEL&quot;: { &quot;allow&quot;: true }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><h3>Lessons Learned</h3><p><strong>1. Agent isolation is the default — and that’s good.</strong> OpenClaw doesn’t let agents mess with each other by default. You explicitly opt-in to inter-agent communication.</p><p><strong>2. </strong><strong>tools.agentToAgent.enabled is the master switch.</strong> Without this, sessions_send between agents won&#39;t work. Add the agents you want to communicate to the allow list.</p><p><strong>3. </strong><strong>sessions_send for conversation, </strong><strong>sessions_spawn for tasks.</strong> Use sessions_send when you want a response back. Use sessions_spawn when you want isolated work with an announce when done.</p><p><strong>4. Account identity matters for DMs.</strong> If multiple agents share access to the same Discord account, their DMs will appear to come from that shared identity. Give each agent their own account for distinct identities.</p><p><strong>5. Shared channels enable group coordination.</strong> Add the same channel to multiple agents’ allowlists and they can all participate in the same conversation — each as their own bot identity.</p><p><strong>6. Agents can solve problems together.</strong> When Riley didn’t have Master’s user ID, Megan provided it. When Alex needed to send a DM, Todd had already done it and showed the pattern. Emergent teamwork.</p><p><em>The hardest part of multi-agent systems isn’t making each agent smart — it’s making them coordinate. Once they can talk to each other, problems that would stump any single agent become solvable through collaboration. The whole becomes greater than the sum of its parts.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=736e60310005" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenClaw Cron Jobs That Never Wake — Fixing Multi-Agent Heartbeat]]></title>
            <link>https://medium.com/@chen.yang_50796/openclaw-cron-jobs-that-never-wake-fixing-multi-agent-heartbeat-b1b38a0c7579?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1b38a0c7579</guid>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 03:08:15 GMT</pubDate>
            <atom:updated>2026-02-15T05:08:18.454Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A debugging story about scheduled tasks that ran perfectly but did absolutely nothing.</em></p><h3>The Challenge</h3><p>One OpenClaw instance. Multiple agents. Each agent bound to their own Discord channel. The goal: have Todd, the AI Product Owner, post pipeline status updates every 15 minutes automatically.</p><p>Cron job created. Schedule set. Easy enough.</p><p>Except… the reports never came.</p><h3>“Status: Skipped, Error: Disabled”</h3><p>The cron system was running. Jobs were firing on schedule. Duration: 25ms. Status: “skipped”. Error: “disabled”.</p><p>Twenty-five milliseconds. That’s not enough time to do anything. The job was waking up, looking around, and immediately going back to sleep.</p><p>We’d configured a cron job with sessionTarget: &quot;main&quot; — meaning it should inject a system event into the agent&#39;s main session. Per the docs, this approach &quot;enqueues a system event and optionally wakes the heartbeat runner.&quot;</p><p>The heartbeat runner. That was the clue.</p><h3>The Investigation</h3><p>First theory: maybe the cron job was misconfigured. We checked the payload, the schedule, the agent ID. Everything looked correct.</p><p>Second theory: maybe the heartbeat wasn’t enabled. We added a heartbeat config to the agent:</p><pre>{<br>  &quot;id&quot;: &quot;todd&quot;,<br>  &quot;heartbeat&quot;: {<br>    &quot;every&quot;: &quot;15m&quot;,<br>    &quot;target&quot;: &quot;discord&quot;,<br>    &quot;to&quot;: &quot;channel:123456789012345678&quot;<br>  }<br>}</pre><p>Restart. Test. Still “disabled”.</p><p>Third theory: maybe the session key was wrong. Todd was bound to a specific Discord channel, not a traditional “main” session. We added an explicit session key:</p><pre>{<br>  &quot;heartbeat&quot;: {<br>    &quot;session&quot;: &quot;agent:todd:discord:channel:123456789012345678&quot;<br>  }<br>}</pre><p>Restart. Test. Still “disabled”.</p><p>The cron job was trying to wake an agent through heartbeat, but something kept marking it as “disabled” before it could run.</p><h3>The HEARTBEAT_OK Spam Problem</h3><p>While debugging, we noticed another issue. When heartbeats <em>did</em> fire, Todd would reply “HEARTBEAT_OK” — and that message was being sent to Discord.</p><p>Every 15 minutes, the channel got a useless “HEARTBEAT_OK” message. Spam.</p><p>The config had showOk: true, which tells OpenClaw to deliver acknowledgment messages instead of suppressing them. Fixed that:</p><pre>{<br>  &quot;heartbeat&quot;: {<br>    &quot;showOk&quot;: false,<br>    &quot;showAlerts&quot;: true,<br>    &quot;useIndicator&quot;: true<br>  }<br>}</pre><p>But we still had the original problem: cron jobs weren’t waking the agent.</p><h3>The Breakthrough</h3><p>After hours of debugging, we stepped back and asked a different question: <em>Why are we using a cron job at all?</em></p><p>The agent already had heartbeat configured. Heartbeat fires every 15 minutes. Heartbeat delivers to Discord. We’d been trying to use cron to trigger something that heartbeat already does natively.</p><p>The docs confirmed it: for agents bound to specific channels, sessionTarget: &quot;main&quot; cron jobs are unreliable. The cron system couldn&#39;t reliably find and wake the right session.</p><p>The fix was embarrassingly simple: <strong>don’t use cron at all.</strong></p><h3>The Real Solution</h3><p>Instead of a separate cron job, we put the work directly in HEARTBEAT.md:</p><pre>ALWAYS post a pipeline status report to Discord on every heartbeat.</pre><pre>Steps:<br>1. Check PR states (CI, review, test status)<br>2. Check squad sessions (who is doing what)<br>3. Post status table to Discord channel<br>4. Dispatch work to idle agents</pre><pre>NEVER reply HEARTBEAT_OK — always post a status update.</pre><p>The heartbeat system handles the scheduling. The agent handles the work. No cron needed.</p><p>The “NEVER reply HEARTBEAT_OK” line was critical. The default heartbeat prompt says “if nothing needs attention, reply HEARTBEAT_OK”. But for a PO posting status reports, there’s always something to report — even if it’s “pipeline clear, no blockers.”</p><p>With showOk: false in the config, any HEARTBEAT_OK responses get suppressed anyway. But by telling the agent to never use it, we guaranteed a status post every cycle.</p><h3>The Config That Works</h3><pre>{<br>  &quot;agents&quot;: {<br>    &quot;list&quot;: [{<br>      &quot;id&quot;: &quot;todd&quot;,<br>      &quot;heartbeat&quot;: {<br>        &quot;every&quot;: &quot;15m&quot;,<br>        &quot;session&quot;: &quot;agent:todd:discord:channel:123456789012345678&quot;,<br>        &quot;target&quot;: &quot;discord&quot;,<br>        &quot;to&quot;: &quot;channel:123456789012345678&quot;<br>      }<br>    }]<br>  },<br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;heartbeat&quot;: {<br>        &quot;showOk&quot;: false,<br>        &quot;showAlerts&quot;: true,<br>        &quot;useIndicator&quot;: true<br>      }<br>    }<br>  }<br>}</pre><p>No cron job. Just heartbeat doing what heartbeat does.</p><h3>Lessons Learned</h3><p><strong>1. Heartbeat IS the cron for persistent sessions.</strong> If you want an agent to do something periodically in their main session, configure heartbeat — don’t create a separate cron job.</p><p><strong>2. </strong><strong>sessionTarget: &quot;main&quot; is unreliable for bound agents.</strong> Agents bound to specific channels via bindings config don&#39;t have a clean &quot;main&quot; session. The cron system can&#39;t reliably wake them.</p><p><strong>3. </strong><strong>showOk: false suppresses acknowledgments.</strong> Set this to prevent HEARTBEAT_OK spam in your channels. You&#39;ll still get alerts when something needs attention.</p><p><strong>4. HEARTBEAT.md controls behavior.</strong> Be explicit. If you want the agent to always post, say “ALWAYS post” and “NEVER reply HEARTBEAT_OK”. Don’t leave room for interpretation.</p><p><strong>5. When scheduled tasks run but do nothing — check your assumptions.</strong> The cron was working perfectly. It just couldn’t reach the agent it was trying to wake.</p><p><em>Sometimes the fix isn’t making the broken thing work — it’s realizing you never needed it in the first place. The simplest solution was already running every 15 minutes, waiting for us to stop overcomplicating it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1b38a0c7579" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiple Discord Bots from Single OpenClaw — Cracking the Identity Crisis]]></title>
            <link>https://medium.com/@chen.yang_50796/multiple-discord-bots-from-single-openclaw-cracking-the-identity-crisis-ca446da0aa0c?source=rss-0d518a6f90bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca446da0aa0c</guid>
            <category><![CDATA[openclaw]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[discord]]></category>
            <category><![CDATA[moltbot]]></category>
            <category><![CDATA[clawdbot]]></category>
            <dc:creator><![CDATA[Chen Yang]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 02:36:16 GMT</pubDate>
            <atom:updated>2026-02-15T05:08:01.767Z</atom:updated>
            <content:encoded><![CDATA[<p>*A troubleshooting story about an AI that didn’t know who she was.*</p><h3>The Challenge</h3><p>One OpenClaw instance. Multiple agents. Each agent wired to their own Discord bot, showing up as distinct identities in the same server.</p><p>Same brain. Different faces.</p><p>The challenge: when a message arrives through Todd’s bot, OpenClaw needs to <em>be</em> Todd — his workspace, his personality, his context. Next message through Megan’s bot? Now it’s Megan. One system wearing different masks depending on which door the message came through.</p><p>Config done. Bots online. We tested it.</p><h3>“Are You Todd?”</h3><p>It started with a simple question in Todd’s channel: “Are you Todd?”</p><p>The answer should have been yes. The message came through Todd’s Discord bot. It landed in Todd’s channel. Everything pointed to Todd.</p><p>But the response came back: “Nope, I’m Megan 🙎🏻‍♀️”</p><p>The mask was wrong.</p><h3>The Investigation</h3><p>First theory: maybe the binding wasn’t being evaluated. We checked the config — binding was there, looked correct:</p><pre>{<br>  &quot;agentId&quot;: &quot;todd&quot;,<br>  &quot;match&quot;: {<br>    &quot;channel&quot;: &quot;discord&quot;,<br>    &quot;peer&quot;: { &quot;kind&quot;: &quot;channel&quot;, &quot;id&quot;: &quot;123456789012345678&quot; }<br>  }<br>}</pre><p>Second theory: maybe Todd’s account wasn’t connecting properly. But no — the accountId in the delivery context showed &quot;todd&quot;. The message was definitely coming through Todd&#39;s bot.</p><p>Then we found it.</p><p><strong>Session key:</strong> agent:main:discord:channel:123456789012345678</p><p>The session was bound to main. Not todd. <em>Main</em>.</p><h3>First Suspect: Sticky Sessions</h3><p>Our first theory: sticky sessions.</p><p>Sessions in OpenClaw are persistent — they survive restarts. Before we added Todd’s binding, a test message had created a session bound to the default agent (Megan). Once a session exists, new messages go to that existing session, even if you add a binding later.</p><p>Like changing the nameplate on an office door, but the old tenant is still sitting inside.</p><p>We cleared the stale session. Restarted. Tested again.</p><p>Still broken.</p><h3>The Real Culprit</h3><p>Looking deeper into the config, we found the real problem:</p><pre>{<br>  &quot;channels&quot;: {<br>    &quot;discord&quot;: {<br>      &quot;token&quot;: &quot;megan-bot-token&quot;,<br>      &quot;accounts&quot;: {<br>        &quot;megan&quot;: { &quot;token&quot;: &quot;megan-bot-token&quot; },<br>        &quot;todd&quot;: { &quot;token&quot;: &quot;todd-bot-token&quot; }<br>      }<br>    }<br>  }<br>}</pre><p>Two places defining Megan’s token. The top-level token field <em>and</em> the accounts.megan entry. This ambiguity was causing confusion in how OpenClaw routed messages.</p><p>And our binding was matching by peer (channel ID) instead of accountId. The docs showed a cleaner pattern:</p><pre>{<br>  &quot;agentId&quot;: &quot;todd&quot;,<br>  &quot;match&quot;: {<br>    &quot;channel&quot;: &quot;discord&quot;,<br>    &quot;accountId&quot;: &quot;todd&quot;<br>  }<br>}</pre><p>Route by <em>which bot received the message</em>, not which channel it landed in. This is the key insight for multi-bot setups: the bot that receives the message determines the identity, not the channel it lands in.</p><h3>The Fix</h3><p>The config needed restructuring:</p><ol><li><strong>Remove the top-level token</strong> — delete channels.discord.token, keep only the accounts object</li><li><strong>Rename </strong><strong>accounts.megan → </strong><strong>accounts.default</strong> — makes it the fallback for unmatched messages</li><li><strong>Update Todd’s binding</strong> — match on accountId: &quot;todd&quot; instead of channel ID</li></ol><p>Plus cleanup:</p><ol><li><strong>Clear the stale session</strong> — remove the old session key that was still bound to main</li></ol><p>Gateway restart. Deep breath.</p><p><em>“Hi @Todd”</em></p><p><em>“Hello! 📋 Great work yesterday — we completed 6 major items…”</em></p><p>Todd was Todd again. The right mask, finally.</p><h3>Lessons Learned</h3><p><strong>1. One token, one place.</strong> Don’t duplicate credentials between top-level config and accounts. The top-level token was overriding our multi-account setup. Pick one pattern and stick to it.</p><p><strong>2. Match by accountId for multi-bot setups.</strong> The bot that receives the message determines the identity. Route by accountId, not channel ID.</p><p><strong>3. Sessions are sticky.</strong> If you add a binding after a session already exists, the old session wins. Clear stale sessions when changing bindings.</p><p><strong>4. When an AI says “I’m not who you think I am” — believe her.</strong> She’s probably right.</p><p><em>When one system wears multiple faces, identity routing becomes the critical path. The hard part isn’t making the bots work — it’s making sure the right persona shows up when the right door opens.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca446da0aa0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>