<?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: Harshit Kumar</title>
    <description>The latest articles on DEV Community by Harshit Kumar (@harshitk).</description>
    <link>https://dev.to/harshitk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1377834%2Fb2193139-02a4-4f7c-b859-e561f1348e0e.jpeg</url>
      <title>DEV Community: Harshit Kumar</title>
      <link>https://dev.to/harshitk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshitk"/>
    <language>en</language>
    <item>
      <title>Memory Is Not a Vector Database: Why AI Agents Need Beliefs, Not Storage</title>
      <dc:creator>Harshit Kumar</dc:creator>
      <pubDate>Wed, 04 Feb 2026 07:25:35 +0000</pubDate>
      <link>https://dev.to/harshitk/memory-is-not-a-vector-database-why-ai-agents-need-beliefs-not-storage-2baj</link>
      <guid>https://dev.to/harshitk/memory-is-not-a-vector-database-why-ai-agents-need-beliefs-not-storage-2baj</guid>
      <description>&lt;p&gt;&lt;em&gt;Why storage is not the same as remembering&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you've built an AI agent that works with users over multiple sessions, you've probably hit this wall: the agent keeps forgetting things it should know.&lt;/p&gt;

&lt;p&gt;You store user preferences. The agent ignores them. You correct it. It makes the same mistake tomorrow. You add more context to the prompt. It works for a while, then breaks again.&lt;/p&gt;

&lt;p&gt;So you reach for the obvious solution: a vector database. Store everything, retrieve what's relevant, inject it into the prompt. Problem solved, right?&lt;/p&gt;

&lt;p&gt;Not quite.&lt;/p&gt;

&lt;p&gt;I've been building agents for a while now, and I keep seeing the same pattern. Vector retrieval gets you 70% of the way there. The last 30% is where things fall apart—and it's the part that actually matters for user experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Pattern That Keeps Breaking
&lt;/h2&gt;

&lt;p&gt;Here's a scenario I've seen repeatedly:&lt;/p&gt;

&lt;p&gt;A user tells your agent: "I prefer dark mode." You store it. Great.&lt;/p&gt;

&lt;p&gt;A week later, the user says: "Actually, I've switched to light mode—easier on my eyes during the day."&lt;/p&gt;

&lt;p&gt;What happens? Your vector store now has two contradictory statements. When the agent retrieves "user display preferences," it might get either one. Or both. It has no way to know which is current, which is outdated, or how confident it should be in either.&lt;/p&gt;

&lt;p&gt;The agent ends up flip-flopping, or worse, confidently asserting the wrong preference.&lt;/p&gt;

&lt;p&gt;This isn't a retrieval problem. It's a representation problem. We're treating memory as storage when it should be treated as belief.&lt;/p&gt;

&lt;p&gt;Here's another failure mode:&lt;/p&gt;

&lt;p&gt;A support agent learns that asking clarifying questions before proposing a fix reduces churn. You observe this pattern manually. The agent never does.&lt;/p&gt;

&lt;p&gt;You can store past conversations. You can retrieve similar ones. But nothing in a vector store turns "this approach worked" into "do this more often."&lt;/p&gt;

&lt;p&gt;That's not memory. That's logging.&lt;/p&gt;

&lt;p&gt;I call this the &lt;strong&gt;storage fallacy&lt;/strong&gt;: assuming persistence automatically produces understanding.&lt;/p&gt;




&lt;h2&gt;
  
  
  A List of Embeddings Is Not Memory
&lt;/h2&gt;

&lt;p&gt;Vector databases are excellent at one thing: finding semantically similar content. But similarity isn't the same as relevance, and retrieval isn't the same as remembering.&lt;/p&gt;

&lt;p&gt;Human memory doesn't work like a filing cabinet where you pull out documents. It's an active system that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reinforces&lt;/strong&gt; things you encounter repeatedly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgets&lt;/strong&gt; things you don't use&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Updates&lt;/strong&gt; when new information contradicts old information&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weighs&lt;/strong&gt; memories by confidence, not just similarity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you tell someone the same thing three times, they become more confident it's true. When you contradict yourself, they become less certain about both statements. When you don't mention something for months, it fades.&lt;/p&gt;

&lt;p&gt;None of this happens in a vector store. Every embedding sits there with equal weight, forever, until you manually delete it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory as Belief
&lt;/h2&gt;

&lt;p&gt;The shift that changed how I think about this: stop treating memories as facts and start treating them as beliefs.&lt;/p&gt;

&lt;p&gt;A belief has properties that a stored fact doesn't:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confidence.&lt;/strong&gt; How certain are we that this is true? A preference mentioned once in passing is different from one stated emphatically three times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reinforcement.&lt;/strong&gt; When we encounter similar information again, confidence should increase. "User likes dark mode" and "User prefers dark themes" shouldn't create two entries—they should strengthen one belief.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decay.&lt;/strong&gt; Beliefs that aren't accessed or reinforced should fade over time. Not deleted, but deprioritized. The user's preference from two years ago probably matters less than what they said last week.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contradiction handling.&lt;/strong&gt; When new information conflicts with existing beliefs, both should be affected. The old belief loses confidence. The new one starts with moderate confidence. The system acknowledges uncertainty rather than pretending it doesn't exist.&lt;/p&gt;

&lt;p&gt;Beliefs are functions of time, not static rows.&lt;/p&gt;

&lt;p&gt;Here's what this looks like in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"User prefers dark mode" → stored with confidence 0.6

User mentions dark mode again → confidence rises to 0.75

User later says "I prefer light mode" →
  - "dark mode" drops to 0.45
  - "light mode" created at 0.65
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the agent doesn't see "two facts." It sees uncertainty. It can say "I think you prefer light mode now, though you used to prefer dark" instead of confidently asserting the wrong thing.&lt;/p&gt;

&lt;p&gt;Concretely, a belief looks more like:&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;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"User prefers dark mode"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"confidence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"last_verified_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2024-01-12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"reinforcement_count"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user_statement"&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;Not a document. Not an embedding. A stateful object.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory Isn't One Thing
&lt;/h2&gt;

&lt;p&gt;The other realization: I've been lumping together very different types of memory under one label.&lt;/p&gt;

&lt;p&gt;Cognitive science has known for decades that human memory isn't monolithic. There are distinct systems serving different purposes. For agents, four types matter most:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic memory&lt;/strong&gt; is factual knowledge. "The user is a backend engineer." "They work at a fintech company." "They prefer Python for scripting." These are beliefs about the world and the user that persist across sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Episodic memory&lt;/strong&gt; is experiential. Not just what happened, but the context around it—when, where, what was the emotional tone, what was the outcome. "Last Tuesday, the user was frustrated about a deployment failure. We helped them set up monitoring. They were satisfied." This is richer than extracted facts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working memory&lt;/strong&gt; is the active scratchpad. What's the current goal? What context is relevant right now? This is session-scoped and limited in capacity—you can't hold everything active at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Procedural memory&lt;/strong&gt; is learned skills. Not facts, but patterns of successful action. "When a user says they want to cancel, offering a discount before processing usually leads to retention." This is how agents get better at their jobs over time.&lt;/p&gt;

&lt;p&gt;This isn't academic purity. Each type maps cleanly to an engineering responsibility:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Semantic&lt;/strong&gt; → long-term knowledge store&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Episodic&lt;/strong&gt; → append-only experience log&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Working&lt;/strong&gt; → active context assembler&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Procedural&lt;/strong&gt; → policy selection system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most "memory" implementations I've seen treat everything as semantic memory. They miss the temporal richness of episodes, the active focus of working memory, and the skill accumulation of procedural memory.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bigger Models Don't Fix Memory
&lt;/h2&gt;

&lt;p&gt;Larger context windows help agents remember more, but they don't help agents remember &lt;em&gt;better&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Without reinforcement, decay, and contradiction handling, bigger context just means more clutter. You can fit 100k tokens in a prompt. You still can't represent "I used to believe X but now I believe Y with moderate confidence."&lt;/p&gt;

&lt;p&gt;Many agent failures that look like reasoning problems are actually memory problems. The model reasons fine—it's just reasoning over the wrong context because retrieval gave it stale or contradictory information with no signal about which to trust.&lt;/p&gt;




&lt;h2&gt;
  
  
  What We're Building
&lt;/h2&gt;

&lt;p&gt;This is what led me to build Engram, a cognitive memory layer for AI agents.&lt;/p&gt;

&lt;p&gt;The core idea: memory should behave like memory, not like storage.&lt;/p&gt;

&lt;p&gt;Think of it as a cognitive operating layer that sits between your agent and its storage. The current focus is correctness and cognitive behavior, not feature breadth.&lt;/p&gt;

&lt;p&gt;When you store a belief, it has confidence. When you encounter it again, it reinforces. When you contradict it, both beliefs adjust. When you don't access it, it decays. When you retrieve, you get not just similarity but a weighted score that accounts for confidence, recency, and relevance.&lt;/p&gt;

&lt;p&gt;You can store episodes with full context—entities, emotional valence, outcomes and have the system extract semantic beliefs automatically. You can record what worked and what didn't, and have procedural patterns emerge that make your agent better over time.&lt;/p&gt;

&lt;p&gt;We consistently see agents stop repeating the same errors after a few dozen interactions. That's not because we tuned anything, it's because the memory system does what memory should do.&lt;/p&gt;

&lt;p&gt;It's an HTTP API. You plug it into whatever agent framework you're using. It handles the cognitive complexity so your agent code stays clean.&lt;/p&gt;




&lt;h2&gt;
  
  
  What This Isn't
&lt;/h2&gt;

&lt;p&gt;A few things Engram explicitly doesn't do, because scope matters:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not an agent framework.&lt;/strong&gt; We're not competing with LangChain or CrewAI. We're infrastructure they can use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a vector database.&lt;/strong&gt; We use vectors, but that's an implementation detail. The interface is cognitive, not geometric.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not long-term context stuffing.&lt;/strong&gt; We don't build giant prompts. We build systems that knows what matters.&lt;/p&gt;

&lt;p&gt;The goal is to be the memory layer—one thing, done well.&lt;/p&gt;




&lt;h2&gt;
  
  
  Who This Is For
&lt;/h2&gt;

&lt;p&gt;If you're building agents that interact with users over time, and you've been frustrated by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Context limits forcing you to drop important information&lt;/li&gt;
&lt;li&gt;Agents repeating the same mistakes&lt;/li&gt;
&lt;li&gt;Preferences that don't stick&lt;/li&gt;
&lt;li&gt;No sense of learning or improvement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then this might be useful.&lt;/p&gt;

&lt;p&gt;It's early. The API is stabilizing. We're looking for people who want to build with it and give feedback.&lt;/p&gt;




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

&lt;p&gt;We're publishing examples and benchmarks showing the learning dynamics in action. There's a demo that shows error rates dropping as an agent accumulates procedural memory, not because we tweaked numbers, but because the memory system is doing what memory should do.&lt;/p&gt;

&lt;p&gt;Here's the repo: &lt;a href="https://github.com/Harshitk-cp/engram" rel="noopener noreferrer"&gt;github.com/Harshitk-cp/engram&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this resonates with how you've been thinking about agent memory, I'd love to hear from you. If you think I'm wrong about something, I'd love to hear that too.&lt;/p&gt;

&lt;p&gt;Building in public means being wrong in public. That's the tradeoff for building things that actually work :)&lt;/p&gt;




</description>
      <category>ai</category>
      <category>agents</category>
      <category>opensource</category>
      <category>engram</category>
    </item>
    <item>
      <title>Integrating RTMP and WebRTC for Real-Time Streaming</title>
      <dc:creator>Harshit Kumar</dc:creator>
      <pubDate>Thu, 27 Jun 2024 22:34:55 +0000</pubDate>
      <link>https://dev.to/harshitk/integrating-rtmp-and-webrtc-for-real-time-streaming-2lbb</link>
      <guid>https://dev.to/harshitk/integrating-rtmp-and-webrtc-for-real-time-streaming-2lbb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In the rapidly evolving landscape of real-time communication and streaming, integrating different protocols to leverage their unique strengths is crucial. This project presents an RTMP server inspired by the LiveKit Ingress Service. It receives an RTMP stream from a user in a room, transcodes the audio from AAC to Opus (making it WebRTC compatible), and the video to H264, then pushes it to WebRTC tracks connected to clients. The server acts as a peer, maintaining a peer-to-peer (P2P) connection with each client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why RTMP and WebRTC?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;RTMP&lt;/strong&gt;: A Proven Protocol for Live Streaming&lt;br&gt;
Real-Time Messaging Protocol (RTMP) is a mature and robust protocol widely used for live streaming. It provides low-latency transmission of audio, video, and data over the Internet. RTMP is favored for its ability to handle high-quality streams with minimal buffering and its support for a variety of codecs and formats. This makes it an excellent choice for ingesting live video streams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebRTC&lt;/strong&gt;: Real-Time Communication in the Browser&lt;br&gt;
Web Real-Time Communication (WebRTC) is a cutting-edge technology that enables real-time audio, video, and data sharing directly between browsers without the need for plugins. WebRTC is designed for low-latency communication, making it ideal for video conferencing, live streaming, and interactive applications. Its peer-to-peer architecture ensures efficient data transmission and scalability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integrating RTMP and WebRTC&lt;/strong&gt;: The Best of Both Worlds&lt;br&gt;
By integrating RTMP for stream ingestion and WebRTC for stream delivery, we can create a powerful real-time streaming solution. RTMP handles the initial high-quality stream intake, and WebRTC ensures efficient, low-latency distribution to end-users. This combination provides a seamless streaming experience with the reliability of RTMP and the real-time capabilities of WebRTC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;br&gt;
RTMP to WebRTC: Receives RTMP streams and delivers them to WebRTC clients.&lt;br&gt;
Audio Transcoding: Transcodes AAC audio to Opus for WebRTC compatibility.&lt;br&gt;
Video Transcoding: Ensures video is encoded in H264 for WebRTC delivery.&lt;br&gt;
Webhook Notifications: Uses webhooks to notify the publishing state of the stream to different rooms.&lt;br&gt;
WebSocket Signaling: Establishes WebRTC connections using WebSockets for offer/answer exchange.&lt;br&gt;
Concurrency for Performance: Utilizes Go's concurrency patterns and channels to enhance streaming performance and reduce latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Libraries and Packages&lt;/strong&gt;&lt;br&gt;
Pion WebRTC: Used for handling WebRTC connections.&lt;br&gt;
Yuptopp RTMP: Used for handling RTMP streams.&lt;br&gt;
fdkaac: For AAC decoding.&lt;br&gt;
gopkg.in/hraban/opus.v2: For Opus encoding.&lt;br&gt;
go-chi/chi: Lightweight, idiomatic, and composable router for building Go HTTP services.&lt;br&gt;
logrus: For logging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
RTMP Server&lt;br&gt;
The RTMP server listens for incoming RTMP streams. When a stream is published:&lt;/p&gt;

&lt;p&gt;Audio Processing: Decodes AAC audio and encodes it into Opus format using fdkaac and opus.&lt;br&gt;
Video Processing: Ensures the video stream is in H264 format.&lt;br&gt;
WebRTC Integration: Sends processed audio and video to WebRTC tracks connected to clients.&lt;br&gt;
WebRTC Connection&lt;br&gt;
The WebRTC connection is established via WebSockets:&lt;/p&gt;

&lt;p&gt;WebSocket Handler: Manages WebRTC signaling (offer/answer exchange) using WebSockets.&lt;br&gt;
Peer Connection: Each client establishes a peer connection with the server.&lt;br&gt;
Track Delivery: Delivers audio and video tracks to clients via WebRTC.&lt;br&gt;
Webhooks&lt;br&gt;
Webhooks listen to the audio and video channels and notify the state of streams to their subscribers:&lt;/p&gt;

&lt;p&gt;Notifications: Sent when streams start or stop using a webhook manager.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges Faced&lt;/strong&gt;&lt;br&gt;
One of the primary challenges in this project was the lack of support for Opus audio in RTMP. RTMP and OBS (Open Broadcaster Software) share only one common audio codec: AAC. This posed a problem since WebRTC requires Opus audio for optimal performance. Here's how I tackled this issue:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Initial Approach: External Pipeline&lt;/strong&gt;&lt;br&gt;
My first solution was to use a separate GStreamer or FFmpeg pipeline to convert the AAC encoded audio. This pipeline would process the audio and pass it to an RTP channel, which would then ingest the audio packets directly into WebRTC. However, this approach increased CPU utilization by 70%, significantly impacting performance when handling multiple streams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimized Solution: In-Memory Encoding&lt;/strong&gt;&lt;br&gt;
After further research, I discovered a more efficient method. By performing in-memory encoding of the audio buffer directly to the Go channel, I could pass it to WebRTC tracks in the Opus codec. I used the gopkg.in/hraban/opus.v2 package, a Go translation layer for C libraries like libopus and libopusfile, which provide encoders and decoders.&lt;/p&gt;

&lt;p&gt;This approach allowed for in-memory translation of the audio layer from AAC to Opus, drastically reducing the performance cost compared to the initial solution. The overhead was minimal, making it almost as efficient as streaming without encoding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Performance Enhancements&lt;/strong&gt;&lt;br&gt;
Concurrency: Utilizes Go's concurrency patterns to efficiently handle multiple streams.&lt;br&gt;
Channels: Uses channels for buffering video and audio data, ensuring smooth delivery to WebRTC tracks.&lt;br&gt;
Optimized Transcoding: Efficiently transcodes audio and video to minimize latency.&lt;br&gt;
Conclusion&lt;/p&gt;

&lt;p&gt;This project demonstrates the power of combining RTMP and WebRTC to create a real-time streaming solution that is both robust and efficient. By leveraging the strengths of each protocol, we can deliver high-quality, low-latency streams to users seamlessly. Whether you're building a live streaming platform, a video conferencing tool, or any other real-time application, this RTMP server provides a solid foundation for your needs.&lt;/p&gt;

&lt;p&gt;Stay tuned for further updates and enhancements to this project, and feel free to contribute!.&lt;br&gt;
&lt;a href="https://github.com/Harshitk-cp/rtmp_server" rel="noopener noreferrer"&gt;Source Code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webrtc</category>
      <category>go</category>
      <category>backend</category>
      <category>rtmp</category>
    </item>
  </channel>
</rss>
