<?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 Niranjan B R on Medium]]></title>
        <description><![CDATA[Stories by Niranjan B R on Medium]]></description>
        <link>https://medium.com/@brniranjanhegde?source=rss-739d2a59a80a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*r-rdS83kHguC6GipqOFAZg.png</url>
            <title>Stories by Niranjan B R on Medium</title>
            <link>https://medium.com/@brniranjanhegde?source=rss-739d2a59a80a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:27:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brniranjanhegde/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[What if AI could turn an emotion into a song that someone, somewhere, needs to hear? ]]></title>
            <link>https://medium.com/@brniranjanhegde/what-if-ai-could-turn-an-emotion-into-a-song-that-someone-somewhere-needs-to-hear-e9088867d502?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9088867d502</guid>
            <category><![CDATA[raag]]></category>
            <category><![CDATA[ai-and-creativity]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 07:52:22 GMT</pubDate>
            <atom:updated>2026-10-15T07:52:22.338Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://suno.com/song/a33adf15-f235-485a-a276-1592989fa4c5?sh=cUdjfmViuOeDgKFA">https://suno.com/song/a33adf15-f235-485a-a276-1592989fa4c5?sh=cUdjfmViuOeDgKFA</a></p><p>I learnt Indian classical music when I was a kid and have always loved exploring raagas. This morning, I felt like combining that passion with my curiosity about AI. Since Raag Bhairavi is traditionally associated with the morning, I chose it as the foundation for this song.</p><p>For a while, I wanted to experiment with AI — not just another technical experiment, but something meaningful.</p><p>So, I made AI to write these lyrics and used it to compose them into a song.<br>The result is a song about something many people experience but rarely talk about openly: the uncertainty of being laid off, the silence after sending countless resumes, the pressure of explaining your situation, and the quiet struggle of holding on to hope.</p><p>This song is about remembering who you are when your professional identity feels uncertain.</p><p>A layoff is an event, not an identity.</p><p>A career break is a chapter, not the whole story.</p><p>And a rejection is not a measure of your worth.</p><p>To everyone navigating a difficult career transition, I hope this song reminds you that you are more than your job title, your current status, or the last email you received.</p><p>Give yourself permission to feel, to pause, to rebuild, and to begin again.<br>Because sometimes, hope doesn’t arrive as an opportunity or an answer.<br>Sometimes, it arrives as a song that reminds you to keep going. ❤️</p><p>🎧 Listen to the song. Let me know what you feel.</p><p>I’m excited by the possibilities of AI, but this experiment also reminded me that technology becomes truly interesting when we use it to express something human.</p><p><a href="https://www.linkedin.com/search/results/all/?keywords=%23raagbhairavi&amp;origin=HASH_TAG_FROM_FEED">#RaagBhairavi</a> <a href="https://www.linkedin.com/search/results/all/?keywords=%23aiandcreativity&amp;origin=HASH_TAG_FROM_FEED">#AIandCreativity</a> <a href="https://www.linkedin.com/search/results/all/?keywords=%23music&amp;origin=HASH_TAG_FROM_FEED">#Music</a> <a href="https://www.linkedin.com/search/results/all/?keywords=%23careertransition&amp;origin=HASH_TAG_FROM_FEED">#CareerTransition</a> <a href="https://www.linkedin.com/search/results/all/?keywords=%23resilience&amp;origin=HASH_TAG_FROM_FEED">#Resilience</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9088867d502" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Streaming in LangGraph: Messages, Updates, and Values Explained]]></title>
            <link>https://medium.com/@brniranjanhegde/understanding-streaming-in-langgraph-messages-updates-and-values-explained-ef1389004a44?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef1389004a44</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[langgraph]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 14:30:42 GMT</pubDate>
            <atom:updated>2026-10-14T14:30:42.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kj5RiYNDLD4K_zPORvM5nA.png" /></figure><p><strong>How to make AI applications more responsive by observing what happens inside an AI workflow in real time.</strong></p><p>When we interact with an AI application, we usually see a simple interface: we enter a prompt, wait for a moment, and receive a response.</p><p>But behind that seemingly simple interaction, a lot can happen.</p><p>An AI workflow might call an LLM, execute a tool, retrieve information from a database, validate a result, update its internal state, and then generate a final response.</p><p>If all of these operations happen behind the scenes, users may experience unnecessary waiting, and developers may struggle to understand what is happening inside the application.</p><p>This is where <strong>streaming in LangGraph</strong> becomes particularly useful.</p><p>Instead of waiting for the entire workflow to finish, LangGraph allows us to observe intermediate activity as the graph executes.</p><p>We can stream the AI’s generated messages, inspect updates from individual nodes, or receive snapshots of the workflow’s state.</p><p>In this article, we’ll explore these three streaming modes:</p><ul><li><strong>Messages</strong> — What the AI is generating.</li><li><strong>Updates</strong> — What each workflow step changes or returns.</li><li><strong>Values</strong> — What the complete workflow state looks like after an execution step.</li></ul><p>We’ll also build a simple example to understand how these modes work in practice.</p><h3>1. What Is LangGraph?</h3><p>LangGraph is a framework for building stateful, multi-step AI applications. It is particularly useful when an AI workflow needs to do more than generate a single response.</p><p>For example, consider an AI travel-planning assistant.</p><p>When a user asks:</p><blockquote><em>Plan a three-day trip to Bangalore with places to visit, food recommendations, and a budget.</em></blockquote><p>The application might need to:</p><ol><li>Understand the user’s request.</li><li>Research destinations and activities.</li><li>Build an itinerary.</li><li>Estimate the budget.</li><li>Generate the final response.</li></ol><p>Each step can be represented as a node in a graph.</p><p>The nodes communicate through a shared state, and the graph defines how execution moves from one step to another.</p><p>A simplified workflow might look like this:</p><p><strong>User Input → Research → Planning → Final Response</strong></p><p>Without streaming, the application may wait until the entire graph finishes before showing anything meaningful to the user.</p><p>With streaming, we can expose useful information while the graph is still running.</p><p>This improves the user experience and makes it easier to debug complex workflows.</p><h3>2. Why Does Streaming Matter?</h3><p>Imagine submitting a request to an AI agent that takes eight seconds to complete.</p><p>Without streaming, the user might see a loading spinner for eight seconds and then receive the entire response at once.</p><p>Even if the application is doing useful work during those eight seconds, the user has no visibility into it.</p><p>Streaming changes that experience.</p><p>The application can show generated text as it arrives, display progress as workflow nodes finish, or update a live view of the agent’s state.</p><p>Streaming is useful for several reasons.</p><p><strong>Better user experience</strong></p><p>Users can begin reading a response before the complete answer is generated. This is especially valuable for long responses.</p><p><strong>Improved observability</strong></p><p>Developers can see which steps are executing and inspect their outputs without waiting for the entire workflow to finish.</p><p><strong>More responsive interfaces</strong></p><p>Frontend applications can update their UI incrementally rather than waiting for one large response.</p><p><strong>Easier debugging</strong></p><p>Intermediate outputs help identify unexpected node results, incorrect state transitions, and workflow problems.</p><p>However, streaming does not necessarily make the underlying workflow execute faster. Its primary benefit is that information becomes available incrementally.</p><p>To understand how LangGraph supports this, let’s look at its three important streaming modes.</p><h3>3. Streaming Messages: What Is the AI Saying?</h3><p>The first mode is messages.</p><p>This mode is useful when you want to stream language-model output token by token, or in small chunks, as it becomes available.</p><p>Think about how ChatGPT displays a long answer.</p><p>Instead of waiting for the entire response, you can see the text appear progressively.</p><p>The same general idea applies to LLM-based applications built with LangGraph.</p><p>For example, imagine an agent generating this response:</p><blockquote><em>Bangalore is a great destination for a three-day trip. You can explore its parks, historic landmarks, cafes, and local food scene.</em></blockquote><p>With message streaming, the application can begin displaying the response before the model has generated every word.</p><h3>How does it work?</h3><p>When using the messages streaming mode, LangGraph emits message chunks along with metadata identifying the node that produced them.</p><p>Conceptually, an event might contain:</p><ul><li>A piece of generated text.</li><li>Information about the message.</li><li>Metadata about the graph node or model invocation.</li></ul><p>The application can process these chunks and append the generated text to the visible response.</p><h3>Example</h3><pre>from langchain.chat_models import init_chat_model<br>from langgraph.graph import StateGraph, START, END<br>from typing_extensions import TypedDict</pre><pre>model = init_chat_model(&quot;openai:gpt-4.1-mini&quot;)<br></pre><pre>class State(TypedDict):<br>    question: str<br>    answer: str<br></pre><pre>def generate_answer(state: State):<br>    response = model.invoke(state[&quot;question&quot;])<br>    return {&quot;answer&quot;: response.content}<br></pre><pre>builder = StateGraph(State)<br>builder.add_node(&quot;generate_answer&quot;, generate_answer)<br>builder.add_edge(START, &quot;generate_answer&quot;)<br>builder.add_edge(&quot;generate_answer&quot;, END)</pre><pre>graph = builder.compile()</pre><pre>for message_chunk, metadata in graph.stream(<br>    {&quot;question&quot;: &quot;Explain why Bangalore is popular with tourists.&quot;},<br>    stream_mode=&quot;messages&quot;,<br>):<br>    if message_chunk.content:<br>        print(message_chunk.content, end=&quot;&quot;, flush=True)</pre><p>This example illustrates the message-streaming pattern. Exact chunk types and behavior can vary depending on the model and the LangGraph/LangChain versions you use.</p><p><strong>Important:</strong> Calling model.invoke() inside a node generally waits for the model to finish. To stream tokens from the model itself, use a streaming-capable model call, such as model.stream(), or an appropriately configured LangGraph node and model integration.</p><p>For example, the node can yield model chunks through a streaming-capable implementation, allowing LangGraph’s message stream to expose them as they arrive.</p><h3>When should you use message streaming?</h3><p>Use it when:</p><ul><li>You want to display generated text incrementally.</li><li>You’re building a conversational AI interface.</li><li>Your application generates long responses.</li><li>You want to expose model output while the workflow continues.</li></ul><p>One important detail: <strong>message streaming is about LLM output, not a complete description of everything happening in the graph.</strong></p><p>If you need to inspect intermediate node results or the application’s shared state, the other streaming modes are more appropriate.</p><h3>4. Streaming Updates: What Just Changed?</h3><p>The second mode is updates.</p><p>While message streaming focuses on what the model generates, update streaming focuses on the results returned by graph nodes.</p><p>Suppose our travel-planning workflow contains three nodes:</p><ul><li>research</li><li>plan</li><li>finalize</li></ul><p>Each node performs a specific operation and returns updates to the graph’s state.</p><p>For example:</p><p>The research node returns:</p><pre>{<br>    &quot;research&quot;: &quot;Recommended destinations and activities&quot;<br>}</pre><p>The planning node returns:</p><pre>{<br>    &quot;itinerary&quot;: &quot;A three-day itinerary&quot;<br>}</pre><p>The finalization node returns:</p><pre>{<br>    &quot;final_answer&quot;: &quot;Your completed travel plan&quot;<br>}</pre><p>With updates, LangGraph can emit the state updates returned by these nodes as they execute.</p><p>This means you can inspect the result of each step without waiting for the entire graph to finish.</p><h3>Example</h3><p>Let’s build a small workflow that demonstrates this behavior.</p><pre>from typing_extensions import TypedDict<br>from langgraph.graph import StateGraph, START, END<br></pre><pre>class TravelState(TypedDict, total=False):<br>    request: str<br>    research: str<br>    itinerary: str<br>    final_answer: str<br></pre><pre>def research(state: TravelState):<br>    return {<br>        &quot;research&quot;: (<br>            &quot;Cubbon Park, Lalbagh Botanical Garden, &quot;<br>            &quot;Bangalore Palace, and local food spots.&quot;<br>        )<br>    }<br></pre><pre>def plan(state: TravelState):<br>    return {<br>        &quot;itinerary&quot;: (<br>            &quot;Day 1: Parks and local food. &quot;<br>            &quot;Day 2: Historic landmarks. &quot;<br>            &quot;Day 3: Cafes and relaxed sightseeing.&quot;<br>        )<br>    }<br></pre><pre>def finalize(state: TravelState):<br>    return {<br>        &quot;final_answer&quot;: (<br>            f&quot;Travel plan: {state[&#39;itinerary&#39;]}&quot;<br>        )<br>    }<br></pre><pre>builder = StateGraph(TravelState)</pre><pre>builder.add_node(&quot;research&quot;, research)<br>builder.add_node(&quot;plan&quot;, plan)<br>builder.add_node(&quot;finalize&quot;, finalize)</pre><pre>builder.add_edge(START, &quot;research&quot;)<br>builder.add_edge(&quot;research&quot;, &quot;plan&quot;)<br>builder.add_edge(&quot;plan&quot;, &quot;finalize&quot;)<br>builder.add_edge(&quot;finalize&quot;, END)</pre><pre>graph = builder.compile()</pre><pre>for update in graph.stream(<br>    {&quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;},<br>    stream_mode=&quot;updates&quot;,<br>):<br>    print(update)</pre><p>The output will contain updates associated with the nodes that execute.</p><p>Conceptually, you might see something like:</p><pre>{&quot;research&quot;: {&quot;research&quot;: &quot;Recommended destinations...&quot;}}</pre><pre>{&quot;plan&quot;: {&quot;itinerary&quot;: &quot;Day 1: Parks and local food...&quot;}}</pre><pre>{&quot;finalize&quot;: {&quot;final_answer&quot;: &quot;Travel plan: Day 1...&quot;}}</pre><p>The strings above are illustrative and abbreviated. The actual values will depend on your node implementations.</p><h3>Why is this useful?</h3><p>Imagine you’re building a frontend for an AI agent.</p><p>Instead of displaying only a generic loading indicator, your UI can communicate meaningful progress:</p><ul><li>Research completed.</li><li>Itinerary created.</li><li>Final response prepared.</li></ul><p>You can also log intermediate node outputs during development to understand how information moves through the workflow.</p><p>There is an important distinction here: <strong>updates represent the changes returned by nodes, not necessarily the entire current state of the graph.</strong></p><p>If you want the complete state after each step, use values.</p><h3>When should you use update streaming?</h3><p>Use it when:</p><ul><li>You want to observe node execution.</li><li>You need progress indicators for multi-step agents.</li><li>You want to debug intermediate results.</li><li>You want to build interfaces that react to workflow events.</li></ul><p>For complex applications, update streaming is often one of the most useful ways to understand what an agent is doing.</p><h3>5. Streaming Values: What Does the Entire State Look Like Now?</h3><p>The third mode is values.</p><p>To understand it, we need to look at the concept of state in LangGraph.</p><p>A graph’s state is the shared data structure that nodes read from and update as execution progresses.</p><p>In our travel-planning example, the state might contain:</p><pre>{<br>    &quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;,<br>    &quot;research&quot;: &quot;...&quot;,<br>    &quot;itinerary&quot;: &quot;...&quot;,<br>    &quot;final_answer&quot;: &quot;...&quot;<br>}</pre><p>As the graph executes, different nodes contribute new information to that state.</p><p>With values, LangGraph emits snapshots of the full state after graph steps.</p><p>This differs from updates, which emits the updates returned by individual nodes.</p><h3>Example</h3><p>Using the same graph, change the streaming mode:</p><pre>for state in graph.stream(<br>    {&quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;},<br>    stream_mode=&quot;values&quot;,<br>):<br>    print(state)</pre><p>Conceptually, the state evolves as follows.</p><p><strong>After research:</strong></p><pre>{<br>    &quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;,<br>    &quot;research&quot;: &quot;Recommended destinations and activities&quot;<br>}</pre><p><strong>After planning:</strong></p><pre>{<br>    &quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;,<br>    &quot;research&quot;: &quot;Recommended destinations and activities&quot;,<br>    &quot;itinerary&quot;: &quot;A three-day itinerary&quot;<br>}</pre><p><strong>After finalization:</strong></p><pre>{<br>    &quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;,<br>    &quot;research&quot;: &quot;Recommended destinations and activities&quot;,<br>    &quot;itinerary&quot;: &quot;A three-day itinerary&quot;,<br>    &quot;final_answer&quot;: &quot;Your completed travel plan&quot;<br>}</pre><p>These are simplified representations of the evolving state, not literal output from the preceding example.</p><p>The key idea is that each emitted value represents the full state snapshot, including the information accumulated up to that point.</p><h3>Why is this useful?</h3><p>Values are particularly useful when you need to understand the complete context available to your workflow.</p><p>For example, suppose an agent produces an incorrect answer.</p><p>You might want to investigate:</p><ul><li>Was the original user request preserved?</li><li>Did the research node return the expected information?</li><li>Did the planning node update the itinerary correctly?</li><li>Was the final answer generated from the expected state?</li></ul><p>With state streaming, you can observe how the shared state evolves and identify where things went wrong.</p><p>It can also help you build live debugging interfaces that display the current workflow state.</p><p>One caution: full state snapshots can be large. If your application stores documents, tool results, or substantial conversation history in its state, streaming every snapshot may create significant overhead.</p><h3>When should you use value streaming?</h3><p>Use it when:</p><ul><li>You need complete state snapshots.</li><li>You’re debugging state transitions.</li><li>You’re inspecting data shared between nodes.</li><li>You’re developing internal tools for workflow observability.</li></ul><h3>6. Messages vs. Updates vs. Values</h3><p>Now that we’ve explored each mode, let’s compare them directly.</p><p>FeatureMessagesUpdatesValuesPrimary purposeStream LLM outputObserve node updatesObserve full stateTypical contentMessage chunks and metadataNode names and returned updatesComplete state snapshotsBest use caseLive text generationWorkflow progress and debuggingState inspectionUI exampleText appearing progressively”Research completed”Live state inspectorData scopeModel outputNode-level changesEntire current state</p><p>The easiest way to remember the difference is:</p><p><strong>Messages = What the AI is saying.</strong></p><p><strong>Updates = What each workflow step returned.</strong></p><p><strong>Values = What the overall state looks like now.</strong></p><p>These modes aren’t competing alternatives. Each gives you a different view of the same running workflow.</p><h3>7. Can We Combine These Streaming Modes?</h3><p>Yes. This is where streaming becomes especially powerful.</p><p>LangGraph supports requesting multiple streaming modes in one execution.</p><p>For example:</p><pre>for part in graph.stream(<br>    {&quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;},<br>    stream_mode=[&quot;updates&quot;, &quot;values&quot;],<br>):<br>    print(part)</pre><p>When multiple modes are enabled, the emitted events are tagged with their respective mode so that your application can distinguish them.</p><p>The exact event structure depends on the API and version being used. In current LangGraph APIs, you can also use the version=&quot;v2&quot; streaming format to receive a consistent event structure, including a type field and mode-specific data.</p><p>For example:</p><pre>for part in graph.stream(<br>    {&quot;request&quot;: &quot;Plan a three-day Bangalore trip&quot;},<br>    stream_mode=[&quot;updates&quot;, &quot;values&quot;],<br>    version=&quot;v2&quot;,<br>):<br>    if part[&quot;type&quot;] == &quot;updates&quot;:<br>        print(&quot;Node updates:&quot;, part[&quot;data&quot;])</pre><pre>    elif part[&quot;type&quot;] == &quot;values&quot;:<br>        print(&quot;Current state:&quot;, part[&quot;data&quot;])</pre><p>Check your installed LangGraph version for support for this format.</p><p>You can apply the same general pattern to an application that needs to expose several different types of information simultaneously.</p><p>For instance, an AI application might:</p><ol><li>Display generated text as it arrives.</li><li>Show which agent step has completed.</li><li>Keep a developer-facing state inspector updated.</li></ol><p>A frontend can consume these events and render the relevant information in separate parts of the interface.</p><p>This is particularly valuable when building AI agents that perform multiple operations before returning a final answer.</p><h3>8. A Practical Architecture for Streaming AI Applications</h3><p>Let’s consider how these ideas fit into a real application.</p><p>Imagine you’re building an AI-powered research assistant using:</p><ul><li><strong>LangGraph</strong> for workflow orchestration.</li><li><strong>An LLM</strong> for reasoning and text generation.</li><li><strong>FastAPI</strong> for the backend.</li><li><strong>React</strong> for the frontend.</li></ul><p>A typical architecture looks like this:</p><p><strong>React frontend → FastAPI endpoint → LangGraph workflow → LLM and tools</strong></p><p>The backend starts the graph execution and forwards selected events to the frontend.</p><p>The frontend consumes those events and updates the UI.</p><p>Different streaming modes can serve different UI responsibilities.</p><h3>Message events</h3><p>Append generated text to the assistant’s response.</p><h3>Update events</h3><p>Update the workflow’s progress indicator or activity timeline.</p><h3>Value events</h3><p>Refresh a state inspector or debugging panel.</p><p>The backend can expose these events through a streaming transport such as Server-Sent Events (SSE) or WebSockets.</p><p>For a straightforward, one-way stream from the server to the browser, SSE is often a good starting point.</p><p>For applications requiring bidirectional, real-time communication, WebSockets may be more appropriate.</p><h3>Important implementation considerations</h3><p><strong>1. Stream events deliberately</strong></p><p>Not every internal event needs to reach the end user. Decide which events belong in the public UI and which should remain available only for debugging.</p><p><strong>2. Handle partial output</strong></p><p>A message may arrive in several chunks. Your frontend should append chunks correctly rather than replacing the response each time.</p><p><strong>3. Preserve event ordering</strong></p><p>When forwarding multiple event types, maintain a clear event format and avoid accidentally mixing state updates with generated text.</p><p><strong>4. Handle errors and cancellation</strong></p><p>A client can disconnect while a graph is running. Your backend should handle cancellation, exceptions, and cleanup appropriately.</p><p><strong>5. Consider privacy</strong></p><p>State snapshots and tool outputs may contain sensitive information. Avoid exposing internal prompts, credentials, private documents, or raw tool results to unauthorized users.</p><p><strong>6. Remember that node completion is not necessarily token generation</strong></p><p>A node may invoke an LLM, wait for an external API, or perform a long computation. Update streaming can show node results, but it does not automatically provide fine-grained progress inside every operation.</p><p>Designing a good streaming experience requires more than enabling a streaming mode. It also requires deciding what information is useful, when it becomes available, and how it should be presented.</p><h3>9. Common Mistakes to Avoid</h3><p>When working with LangGraph streaming, a few misunderstandings are worth avoiding.</p><h3>Mistake 1: Assuming updates and values are identical</h3><p>They aren’t.</p><p>Updates show the changes returned by nodes, while values show the full state snapshot.</p><p>If you need the entire state, use values.</p><h3>Mistake 2: Expecting every node to generate message chunks</h3><p>Not every node invokes an LLM. A node that performs a calculation or calls an external service may return a state update without producing any model-generated text.</p><p>Message streaming is most relevant to LLM output.</p><h3>Mistake 3: Assuming streaming makes the workflow faster</h3><p>Streaming improves visibility and perceived responsiveness, but the underlying workflow still needs to perform its work.</p><p>A slow database query remains slow, even if other events are streamed while it executes.</p><h3>Mistake 4: Sending every internal event to the user</h3><p>Developer-facing diagnostics and end-user progress are different concerns.</p><p>A production application should expose only the events that make sense for its intended audience.</p><h3>Mistake 5: Forgetting to configure actual model streaming</h3><p>If an LLM invocation waits for a complete response before returning, your graph node may not produce text incrementally.</p><p>Use the model’s streaming functionality and the appropriate LangGraph integration when token-level output is required.</p><h3>Mistake 6: Ignoring state size</h3><p>Full state snapshots can be expensive when the graph accumulates large amounts of data.</p><p>Use the streaming mode that matches the information you need rather than collecting everything by default.</p><h3>10. Which Streaming Mode Should You Choose?</h3><p>You don’t always need all three modes.</p><p>The right choice depends on the problem you’re trying to solve.</p><p><strong>Choose </strong><strong>messages</strong> when the primary goal is to display AI-generated text as soon as it becomes available.</p><p><strong>Choose </strong><strong>updates</strong> when you need to understand what each node returns or communicate progress through a multi-step workflow.</p><p><strong>Choose </strong><strong>values</strong> when you need to inspect the complete state after each graph step.</p><p>For many production applications, a combination works best.</p><p>For example, a customer-facing assistant may primarily need message streaming, while an internal agent dashboard may benefit more from updates and values.</p><p>Start with the smallest set of events that supports your use case. Add more only when they provide meaningful value.</p><h3>Conclusion</h3><p>Streaming is an important part of building responsive AI applications, particularly when workflows involve multiple steps, tools, and LLM calls.</p><p>LangGraph provides different ways to observe a running workflow, each designed for a different purpose.</p><ul><li><strong>Messages</strong> let us observe model output as it becomes available.</li><li><strong>Updates</strong> let us inspect what individual nodes return.</li><li><strong>Values</strong> let us observe how the complete state evolves.</li></ul><p>Once you understand these differences, it’s much easier to design useful progress indicators, build live debugging tools, and create AI interfaces that feel responsive.</p><p>The next time you build a LangGraph application, don’t think of the workflow as a black box that produces a final answer.</p><p>Think of it as a sequence of meaningful events that your application can observe and use.</p><p>That small change in perspective can make a big difference in how you build, debug, and deliver AI-powered experiences.</p><p><strong>What about you? Have you used LangGraph streaming in a project? Which mode do you find most useful — Messages, Updates, or Values?</strong></p><p>I’d love to hear about your experience.</p><p>#LangGraph #AI #GenerativeAI #AIEngineering #Python #LLM #AgenticAI #SoftwareEngineering</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef1389004a44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Retriever can cause bugs?]]></title>
            <link>https://medium.com/@brniranjanhegde/why-retriever-can-cause-bugs-4330e67ddcf7?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4330e67ddcf7</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[rag-pipeline]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 11:43:39 GMT</pubDate>
            <atom:updated>2026-10-13T11:43:39.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hC9k9anGrnl_NVa_ySZEcw.png" /></figure><p><em>Why your RAG system is probably failing before the model ever speaks, and how to fix it.</em></p><p>Our RAG chatbot kept giving wrong answers.</p><p>So I did what everyone does. I rewrote the prompt. I swapped in a bigger model. I fiddled with the temperature. I added “only answer from the provided context” in capital letters, as if shouting at the model would help.</p><p>Nothing worked. Three weeks went by.</p><p>Then, out of frustration, I did something I should have done on day one: I printed exactly what the retriever was sending to the model.</p><p>The right answer wasn’t in there. It had never been in there.</p><p>The LLM wasn’t hallucinating out of stupidity. It was doing its best with the wrong pages.</p><h3>The lawyer who never saw the contract</h3><p>Imagine hiring a brilliant lawyer and asking a question about <em>your</em> contract, but never handing them the contract. They would still answer. Confidently. Fluently. And very possibly wrong.</p><p>That is an LLM with a bad retriever.</p><p>In Retrieval-Augmented Generation (RAG), the flow is simple:</p><ol><li>A user asks a question.</li><li>The <strong>retriever</strong> searches your knowledge base and pulls out the most relevant chunks.</li><li>The <strong>LLM</strong> reads those chunks and writes the answer.</li></ol><p>Most teams pour their energy into step 3, because the model is the shiny part. But the model can only be as good as what step 2 hands it. Garbage context in, polished garbage out.</p><h3>How to tell it’s the retriever, not the model</h3><p>Before you touch the prompt again, run this quick check. For a handful of questions your system gets wrong, look at the retrieved chunks and ask:</p><ul><li><strong>Is the answer anywhere in the context?</strong> If not, no model on earth can save you. This is a retrieval failure.</li><li><strong>Is it there but buried?</strong> If the answer sits in chunk 9 of 10, you have a ranking problem.</li><li><strong>Is it there and clear, yet the model still gets it wrong?</strong> Only now is it a generation problem.</li></ul><p>In my case, the answer was missing in most failures. Three weeks of prompt tuning had been aimed at the wrong target.</p><h3>What actually fixed it</h3><p>Three changes made the difference, and none of them touched the LLM.</p><p><strong>1. Better chunking.</strong> We had been splitting documents into large, arbitrary blocks. A single chunk often mixed three unrelated topics, which diluted its meaning and made it match poorly. Smaller, semantically coherent chunks (a section, a policy, a single FAQ answer) retrieved far more accurately.</p><p><strong>2. Hybrid search.</strong> Pure semantic search is great at meaning but surprisingly weak at exact terms like product codes, error IDs, and names. Pure keyword search has the opposite problem. Combining both, keyword plus vector search, covered each other’s blind spots.</p><p><strong>3. A re-ranker.</strong> The retriever casts a wide net, say the top 20 results. A re-ranker then reads the question and each candidate more carefully and reorders them, so the best few reach the model first. It’s a small extra step with an outsized payoff.</p><p>Accuracy jumped, and we hadn’t changed a single word of the prompt or touched the model.</p><h3>The takeaway</h3><p>When a RAG system fails, our instinct is to blame the part that talks. But the part that <em>finds</em> is usually the culprit.</p><p>So next time your AI gives a wrong answer, resist the urge to upgrade the model. Open the logs. Read what the retriever actually retrieved. Ask the simplest question in AI engineering:</p><p><strong>Did my model even see the right information?</strong></p><p>Sometimes the smartest fix isn’t a smarter brain. It’s a better librarian.</p><p><em>Have you ever blamed the model when the retriever was the real problem? I’d love to hear your story in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4330e67ddcf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All About Chunking in AI world]]></title>
            <link>https://medium.com/@brniranjanhegde/all-about-chunking-in-ai-world-500abf04116e?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/500abf04116e</guid>
            <category><![CDATA[developing-ai-models]]></category>
            <category><![CDATA[chunking]]></category>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Tue, 29 Sep 2026 10:54:28 GMT</pubDate>
            <atom:updated>2026-09-29T10:54:28.752Z</atom:updated>
            <content:encoded><![CDATA[<p>A chunk describing “the pump” has no idea it’s referring to the XR-12 pump defined three paragraphs earlier. That’s not a bug in a retrieval system. That’s the default behavior of how most RAG pipelines are built — and once you understand why, chunk size stops looking like the actual problem.</p><h3>The Basics, Quickly</h3><p>Before a language model can answer a question using your documents, two things have to happen. First, the document gets split into smaller pieces — chunking. Second, each piece gets converted into a vector, a list of numbers representing its meaning in high-dimensional space — an embedding. When a question comes in, it gets embedded too, and the system retrieves whichever chunks have embeddings closest to the question’s embedding.</p><p>That’s the entire mechanism behind “chat with your PDF,” AI-powered search over internal documents, and most retrieval-augmented generation systems in production today. The part that gets glossed over is what happens to meaning during that splitting step.</p><h3>Isolation Is the Real Problem, Not Chunk Size</h3><p>Standard chunking embeds each piece of text completely independently. Split a document into ten chunks, and each one gets sent through the embedding model on its own, with zero awareness that the other nine chunks — or the rest of the document — exist at all.</p><p>This is why chunk size feels like an unsolvable tradeoff. Make chunks small, and you lose surrounding context — pronouns without antecedents, terms referenced without their definitions, numbers without the label that gives them meaning. Make chunks large, and you run into a different problem: cramming multiple distinct ideas into a single embedding vector mathematically blurs that vector. An embedding is a compressed representation, and forcing it to represent several unrelated topics at once means it ends up representing none of them precisely. This is sometimes called the dilution problem, and it’s a direct consequence of how embedding models pool information into a fixed-size vector.</p><p>The uncomfortable realization: adjusting chunk size doesn’t fix the underlying issue. It just trades one failure mode for the other. The isolation problem — each chunk being embedded blind to everything around it — is the actual root cause, and it doesn’t go away no matter what size you pick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQ2QMyAx0wqU-m_G8vSk8A.png" /></figure><h3>Late Chunking: Changing the Order of Operations</h3><p>In 2024, Jina AI introduced a technique called late chunking that addresses this directly, by changing <em>when</em> chunking happens relative to <em>when</em> embedding happens, rather than changing chunk size at all.</p><p>Standard pipelines chunk first, then embed each chunk independently. Late chunking reverses that order. The entire document — or as much of it as fits the embedding model’s context window — is run through a long-context transformer first, as a single pass. Because of how self-attention works, every token’s internal representation ends up incorporating information from every other token in that same pass. Only after this full-document forward pass do you apply chunk boundaries, mean-pooling the token-level embeddings within each span to produce the final per-chunk vectors.</p><p>The result is subtle but important: the chunks themselves are still small. But each chunk’s embedding was generated with full awareness of the document it came from, because that awareness was baked in during the attention pass, before any splitting occurred. A chunk mentioning “the pump” produces an embedding that has already implicitly incorporated the earlier mention of “XR-12 pump,” because the model attended to that earlier text while processing this one.</p><p>This isn’t a theoretical improvement. Benchmark testing shows roughly a 5 to 10 percent retrieval accuracy improvement over standard isolated-chunk embedding, concentrated specifically in documents with heavy cross-referencing — pronouns, definitions introduced once and referenced repeatedly, and narrative dependencies where later text only makes sense in light of earlier text.</p><h3>The Real Constraints</h3><p>Late chunking isn’t free of tradeoffs. It requires an embedding model architecture built around mean pooling across token embeddings — CLS-token-style models, which compress everything into a single summary token, can’t be used this way. And the entire document still has to fit inside the embedding model’s context window in order to be processed in one pass; for a model like jina-embeddings-v3, that ceiling is around 8,192 tokens, roughly ten pages. Documents longer than that need to be pre-divided into sections before late chunking is applied within each section, which reintroduces a smaller-scale version of the original isolation problem at the section boundaries.</p><h3>An Alternative Approach: Contextual Retrieval</h3><p>Late chunking isn’t the only way to solve this. Anthropic’s Contextual Retrieval technique, introduced around the same period, approaches the identical underlying problem from the opposite direction. Instead of changing when embedding happens, it changes what gets embedded. Before a chunk is embedded, a language model generates a short piece of explanatory context — a sentence or two situating that chunk within the broader document — and prepends it to the chunk’s actual text. The isolation problem gets solved by making the missing context explicit in the text itself, rather than architecturally folding it in through an early attention pass.</p><p>The two techniques target the same failure mode through genuinely different mechanisms, and they aren’t mutually exclusive — some pipelines combine chunking-boundary strategies like semantic chunking with either approach, since deciding <em>where</em> to split and deciding <em>how much context each split retains</em> are separate design decisions.</p><h3>Why This Matters in Practice</h3><p>If you’re building or evaluating a RAG system, the practical takeaway is this: chunk size tuning is treating a symptom. The actual design question worth asking is whether your chunks are being embedded with any awareness of the document they came from, or whether each one is being handed to the embedding model in total isolation. For documents that are mostly self-contained, dense with standalone facts, isolation barely matters. For documents full of cross-references, defined terms used repeatedly, and narrative structure — technical manuals, legal contracts, long reports — it’s very often the actual reason retrieval quality falls short, long before chunk size is the real culprit.</p><p>Chunking was never really about how to split text. It was always about how to keep a small piece of a document from forgetting the document it came from.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=500abf04116e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pydantic vs Typescript]]></title>
            <link>https://medium.com/@brniranjanhegde/pydantic-vs-typescript-9977256f6ffd?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9977256f6ffd</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[pydantic]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 06:35:12 GMT</pubDate>
            <atom:updated>2026-09-22T06:37:15.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQ5IEd7EBELSgxRTEh9YQg.png" /></figure><p>TypeScript types vanish the moment your code compiles. Pydantic types don’t — they’re still running when your code executes. That one difference is worth understanding if you’ve ever used Zod.</p><p>If you’ve ever added Zod on top of TypeScript, you already understand Pydantic. You just didn’t know it yet.</p><p>Why Your TypeScript Types Are Lying to You at Runtime</p><p>I’ve shipped a bug that TypeScript should have caught. It didn’t, because it couldn’t — and once I understood why, it changed how I think about type safety entirely.</p><p>Here’s the setup: an API returns a user object. My interface says age: number. TypeScript is happy. The editor shows no red squiggles. The build passes. Then, in production, that same field comes back as a string because someone changed the backend without telling anyone, and a piece of math further down the code silently produces garbage instead of a number.</p><p>TypeScript never had a chance to catch this. And once you understand why, you start seeing the exact same gap everywhere in the JavaScript ecosystem — and you start noticing that Python’s Pydantic library closes it in a fundamentally different, arguably better, way.</p><h3>Types That Don’t Survive Their Own Compilation</h3><p>TypeScript’s type system is, structurally, a very good idea: annotate your code, catch mismatches before you ship. But the mechanism behind it has a hard limit that’s easy to forget once you’re used to the safety it provides.</p><p>TypeScript types are erased at compile time. The compiler uses them to check your code, and then deletes them. The JavaScript that actually runs in a browser or a Node process has no concept of an “interface” or a “type” at all — it’s plain, untyped JavaScript, identical to what you’d get if you’d never annotated anything in the first place.</p><p>This means TypeScript’s checking only applies to code paths it can see at compile time. It has no power over anything arriving from outside that boundary: an API response, a user’s form input, a third-party library without accurate type definitions, a message from a WebSocket. You can annotate the shape you <em>expect</em>, but nothing enforces that the data actually <em>is</em> that shape once your program is running.</p><h3>The Ecosystem Already Built a Patch For This</h3><p>If you’ve used Zod, you’ve already met the solution the JavaScript ecosystem converged on. Rather than trusting a compile-time-only type, you define a runtime schema, and validate incoming data against it as your code executes. If the data doesn’t match, the validator throws or reports an error right then, instead of letting bad data quietly propagate into your app’s logic.</p><p>This wasn’t a small addition. It became close to standard practice for any serious TypeScript codebase handling external data, precisely because everyone eventually ran into the same problem: a .ts file full of accurate-looking interfaces gives you exactly zero runtime protection on its own.</p><p>The tradeoff most developers accept without really noticing: now you’re maintaining two separate things. A TypeScript interface for compile-time checking, and a Zod schema for runtime checking. They’re supposed to describe the same shape. Nothing forces them to actually stay in sync — that discipline is on you.</p><h3>Pydantic Skips the Duplication Entirely</h3><p>This is where Python’s Pydantic library, and by extension FastAPI which is built on top of it, does something structurally different rather than just “better.”</p><p>In Pydantic, there is no separate runtime schema. The type hint itself is the runtime schema. Write:</p><pre>class User(BaseModel):<br>    age: int</pre><p>That int annotation isn&#39;t decoration for an editor&#39;s benefit. It&#39;s read by Pydantic and used to genuinely validate incoming data, every single time an object of that type gets constructed — not once at compile time, but continuously, at runtime, for the entire life of the application.</p><p>Send in age: &quot;old&quot;, and Pydantic doesn&#39;t let it through as a User at all. It raises a clear validation error, naming exactly which field failed and why. There&#39;s no separate file to keep in sync, no risk of your &quot;type&quot; and your &quot;validator&quot; quietly drifting apart over months of edits, because they were never two things to begin with.</p><h3>The Actual Difference, Side by Side</h3><p>In a TypeScript codebase, the honest picture looks like this: an interface tells the compiler and your editor what shape you expect, and it disappears the moment your code runs. A Zod schema (or similar) is the thing actually protecting you once real data shows up, and it’s a second artifact you write and maintain by hand.</p><p>In a Python codebase using Pydantic, there’s one artifact. The class definition is simultaneously the thing your editor uses for autocompletion and static checking, and the thing enforcing that shape the instant real data arrives. There’s nothing to keep in sync, because there was only ever one definition to begin with.</p><p>Neither approach is “wrong.” TypeScript’s model is a deliberate tradeoff — compile-time-only checking is fast and has no runtime cost by default, and opting into runtime validation with something like Zod is a conscious choice rather than a forced one. Pydantic makes the opposite tradeoff by default: every model construction does real work, and in exchange, correctness at the boundary is baked in rather than optional.</p><h3>Why This Matters If You Build Against a Python Backend</h3><p>For frontend developers working against a FastAPI backend specifically, this isn’t just a fun bit of trivia — it has a direct practical benefit. Because FastAPI’s request and response models are Pydantic models, and those same models are used to autogenerate the API’s OpenAPI schema, you can generate accurate TypeScript types directly from that schema rather than hand-writing interfaces and hoping they match what the backend actually returns.</p><p>That closes a version of the same gap from the other direction: instead of trusting a manually maintained frontend type that might drift from reality, you’re pulling the type from the one place it’s actually being enforced.</p><h3>The Takeaway</h3><p>The uncomfortable truth buried in all of this: a type system that only exists at compile time gives you confidence about your own code, and tells you nothing about the world outside it. Every serious TypeScript codebase eventually rediscovers this and reaches for a runtime validator to patch the gap. Pydantic’s real contribution isn’t that it validates data — plenty of tools do that. It’s that it refuses to let “the shape I declared” and “the shape I enforce” become two different things in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9977256f6ffd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FAST APIS]]></title>
            <link>https://medium.com/@brniranjanhegde/fast-apis-80c25c6a9e08?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/80c25c6a9e08</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 14:33:10 GMT</pubDate>
            <atom:updated>2026-09-15T14:33:10.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QteBrScS-xMXDLd9qIU6pQ.png" /></figure><p>Every time an app “talks” to another app — your food delivery app checking restaurant availability, a chatbot calling an AI model — something has to handle that conversation. For a huge number of companies today, that something is FastAPI.</p><p>You don’t need to be technical to get why it matters.</p><p>→ Think of it as a really good receptionist. Any time one piece of software needs to ask another piece of software for something — “get me this user’s order,” “check if this item is in stock” — that request goes through an API. FastAPI is one of the most popular tools for building that receptionist desk.</p><p>→ It catches mistakes before they become problems. If someone sends the wrong type of information — text where a number was expected — FastAPI flags it immediately, instead of letting a broken request quietly cause errors somewhere downstream.</p><p>→ It writes its own documentation. Normally, explaining “here’s how to use our system” to other developers or teams is a separate, tedious job. FastAPI generates a clear, interactive reference automatically, just from how the code is written — saving real engineering time.</p><p>→ It’s fast — genuinely, not just marketing. Python has a reputation for being slower than some other languages. FastAPI was specifically built to compete with much faster tools, which is part of why it became so popular so quickly.</p><p>→ It’s become the default choice for AI products. When you use a chatbot or an AI feature inside an app, there’s a very good chance FastAPI is the layer quietly connecting that app to the AI model behind the scenes.</p><p>It’s not flashy. Nobody outside engineering usually hears the name. But it’s one of the quiet pieces of infrastructure holding together a huge share of the apps — and AI products — people use every day.</p><p>Had you heard of FastAPI before, or is this the first time the name’s come up?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80c25c6a9e08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Function Calling in OpenAI API ]]></title>
            <link>https://medium.com/@brniranjanhegde/function-calling-in-openai-api-33355e568a36?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/33355e568a36</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-tools]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 16:29:13 GMT</pubDate>
            <atom:updated>2026-09-07T16:29:13.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-ke2ROR7WfIROeI8BUrqg.png" /></figure><p>What if your AI could <strong>do things</strong>, not just answer questions?</p><p>That’s where <strong>Function Calling</strong> comes in.</p><p>Imagine you ask your AI assistant:</p><blockquote><em>“What’s the weather in Bangalore?”</em></blockquote><p>The model itself doesn’t magically know the latest weather.</p><p>Instead, it can decide:</p><p><strong>“I need to call a weather function.”</strong></p><p>And this is where things get interesting.</p><h3>So, what is Function Calling?</h3><p>Function Calling allows an OpenAI model to interact with <strong>your application’s functions, APIs, databases, and external systems</strong>.</p><p>Think of it like giving the AI a toolbox.</p><p>You might give it tools such as:</p><pre>getWeather()<br>getUserDetails()<br>searchProducts()<br>createOrder()<br>processRefund()</pre><p>The AI can decide which tool it needs based on the user’s request.</p><h3>How does it actually work?</h3><p>A simple flow looks like this:</p><pre>User<br> ↓<br>&quot;What&#39;s the weather in Bangalore?&quot;<br> ↓<br>AI Model<br> ↓<br>&quot;I need weather data&quot;<br> ↓<br>getWeather(&quot;Bangalore&quot;)<br> ↓<br>Your API / Function<br> ↓<br>27°C, Cloudy<br> ↓<br>AI Model<br> ↓<br>&quot;It&#39;s 27°C and cloudy in Bangalore.&quot;</pre><p>Notice something important:</p><p><strong>The AI doesn’t execute your function.</strong></p><p>It tells your application:</p><blockquote><em>“I want you to call </em><em>getWeather with </em><em>Bangalore.”</em></blockquote><p>Your application executes it.</p><p>Then you send the result back to the model.</p><p>The model uses that result to generate the final response.</p><h3>A simple example</h3><p>You define a function like:</p><pre>const tools = [<br>  {<br>    type: &quot;function&quot;,<br>    name: &quot;get_weather&quot;,<br>    description: &quot;Get the current weather for a city&quot;,<br>    parameters: {<br>      type: &quot;object&quot;,<br>      properties: {<br>        city: {<br>          type: &quot;string&quot;<br>        }<br>      },<br>      required: [&quot;city&quot;]<br>    }<br>  }<br>];</pre><p>Now the model knows:</p><blockquote><em>“I have access to a tool called </em><em>get_weather.”</em></blockquote><p>User asks:</p><pre>What&#39;s the weather in Bangalore?</pre><p>The model may return a tool call like:</p><pre>{<br>  &quot;name&quot;: &quot;get_weather&quot;,<br>  &quot;arguments&quot;: {<br>    &quot;city&quot;: &quot;Bangalore&quot;<br>  }<br>}</pre><p>Your backend then actually runs:</p><pre>getWeather(&quot;Bangalore&quot;);</pre><p>Suppose your API returns:</p><pre>{<br>  &quot;temperature&quot;: 27,<br>  &quot;condition&quot;: &quot;Cloudy&quot;<br>}</pre><p>You send that result back to the model.</p><p>And finally, the model responds:</p><blockquote><em>“It’s 27°C and cloudy in Bangalore.”</em></blockquote><h3>Why is this powerful?</h3><p>Because now AI isn’t limited to:</p><p><strong>Input → Text</strong></p><p>It becomes:</p><p><strong>Input → Think → Use Tool → Get Data → Take Action → Respond</strong></p><p>That opens up a completely different class of applications.</p><p>For example:</p><p>💳 <strong>FinTech</strong></p><blockquote><em>“Show me my latest transactions.”</em></blockquote><p>→ AI calls your transactions API.</p><p>🛒 <strong>E-commerce</strong></p><blockquote><em>“Find me running shoes under ₹5,000.”</em></blockquote><p>→ AI calls your product search API.</p><p>🎫 <strong>Travel</strong></p><blockquote><em>“Book me a flight to Delhi tomorrow.”</em></blockquote><p>→ AI can interact with your booking system.</p><p>👨‍💻 <strong>Developer tools</strong></p><blockquote><em>“Check whether this deployment is healthy.”</em></blockquote><p>→ AI calls your monitoring API.</p><h3>And this is the foundation of AI Agents</h3><p>This is the part I find most interesting.</p><p>An AI that can only generate text is useful.</p><p>An AI that can <strong>use tools</strong> becomes much more capable.</p><pre>LLM<br> ↓<br>Decides what it needs<br> ↓<br>Calls a tool<br> ↓<br>Gets real-world data<br> ↓<br>Reasons about the result<br> ↓<br>Calls another tool if needed<br> ↓<br>Completes the task</pre><p>That’s the basic idea behind many <strong>AI agents</strong>.</p><p>Function calling is essentially the bridge between the <strong>AI model and your application’s real-world capabilities</strong>. OpenAI describes it as a way for models to interface with external systems and access data outside their training data.</p><h3>The key takeaway</h3><p>Don’t think of an LLM as something that only:</p><blockquote><strong><em>answers questions.</em></strong></blockquote><p>Think of it as something that can:</p><blockquote><strong><em>decide what needs to happen next.</em></strong></blockquote><p>Your application provides the tools.</p><p>The model decides when a tool is useful.</p><p><strong>Your code executes the tool.</strong></p><p>And the model turns the result into a useful response.</p><p>That’s the real power of Function Calling.</p><p>If you’re building AI-powered applications with React, Node.js or TypeScript, <strong>Function Calling is one of the concepts worth learning early.</strong></p><p>Because this is where AI starts moving from:</p><p><strong>“Chat with me”</strong></p><p>to</p><p><strong>“Let me help you get something done.”</strong></p><p>#AI #OpenAI #ArtificialIntelligence #React #JavaScript #TypeScript #WebDevelopment #AIEngineering #SoftwareEngineering</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33355e568a36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Opus 5 couldn’t see its own output — so it built a tool to check its own work.]]></title>
            <link>https://medium.com/@brniranjanhegde/claude-opus-5-couldnt-see-its-own-output-so-it-built-a-tool-to-check-its-own-work-b406541f42e8?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b406541f42e8</guid>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 16:42:44 GMT</pubDate>
            <atom:updated>2026-08-14T16:42:44.483Z</atom:updated>
            <content:encoded><![CDATA[<p>Anthropic shipped it on July 24. A few things worth knowing:</p><p>→ Near-Fable-5 intelligence, at half the price — $5/$25 per million tokens.</p><p>→ On ARC-AGI-3, a benchmark testing how well a model learns totally unfamiliar tasks, it jumped to 30.2%, up from ~7–8% before. Biggest single leap on that leaderboard.</p><p>→ It now has an effort dial (low → max) — you can trade cost for capability per request.</p><p>→ Freshest training data yet, through May 2026.</p><p>→ Guardrails trigger 85% less than Fable 5, with zero score on an internal exploit-vulnerability benchmark.</p><p>But the standout moment: asked to generate a 3D schematic it had no way to actually view, it wrote its own computer vision pipeline just to check its own work. Nobody asked it to.</p><p>That’s the real shift — models that don’t just answer, but notice when they can’t verify the answer, and fix that gap themselves.</p><p>What would you stress-test it on first?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b406541f42e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why AI Forgets Things You Told It Earlier — Even With a Massive Memory]]></title>
            <link>https://medium.com/@brniranjanhegde/why-ai-forgets-things-you-told-it-earlier-even-with-a-massive-memory-2b96a4c433a7?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b96a4c433a7</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[context-window]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 18:59:28 GMT</pubDate>
            <atom:updated>2026-08-12T18:59:28.800Z</atom:updated>
            <content:encoded><![CDATA[<p>A model can technically hold an entire book in its context window and still lose track of something you mentioned a few pages back. That contradiction is worth understanding, because it changes how you should actually use these tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mTEGkCqwY9DB_L2tm8TNnw.png" /></figure><h3>What a Context Window Actually Is</h3><p>Every time you talk to an AI model, everything involved — your prompt, the conversation history, any documents you’ve pasted in — has to fit inside something called a context window. Think of it as the model’s working memory for that single interaction. Once you exceed it, older information starts getting dropped.</p><p>This number has grown at a startling pace. In 2022, GPT-3 topped out around 4,096 tokens — roughly 3,000 words, barely enough for a short article. By 2026, several frontier models ship with context windows of a million tokens or more, enough to hold the full text of a novel like War and Peace with room to spare. Some open-weight models now advertise windows in the tens of millions of tokens.</p><p>On paper, that sounds like the memory problem is solved. In practice, it isn’t — and the reason why comes down to how these models actually process everything in that window.</p><h3>How AI “Reads” Everything at Once</h3><p>Unlike a person reading top to bottom, a language model doesn’t process text sequentially. It uses a mechanism called self-attention, where every single token in the context window is compared against every other token to determine relevance. This is what lets a model connect a pronoun near the end of a long document back to a name mentioned near the beginning — it isn’t remembering in the way we think of memory, it’s recalculating relationships across the entire input, every time it generates a new word.</p><p>This is a genuinely elegant solution to a hard problem. It’s also the source of the limitation.</p><h3>The Cost Nobody Puts on the Spec Sheet</h3><p>Comparing every token to every other token means the computational cost of attention scales quadratically with the length of the input. Double the number of tokens, and the amount of computation involved doesn’t just double — it roughly quadruples.</p><p>This is why a model advertising a ten-million-token window and a model actually using that window well are two very different claims. Processing that much text coherently is enormously expensive, and independent testing consistently shows that the advertised maximum is a ceiling, not a guarantee. Usable, high-accuracy performance often sits at only 60 to 70 percent of the stated limit, and the drop-off tends to get steeper the larger the window gets.</p><h3>The Lost-in-the-Middle Effect</h3><p>Here’s the part that catches most people off guard: even well within a model’s stated limit, not all information is treated equally. Models consistently recall information placed near the beginning and the end of a long input far better than information buried in the middle. Fill a context window with hundreds of pages, and the details most likely to get missed aren’t at the edges — they’re in the center.</p><p>Interestingly, this mirrors something well documented in human memory research. People tend to recall the beginning and end of a long meeting or a long list far better than the middle — a pattern sometimes called the serial position effect. The outcome looks similar in both cases, even though the underlying cause is completely different. Human forgetting comes from the limits of working memory. AI’s version comes from how attention mathematically weighs and represents tokens across a sequence. Same pattern, different mechanism.</p><h3>Capacity Is Not Comprehension</h3><p>This is really the core takeaway. A bigger context window means a model can technically accept more information — it does not mean the model will reason equally well across all of it. Treating a massive context window as a substitute for careful structure — assuming you can dump in hundreds of pages and get reliably accurate recall from anywhere in that dump — is where people run into trouble.</p><p>If you’re working with long documents or long conversations, the practical implication is simple: put the most important information near the start or the end of what you give the model, not buried in the middle. And don’t assume a bigger window automatically means better recall — it often just means more room, not more attention.</p><p>The next time an AI model seems to “forget” something you told it earlier in a long conversation, it’s not necessarily a malfunction. It may simply be a very predictable consequence of where that information happened to land.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b96a4c433a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Want to understand modern AI engineering without getting lost in the math?]]></title>
            <link>https://medium.com/@brniranjanhegde/want-to-understand-modern-ai-engineering-without-getting-lost-in-the-math-81dabdf912da?source=rss-739d2a59a80a------2</link>
            <guid isPermaLink="false">https://medium.com/p/81dabdf912da</guid>
            <category><![CDATA[attention-mechanism]]></category>
            <category><![CDATA[tokenization]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Niranjan B R]]></dc:creator>
            <pubDate>Sun, 09 Aug 2026 18:26:20 GMT</pubDate>
            <atom:updated>2026-08-09T18:26:20.575Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a quick cheat sheet for your tech toolkit:</p><ul><li><strong>LLM</strong>: A neural network trained to predict the next word in a sequence.</li><li><strong>Tokenization</strong>: Breaking text into sub-words (tokens) so the model can grasp linguistic patterns.</li><li><strong>Vectors</strong>: Turning tokens into numerical coordinates so similar meanings cluster together.</li><li><strong>Attention Mechanism</strong>: Factoring in surrounding words to decipher ambiguous terms (e.g., “Apple” the fruit vs. “Apple” the tech giant).</li><li><strong>Self-Supervised Learning</strong>: Training models on raw internet text by masking parts of data and having the model guess the blanks.</li><li><strong>Transformer</strong>: The underlying engine that pairs attention blocks with feed-forward networks to predict next tokens.</li><li><strong>Fine-Tuning</strong>: Customizing a base model with specific Q&amp;As to tailor its tone, behavior, or domain knowledge.</li><li><strong>Few-Shot Prompting</strong>: Including explicit examples directly in the user prompt to guide the output format.</li><li><strong>RAG (Retrieval-Augmented Generation)</strong>: Fetching relevant documents from a database in real time to ground answers in company-specific data.</li><li><strong>Vector Database</strong>: A specialized database designed to efficiently search and compare semantic vector similarity.</li><li><strong>MCP (Model Context Protocol)</strong>: An open standard allowing LLMs to securely query external tools and APIs.</li><li><strong>Context Engineering</strong>: Strategically managing prompt context, chat history, and system instructions to maximize model response quality.</li><li><strong>AI Agents</strong>: Long-running background processes capable of calling APIs and autonomously completing multi-step tasks.</li><li><strong>RLHF (Reinforcement Learning from Human Feedback)</strong>: Guiding models using human ratings (+1 / -1) to reinforce helpful and safe outputs.</li><li><strong>Chain of Thought</strong>: Prompting or training a model to break complex problems into sequential reasoning steps.</li><li><strong>Reasoning Models (LRMs)</strong>: Models (e.g., DeepSeek-R1, OpenAI o1) that spend compute time “thinking” through steps before outputting an answer.</li><li><strong>Multimodal Models</strong>: Models built to natively process and generate text alongside images, audio, or video.</li><li><strong>Small Language Models (SLMs)</strong>: Compact, cost-effective models (3M–300M parameters) focused on domain-specific tasks.</li><li><strong>Distillation</strong>: Training a small “student” model to mimic a large “teacher” model to lower latency and compute costs.</li><li><strong>Quantization</strong>: Compressing a model’s numerical precision (e.g., 32-bit to 8-bit) to drastically reduce memory overhead during inference.</li></ul><p>Reference: <a href="https://www.youtube.com/watch?v=OYvlznJ4IZQ">https://www.youtube.com/watch?v=OYvlznJ4IZQ</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81dabdf912da" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>