<?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 Hridayagiri on Medium]]></title>
        <description><![CDATA[Stories by Hridayagiri on Medium]]></description>
        <link>https://medium.com/@hridayagiri78?source=rss-4571299c568a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HCwxjHe2X1pdZK9T</url>
            <title>Stories by Hridayagiri on Medium</title>
            <link>https://medium.com/@hridayagiri78?source=rss-4571299c568a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:04:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hridayagiri78/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[ICE Connection Issues in WebRTC: The Role of TURN/STUN Servers]]></title>
            <link>https://medium.com/@hridayagiri78/ice-connection-issues-in-webrtc-the-role-of-turn-stun-servers-247a7c365c77?source=rss-4571299c568a------2</link>
            <guid isPermaLink="false">https://medium.com/p/247a7c365c77</guid>
            <dc:creator><![CDATA[Hridayagiri]]></dc:creator>
            <pubDate>Tue, 18 Nov 2025 10:30:04 GMT</pubDate>
            <atom:updated>2025-11-18T10:30:04.199Z</atom:updated>
            <content:encoded><![CDATA[<h3>ICE Connection Issues in WebRTC: The Role of TURN/STUN Servers.</h3><p>If you have ever tried building a real time communication app that shares media in terms of audio or video with WebRTC then you have probably been stuck to this message in the console and trying to figure out how and why?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CcSNNDZk-VyD1JYC" /><figcaption>ICE connection state issue</figcaption></figure><blockquote>ICE connection state changed to: failed</blockquote><blockquote>ICE connection state changed to: connecting</blockquote><p>Me myself was stuck and trying to figure it out how are we suppose to solve this and what really is ICE connection issue or am I in the wrong?After doing some thinking, restarting the VM thousand times and after some solid research (and a lot of frustration), found out the real enemy wasn’t my code or i hadn’t missed anything but it was the network.</p><p>It is always one of the first hurdles or problem every person working on the WebRTC will feel and run into. On the bare thinking it seems very simple, and feels like what is there to stop the connection from, just need to click join and yup we are into and you hear the audio or see video from one peer and you establish peer to peer connection there is no problem in that. But when you study a bit deeper and get into it you now understand the network behind it , the NAT’s , the firewalls and IP’s that WebRTC has to fully navigate via and where all the server stuff STUN, TURN and ICE comes into and guides and makes the connection. Its not just connected its always more than that and the problem there is always more than that.</p><h3>ICE: The Traffic Controller of WebRTC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*kwt5FXVata3n8JtvG0hpoA.png" /><figcaption>ICE: the traffic controller for WebRTC</figcaption></figure><p>So what really is ICE (<strong>Interactive Connectivity Establishment) ? </strong>so as per the name defines , in the WebRTC it is a way to establish a connection among two peers, if a peer one needs to communicate with the other peer they are connected via the this connectivity establishment. To share any info in data, audio or video , it is a traffic control system for your media streams that is shared among one peer to another.</p><p>So how does a perfect connection happens between two peers and how does the ICE plays a role here?</p><p>Firstly each peers it gather candidates for it to connect , potential ways like the local IP’s something like 192.131.222.33, public IP’s that are discovered via the STUN server and the relay address that are provided by the TURN server.</p><p>Then the ICE tries to connect each candidate with other peers via this potential ways and checks if the path works or not and the first successful connection is used for the session for the media stream sharing.</p><p>Sounds quite easy to establish the connection right? what could there possibly be an issue to connect two peer? but in the real world scenario it is quite a opposite , in the real world networks NAT types, firewalls and network restriction can block all the connectivity between two peers and that’s the reason you face this kind of connection issue , it is especially when you move from your home network to a enterprise or mobile network.</p><h3>STUN Servers: Mapping the Public Internet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*m-AqzjvtlEmfz8p-rxW7QA.png" /><figcaption>STUN server for mapping the public internet</figcaption></figure><p>Most computer and devices are always behind the NAT’s which is like a invisible wall that blocks your private IP address in the internet. for example our computers might have a private IP address which if given to someone outside your network they cannot access it , it is only for the ones in your network</p><p>In this scenario STUN server comes handy, it lets your computer figure out the public IP address and port , from which other peers in the internet can actually reach to you and share media streams with you. For simple NAT’s this connection is enough ICE can take the public IP that is provided and can establish the connection between two peer but it’s not same case for every NAT’s. STUN server working just fine in every network is quite rare, for example for symmetric NAT’s or some firewalls these don’t let the STUN servers to gives usable address for the peer to connect in the network and in this case the connection fails and the ICE cannot establish the connection between two peers that’s why you see connection is failed even when you have configured STUN server.</p><p>If this is the case than STUN servers are not enough and you need a server that can provide relay address across two peers which can be done by TURN servers.</p><h3>When STUN Servers Isn’t just Enough: TURN Servers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*OWo21qk1OV--lqRx3Nes5A.png" /><figcaption>TURN server when just STUN is not enough</figcaption></figure><p>As per my experience and generally developers when working in the real time communication app in WebRTC we generally think STUN are enough and no need for TURN servers setup but some networks are quite complicated and tricky , for example like symmetric NAT’s , corporate firewalls. These blocks direct connection among the peers and the connection cannot establish and always fails as with just the STUN servers it cannot reached to the expose address as it is still blocked.</p><p>So overcome this TURN servers comes as a life saver that plays a relay role here, instead of trying to connect directly like what the STUN servers tries to do, it creates a relay address where your data or any kind of media streams is sent through a relay server that is publicly accessible , then the server forwards the relay address to the other peer from where the data that is sent by you is received by the other peer on the other end.</p><p>But these do have some trade offs that we have to bear, the path is generally longer compare to the STUN server one and it increases the latency , it puts a heavy load to the server as it is handling all the media but it surely ensures that the connection is establish in a restricted network if properly configured so make sure to use TURN server only when you have to.</p><h3>Setting Up TURN/STUN Servers: COTURN- The Open Source Hero</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*FXp5zxPBSsSCcPzJ4JUpow.png" /><figcaption>COTURN: Host your own server</figcaption></figure><p>While working with setting up the TURN or STUN server most developer don’t immediately host their own server instead they use third party services for example <a href="https://www.twilio.com/en-us/stun-turn">Twillo</a> , where the turn server configurations are given and they are ready to use for you but there is a downside from it. The credentials that they provide are generally temporary and will expire after certain amount of time. These are useful when you want it for a short demo or say quick experiments and testing but not for production ready app.</p><p>So to encounter this issue and host own server instead there is a open source hero that is COTURN</p><p>It is a most popular open-source solution. It supports both STUN and TURN server, is lightweight, stable, and widely used in production. It is also quite easy to setup , barely need to configure some configuration file and open ports based on the inbound rules that you have set in your host.</p><h4>Configuration setup for COTURN for TURN and STUN servers</h4><p>We often assume that configuring COTURN might be a big deal and unnecessary trouble why not just get the temporary thing from third party services, but it is quite easy to setup in our virtual machine or the instance from which we are hosting our service.</p><blockquote>Install COTURN IN YOUR VM</blockquote><blockquote>ACTIVATE THE SERVICE</blockquote><blockquote>CONFIGURE THE MAIN /etc/turnserver.conf file by setting listening port, defining external IP’s , enable STUN and TURN , set username and password for authentication and define the min/max port.</blockquote><blockquote>Open ports and set inbound rules and give UDP and TCP access in your cloud provider like AWS or GCP in required ports.</blockquote><blockquote>and boom your connection gets established and the connecting thing finally sets to connected.</blockquote><h3>ICE issue: How they show up and how are we suppose to Diagnose it.</h3><p>ICE issue always shows up in different manner which makes us hard to identify what might be the cause, there are many reasons the issue might be occurring so here are few things to ask yourself when facing the issue:</p><p>Do you see the relay candidates? If not then your TURN server is unreachable right now maybe it is misconfigured , it generally happens when the peers can’t fall back to TURN server when the STUN server failed.</p><p>Are you only using the UDP TURN and you are in a corporate network? If yes than you have to expect this failure as many firewalls and NAT’s block UDP so TCP is often required.</p><p>What type of NAT is the user that is receiving the media streams behind? If the answer is symmetric NAT and you are using only STUN server than expect this failure as in this case TURN server becomes mandatory.</p><p>Using third party services for TURN and the ICE connection state stuck in connecting (neither failed nor connected)? If yes than please care to check the credentials as the configuration provided by the third party services are temporary and expires after a right amount of time.</p><p>Are the required ports open? TURN server usually needs ports to be opened and set in the inbound rules in your cloud service like AWS or GCP as blocked ports = silent ICE connection failure. NO logs NO warning which gives you more pain and consumes your more time than anything.</p><h3>CONCLUSION</h3><p>Don’t treat ICE failures as errors but treat them as <em>signals</em>.<br>They tell you how the network behaves.<br>They show when STUN is not enough.<br>They tell you <strong>when TURN must step in</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=247a7c365c77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Anatomy of a Modern AI Agent: Voice Intelligence, Memory Optimization, RAG Architecture.]]></title>
            <link>https://medium.com/@hridayagiri78/the-anatomy-of-a-modern-ai-agent-voice-intelligence-memory-optimization-rag-architecture-c69244d621bd?source=rss-4571299c568a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c69244d621bd</guid>
            <dc:creator><![CDATA[Hridayagiri]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 10:54:56 GMT</pubDate>
            <atom:updated>2025-11-17T10:56:21.834Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Modern AI agent </strong>in this world is not just a normal chatbots that can answer your query and just do your task, they are more than that. They can think , they can act and most importantly they can be as per your adjustment and requirement without any intervention of human and can act entirely like a human assistant for you. Building such type of system requires combining different types of layer of intelligence to pass on the feature of a human assistant like speech processing, long term memory and reasoning like a human do.</p><p>In this Blog I break down the internal anatomy of a modern AI agent where I engineered a system that is powerd by voice intelligence (end to end STS pipeline), memory optimization for it to have a memory like a human and a proper retrieval architecture that can say and act as per your requirement and adjustment.</p><h3>Voice Intelligence : Beyond “just Talking”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*lVMfCPMq2AifcI-dMIDcVQ.png" /><figcaption>Voice intelligence: Beyond talking but understanding</figcaption></figure><p>Voice is always the first touchpoint between the human and the AI. Voice intelligence is not just about converting the audio of a human to the text and text to the speech, it is always more than that . The term voice intelligence is not just about making the speech model<strong> “talk” </strong>it is always about creating a natural dialogue that will make someone feel like home which is only possible if the model just not talks but it understands, it interprets the context of one , detects the emotion , recognize what the intent is and responds appropriately and offers suggestions to adjust its behavior as per the users needs.</p><h4>Why fine tuning matters ?</h4><p>So how do we make an AI agent truly intelligent, as we discussed? The answer is <strong>fine-tuning</strong>. Voice intelligence is a combination of <strong>speech-to-text (STT) models, text-to-speech (TTS) models, and large language models (LLM’s)</strong>. Fine-tuning these models is what allows the AI to move beyond basic transcription or speech synthesis and actually understand the user. Though pre-trained models provide general language understanding and speech capabilities, they lack the specificity needed to interpret individual user context, detect subtle emotions, recognize intent accurately, and adjust behavior dynamically.</p><p>Through fine-tuning, we can make the AI <strong>interpret context</strong>, <strong>detect emotional states</strong>, <strong>recognize user intent</strong> and make it <strong>respond </strong>as per we want the AI to behave. It can also learn to behave in specific ways depending on the context, adjusting tone, phrasing, or suggestions dynamically. For example, it can be trained to respond empathetically in sensitive scenarios or assertively when guiding a user through a task in a way a human assistant would do it in a real world scenario.</p><h3>Memory Optimization: “more than just a storage but a true memory”</h3><p>Building a memory for a AI is far more than just a storage that stores the information it is always beyond that. It requires the system to judge the context , judge what the user wants , judge the importance which can adapt dynamically like how a human assistant can do it just not stores information for you but segregates the thing that are relevant and irrelevant and only remembers that are relevant.</p><p>Early assumption often fails, storing everything every data every bit of information is not manageable at all. As not all information matters, only the ones that are useful are mattered here so without a mechanism that can distinguish signal from noise that type of memory systems either <strong>overfit</strong> memorizing irrelevant details or <strong>underfit</strong> losing context too quickly and no relevant information left. This degrades the quality of a good memory system as we want that system to be like human that understands and keeps stuff in the memory that are relevant and starts forgetting the ones that are irrelevant and not much important for them.</p><h4>How memory works Today</h4><p>Most AI “memory” systems in production are structured around <strong>Retrieval-Augmented Generation (RAG)</strong>.</p><ol><li>Chunking: Conversation and documents are broken down into more manageable pieces (500–2000 tokens).</li><li>Embedding: The chunks are converted into a vector representation that capture the semantic meaning among other embeddings.</li><li>Storage: Embeddings that are created are than stored in a vector databases like Qdrant, Chroma and many others.</li><li>Retrieval: Incoming queries are embedded and compared to stored vectors to find semantically similar content.</li><li>Augmentation: Retrieved chunks are fed into the LLM’s to generate a contextually relevant response.</li></ol><p>And some more<strong> “better”</strong> system uses Graph based rag system instead of just storing the chunks this system creates a relationship , extracts the entities and the relationship between them and create a graph like structure which can possibly answer more complex queries and follow relationships. It’s better at entity resolution and can traverse connections.</p><p>But here’s what i have understand after working in the system that optimizes memory it is just a structured form that we have created to search better. It is basically a pool of knowledge we have created to search better but still the system cannot understand or distinguish what is more important and relevant and what are less important and irrelevant. They can’t update their understanding when facts change. They can’t connect new information to existing knowledge in genuine ways.</p><h4>Challenges in AI memory</h4><ol><li><strong>Entity recognition</strong>: One of the most frustrating experience would be recognition of entity from a normal human conversation. When someone says i met <strong>hridaya</strong> today the system finds it difficult to distinguish between which <strong>hridaya</strong> the <strong>hridaya</strong> that was mentioned 3 days ago or another <strong>hridaya</strong> that is irrelevant in this conversation. Is this new <strong>hridaya</strong> or old <strong>hridaya</strong>. While humans can distinguish this effortlessly but AI has no such intuitions to identify this correctly.</li><li><strong>Query variability</strong>: Humans can ask a similar fact queries in different manner, for example: Do I have any meetings tomorrow?,What’s my schedule at 2 PM tomorrow?,Any appointments in the afternoon?. All these question is tilt towards same facts but AI often fails to recognize this as a same fact queries and starts to hallucinate.</li><li><strong>Context window limitation</strong>: Context window is generally considered as the LLM’s “working memory” the amount of text it can actively process at once. Memory retrieval must prioritize what enters the context, balancing<strong> </strong>completeness with attention. if included too much context the model fails to answer question or loses focus on what the user wants and if included too little, and it lacks crucial information.</li><li><strong>Interpretation and world models</strong>: As a human we can interpret what a sentence mean , we can emotionally connect with it. for example a query: “who i like the most from our group of interns” this isn’t a factual query and there is no right or wrong answer for this query. To answer this human brain can effortlessly connect with past experience and emotional context to identify the best answer among other but for an AI it is hard to identify the emotional context they can retrieve the best fact from the knowledge base but a answer to the query like : show me important people of our office? they need to know what the word important mean in their context.</li></ol><h4>What we can build today</h4><p>while we cant just build a perfect human like AI agent and a memory like that is exact clone of a human assistant to you is still quite out of reach, but with proper strategies with definetly help build system that feel more intelligent and more context aware to you.</p><ol><li>Using SQL (Structured Query Language) databases for storing factual facts that must be accurate for precise factual retrieval like dates, account details, appointments.</li><li>Vector search to perform semantic similarity and allow the system to retrieve the information which is generally different but semantically same which states a same fact.</li><li>Knowledge graph to identify complex query to represent the entities and their relationship with one another like who works with whom , who works with what and similarly.</li><li>Explicitly handiling conflicting statement to prevent memory corruption and confusion with similar different fact statements and make important information for a better guided retrieval.</li><li>Human inspired memory pillars:</li></ol><ul><li>Working memory: It is generally considered as a short term memory that keeps tracks of ongoing conversation or task, for example: if we ask “Remind me what we discussed about the project yesterday,” the AI can reference the ongoing dialogue and the raw log to give an accurate answer.</li><li>Episodic memory: It is generally considered as the memory of past experience or past interaction it had with you, for example : Remembering that in a past session you preferred brief summaries over detailed explanations.</li><li>Semantic memory: It is generally considered as the knowledge base or the core information part that is the backbone. It is a consistent knowledge and context that is provided across sessions. for example: knowing Mr. Ram is working in setting up the STS pipeline and Mr. sham is currently working with Mr. Hari to setup AWS the host his system.</li><li>Procedural memory: It is generally considered as rules that allows AI to learn from experience and make it’s behavior based on that, for example: you repeatedly telling AI to be formal and talk respectfully, then it learns to respond in that manner automatically in future.</li></ul><h3>RAG (Retrieval Augmentation Generation) : Intelligence that looks things up.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*w8AbZy1YEyURvktqr0Qtug.png" /><figcaption>RAG representation to fetch the right “memory”</figcaption></figure><p>Even with a proper memory management LLM’s cannot magically know everything, every data every factual or non factual data. This is where the RAG( Retrieval Augmentation Generation) comes in, think of it as a brain with a perfect filing system which can quickly fetch the right <strong>“memory”</strong> and receive and process it like how a human would do it.</p><p>RAG gives the AI a dynamic extension of its memory, a way to instantly pull in facts, documents, past information, or external knowledge that wasn’t part of its training and doesn’t live inside its long-term memory.</p><p>It acts like an external knowledge cortex:<br> not stored permanently, not tied to emotion , but always available to fetch the right information at the right moment whenever the user requries.</p><p>Where voice intelligence allows the agent to talk like a human,<br> and memory optimization allows it to remember like a human,<br> <strong>RAG allows it to research like a human.</strong></p><p>The agent doesn’t just respond using what it knows<br> it actively retrieves, verifies, and stitches in the information it <em>should</em> know.</p><p>This is what enables the agent to:</p><ol><li>Bring updated facts</li><li>Handle multi-step or cross-document queries</li><li>Access information beyond conversations</li><li>Avoid hallucinations by grounding responses in real data</li><li>Personalize answers using retrieved context</li><li>Dynamically adapt its reasoning based on external knowledge</li></ol><h3>Conclusion</h3><p>A modern AI agent is more than just a chatbot. It is an AI agent where the voice intelligence is the <strong>“ears and mouth,” </strong>the memory as the<strong> “past experiences,”</strong> and the RAG as the <strong>“reference library” </strong>the agent consults whenever it needs clarity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c69244d621bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>