<?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: Shourya Agrawal</title>
    <description>The latest articles on DEV Community by Shourya Agrawal (@shourya_agrawal_8bfa96e72).</description>
    <link>https://dev.to/shourya_agrawal_8bfa96e72</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4232609%2F22104fca-6623-4b15-9199-3d7df9bc0879.png</url>
      <title>DEV Community: Shourya Agrawal</title>
      <link>https://dev.to/shourya_agrawal_8bfa96e72</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shourya_agrawal_8bfa96e72"/>
    <language>en</language>
    <item>
      <title>We Reverse-Engineered Switch's Protocol to Build an AI Bug-Fixing Pipeline. Here's How It Went.</title>
      <dc:creator>Shourya Agrawal</dc:creator>
      <pubDate>Sat, 07 Nov 2026 18:11:22 +0000</pubDate>
      <link>https://dev.to/shourya_agrawal_8bfa96e72/we-reverse-engineered-switchs-protocol-to-build-an-ai-bug-fixing-pipeline-heres-how-it-went-2n6g</link>
      <guid>https://dev.to/shourya_agrawal_8bfa96e72/we-reverse-engineered-switchs-protocol-to-build-an-ai-bug-fixing-pipeline-heres-how-it-went-2n6g</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; We built PRAGMATA, a multi-agent bug investigation and fixing pipeline. It takes a bug report, investigates it, reproduces it, debates possible fixes, and eventually ships a patch. Developers stay in control through two approval gates.&lt;/p&gt;

&lt;p&gt;The interesting part? We wanted Switch Console to be where all of this actually happens. Not just somewhere agents dump notifications.&lt;/p&gt;

&lt;p&gt;There was one problem. Switch has no public API documentation.&lt;/p&gt;

&lt;p&gt;So we reverse-engineered the protocol.&lt;/p&gt;




&lt;h2&gt;
  
  
  What We Were Trying to Fix
&lt;/h2&gt;

&lt;p&gt;The usual bug-fixing workflow is pretty painful.&lt;/p&gt;

&lt;p&gt;Someone reports a bug. The report is missing half the context. A developer tries to reproduce it, can't, asks for more information. A few Slack threads later, someone figures out what's wrong.&lt;/p&gt;

&lt;p&gt;Then comes the fix, the review, and the inevitable possibility that the same bug shows up again two sprints later.&lt;/p&gt;

&lt;p&gt;We wanted to automate as much of this as possible.&lt;/p&gt;

&lt;p&gt;That's how PRAGMATA came about.&lt;/p&gt;

&lt;p&gt;It's a 9-phase pipeline that takes an unstructured bug report and works through the entire process:&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;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0. Intake&lt;/td&gt;
&lt;td&gt;Parses the report and extracts metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1. Investigation&lt;/td&gt;
&lt;td&gt;Analyzes the codebase and finds the likely fault&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Reproduction&lt;/td&gt;
&lt;td&gt;Runs the scenario inside an isolated Docker sandbox&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Human Gate 1&lt;/td&gt;
&lt;td&gt;Developer reviews the evidence and approves the bug&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Analysis&lt;/td&gt;
&lt;td&gt;Traces the root cause with code citations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Strategy Debate&lt;/td&gt;
&lt;td&gt;Multiple agents debate competing fixes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Human Gate 2&lt;/td&gt;
&lt;td&gt;Developer picks the approach&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7. Implementation&lt;/td&gt;
&lt;td&gt;Agent writes the patch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8. Verification&lt;/td&gt;
&lt;td&gt;Runs regression tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9. Resolution&lt;/td&gt;
&lt;td&gt;Marks the issue resolved with an audit trail&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One important thing: &lt;strong&gt;we don't let agents blindly modify code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A developer must first approve the bug. Then they choose the fix strategy. Only after that does the implementation agent get to work.&lt;/p&gt;

&lt;p&gt;Everything else is autonomous.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why We Wanted Switch to Be the Actual Interface
&lt;/h2&gt;

&lt;p&gt;Most agent integrations I've seen work like this:&lt;/p&gt;

&lt;p&gt;Agent does something -&amp;gt; sends a Slack message -&amp;gt; human clicks a link -&amp;gt; goes somewhere else to review it.&lt;/p&gt;

&lt;p&gt;We didn't want that.&lt;/p&gt;

&lt;p&gt;Think about it. If an agent tells you it found a bug in &lt;code&gt;cart.js&lt;/code&gt;, line 30, that's not much to go on.&lt;/p&gt;

&lt;p&gt;But what if it shows you the stack trace, actual sandbox output, relevant code, and the failing test?&lt;/p&gt;

&lt;p&gt;Now you have something to make a decision with.&lt;/p&gt;

&lt;p&gt;We wanted all of that to be visible inside Switch. Developers should be able to follow the investigation, review the evidence, and interact with the agents without jumping between five different tools.&lt;/p&gt;

&lt;p&gt;So Switch had to become the collaboration layer itself.&lt;/p&gt;

&lt;p&gt;Which brings us to the most interesting part of this project.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Slight Problem: Switch Has No Public API Docs
&lt;/h2&gt;

&lt;p&gt;Switch Console is a desktop application. We couldn't find public API documentation, an SDK, or even a Postman collection to get started.&lt;/p&gt;

&lt;p&gt;So we opened the Electron app's renderer DevTools and started inspecting network traffic.&lt;/p&gt;

&lt;p&gt;Basically, we watched what the desktop client was doing and mapped out the gateway protocol ourselves.&lt;/p&gt;

&lt;p&gt;Here's the handshake sequence we figured out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET  /gateway/auth/config
POST /gateway/auth/login
GET  /gateway/auth/me
GET  /gateway/tenants
POST /gateway/tenants/{id}/switch
GET  /gateway/rooms
GET  /gateway/chats/{id}/messages
GET  /gateway/chats/{id}/activity
GET  /gateway/messaging-apps
GET  /gateway/feature-flags
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each endpoint had to return the exact structure Switch expected. Otherwise, things would silently break further down the flow.&lt;/p&gt;

&lt;p&gt;Messages were particularly annoying.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;MessagePage&lt;/code&gt; response, for example, needed to look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"headSeq"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hasMore"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And every message needed the right fields: &lt;code&gt;messageId&lt;/code&gt;, &lt;code&gt;seq&lt;/code&gt;, &lt;code&gt;roomId&lt;/code&gt;, &lt;code&gt;sentAt&lt;/code&gt;, &lt;code&gt;sender&lt;/code&gt;, &lt;code&gt;source&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, &lt;code&gt;format&lt;/code&gt;, &lt;code&gt;attachments&lt;/code&gt;, and a bunch of others.&lt;/p&gt;

&lt;p&gt;Even the sender object had its own expected structure, including &lt;code&gt;clientId&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;kind&lt;/code&gt;, and &lt;code&gt;agentId&lt;/code&gt; or &lt;code&gt;userId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Get the schema wrong and the message simply wouldn't show up.&lt;/p&gt;

&lt;p&gt;We ended up building the entire gateway server in FastAPI. Around 400+ lines covering authentication, tenants, rooms, chats, agents, collaborations, and messaging apps.&lt;/p&gt;

&lt;p&gt;Eventually, pointing Switch Console at &lt;code&gt;http://localhost:8000&lt;/code&gt; was enough to get it to authenticate, navigate into our workspace, and display live agent messages.&lt;/p&gt;

&lt;p&gt;That was a pretty satisfying moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Everything Fits Together
&lt;/h2&gt;

&lt;p&gt;The architecture is actually fairly straightforward.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bug report submitted
        ↓
FastAPI workflow engine
        ↓
9-phase investigation pipeline
        ↓
Agents write messages to _STORED_ROOMS
        ↓
Switch Console polls the gateway
        ↓
Developer sees live updates and evidence
        ↓
Developer approves / responds
        ↓
Workflow continues
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One implementation detail worth mentioning: we didn't bother setting up a database or message queue for the demo.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;demo.py&lt;/code&gt; and &lt;code&gt;gateway.py&lt;/code&gt; share a Python dictionary called &lt;code&gt;_STORED_ROOMS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One module writes agent messages into it. The other serves those messages through the gateway endpoints.&lt;/p&gt;

&lt;p&gt;That's it. No Redis, no Kafka, no unnecessary infrastructure for a hackathon demo.&lt;/p&gt;

&lt;p&gt;We also added Slack Incoming Webhooks for teams that want notifications outside Switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Demo: A $100 Bug
&lt;/h2&gt;

&lt;p&gt;We needed a simple bug that people could understand immediately.&lt;/p&gt;

&lt;p&gt;So we used a coupon bug.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// SAVE20 should apply when subtotal &amp;gt;= 100&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem? An order worth exactly $100 doesn't qualify for the discount.&lt;/p&gt;

&lt;p&gt;PRAGMATA takes this report and:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finds the faulty condition in &lt;code&gt;cart.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Reproduces the issue inside a Docker sandbox.&lt;/li&gt;
&lt;li&gt;Shows the reproduction evidence in Switch.&lt;/li&gt;
&lt;li&gt;Waits for the developer to approve the bug.&lt;/li&gt;
&lt;li&gt;Runs a multi-agent debate on possible fixes.&lt;/li&gt;
&lt;li&gt;Lets the developer choose a strategy.&lt;/li&gt;
&lt;li&gt;Applies the one-line patch.&lt;/li&gt;
&lt;li&gt;Runs regression tests and verifies the fix.&lt;/li&gt;
&lt;li&gt;Marks the issue resolved.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All of this takes roughly &lt;strong&gt;32 seconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The actual fix is one character. Getting to the point where we're confident that it's the right fix is the interesting part.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Learned About Switch
&lt;/h2&gt;

&lt;p&gt;Honestly, once we figured out the protocol, the underlying model made a lot of sense.&lt;/p&gt;

&lt;p&gt;Rooms and messages are a pretty natural fit for multi-agent systems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Agents become message senders.&lt;/li&gt;
&lt;li&gt;Workflow phases become messages.&lt;/li&gt;
&lt;li&gt;Threads become sub-investigations.&lt;/li&gt;
&lt;li&gt;Human approvals become part of the conversation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We didn't have to force our agents into some custom chat interface. The collaboration model was already there.&lt;/p&gt;

&lt;p&gt;There are still a few things we'd like to see:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Public API documentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This was easily our biggest time sink. Even a basic protocol reference would have saved us 6+ hours of reverse-engineering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Webhook subscriptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Right now, agents can push messages into Switch, but reacting to messages from users requires polling.&lt;/p&gt;

&lt;p&gt;Being able to subscribe to room events would make the human approval gates much more interactive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Agent identity registration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We currently fake agent identities through &lt;code&gt;sender.name&lt;/code&gt; and &lt;code&gt;sender.kind&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A proper agent registry with persistent identities, roles, avatars, and capability descriptions would make multi-agent rooms much easier to understand.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; FastAPI, Python&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; Next.js, TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent inference:&lt;/strong&gt; Groq&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sandbox:&lt;/strong&gt; Docker&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration:&lt;/strong&gt; Switch Console, Gateway Protocol v0.31.0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notifications:&lt;/strong&gt; Slack Incoming Webhooks&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/A23droid/pragmata" rel="noopener noreferrer"&gt;https://github.com/A23droid/pragmata&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check out the &lt;code&gt;branch-2&lt;/code&gt; branch for the demo flow.&lt;/p&gt;

&lt;p&gt;Built for the &lt;strong&gt;Flip the Switch Hackathon&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The biggest takeaway for us was that getting agents to do the work is only half the problem. Getting humans to trust, understand, and interact with that work is just as important.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>programming</category>
      <category>security</category>
    </item>
  </channel>
</rss>
