<?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 Hardik P on Medium]]></title>
        <description><![CDATA[Stories by Hardik P on Medium]]></description>
        <link>https://medium.com/@hardikfc?source=rss-62d7c9188b73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Hardik P on Medium</title>
            <link>https://medium.com/@hardikfc?source=rss-62d7c9188b73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:23:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hardikfc/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[ Your AI Is Making Things Up. Here’s How to Catch It (and Stop It)]]></title>
            <link>https://medium.com/@hardikfc/your-ai-is-making-things-up-heres-how-to-catch-it-and-stop-it-0b7274e85bf2?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b7274e85bf2</guid>
            <category><![CDATA[hallucinations]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 14:01:02 GMT</pubDate>
            <atom:updated>2026-09-26T14:01:02.974Z</atom:updated>
            <content:encoded><![CDATA[<p><em>It rarely says “I’m not sure.” It just sounds sure.</em></p><p>In 2023, two New York lawyers submitted a court filing full of case law. The cases had names, dates and quotes. <strong>None of them existed.</strong> ChatGPT had invented them, and the judge sanctioned the lawyers.</p><p>Since then, a public database has tracked <strong>more than 2,000 court cases</strong> where AI made-up content ended up in legal filings.</p><p>If you write code with AI, you’ve probably seen smaller versions of this: a method that doesn’t exist, or a config option that was never real. The code looks perfect. It just doesn’t work.</p><p>This is an <strong>AI hallucination</strong>: an answer that sounds right but is false. Here is why it happens, how to spot it, and the prompts that help stop it.</p><h3>1. Why AI makes things up</h3><p>Remember multiple-choice exams? If you didn’t know the answer, you <strong>guessed</strong>. A blank gets zero points; a guess might get lucky.</p><p>OpenAI researchers found AI models learn the same habit. Most tests used to train and score models give nothing for “I don’t know,” so models learn that <strong>guessing pays off</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2oHYrP5R7suwBi3DQXh-w.png" /></figure><p>Both models got about the same number right. But the one that guessed was <strong>wrong 75% of the time</strong>. The one that could say “I don’t know” was wrong only 26% of the time.</p><p><strong>A confident answer is not a correct answer.</strong></p><h3>2. It costs real money</h3><ul><li><strong>Air Canada’s</strong> chatbot invented a refund policy. A tribunal ruled the airline was responsible for what its bot said and had to pay.</li><li><strong>Developers:</strong> a 2025 study found almost <strong>20% of packages</strong> suggested by AI coding models <strong>did not exist</strong>. Attackers can register those fake names and fill them with malware. It’s called <strong>slopsquatting</strong>. A security researcher showed how real the risk is: a harmless test package he published under a hallucinated name got over <strong>30,000 downloads</strong> in three months.</li></ul><h3>3. How to spot a hallucination</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6EBs_3THY6ihEv47mM5WPQ.png" /></figure><p>Quick test: <strong>ask the same question in a new chat.</strong> A different “fact” each time means the AI is guessing.</p><h3>4. Prompts that stop hallucinations</h3><p>You can’t remove hallucinations completely, but you can reduce them. Several of these tips come straight from Anthropic’s own guide for reducing hallucinations in Claude. Copy them and use them.</p><p><strong>1. Allow “I don’t know”</strong></p><p>AI wants to please you. Make not knowing an acceptable answer:</p><pre>If you are not sure about something, say &quot;I don&#39;t know.&quot;<br>Do not guess or make up details.</pre><p><strong>2. Answer only from what you give it</strong></p><p>AI is much better at reading than remembering. Paste the document, log or code, then limit it:</p><pre>Answer using only the text below.<br>If the answer is not in the text, say &quot;Not found in the document.&quot;</pre><p><strong>3. Quote first, then answer</strong></p><p>This forces the AI to find real evidence before it writes:</p><pre>First, quote the exact lines that support your answer.<br>Then give your answer based only on those quotes.</pre><p>If it can’t find a quote, you’ve caught the problem early.</p><p><strong>4. Ask for sources, then click them</strong></p><pre>For each fact, give the source link.<br>If you can&#39;t find a source, mark the fact as [unverified].</pre><p>Always open the links. A fake or broken link is a big red flag.</p><p><strong>5. Ask for confidence levels</strong></p><pre>Label each claim as High, Medium or Low confidence.</pre><p>AI’s confidence labels aren’t always accurate, but they show you where to start checking.</p><p><strong>6. Make it check its own work</strong></p><pre>List 3 questions that could prove your answer wrong.<br>Answer them honestly, then correct your answer if needed.</pre><p>This extra step helps catch mistakes before you rely on the answer.</p><p><strong>7. Don’t ask leading questions</strong></p><p><em>“Why is library X the best choice?”</em> pushes the AI to invent reasons. Ask neutrally instead:</p><pre>Is library X a good choice for this? Give pros, cons and alternatives.</pre><p><strong>8. Use web search for anything recent</strong></p><p>AI only knows what it learned up to a certain date. For news, prices or new library versions, turn on web search or share the link.</p><p><strong>9. Break big tasks into small steps</strong></p><p>One huge prompt leaves more room for gaps and guesses. Small steps are easier to check.</p><h3>5. Extra tips for developers</h3><p><strong>Lock it to your version:</strong></p><pre>We use React 18 and Next.js 14.<br>Only use APIs that exist in these versions.<br>If you&#39;re not sure a method exists, tell me instead of guessing.</pre><p><strong>Check packages before installing:</strong></p><pre>For each package you suggest, give the npm or PyPI link<br>and tell me how widely it is used.</pre><p>Then check it yourself: downloads, age and a real GitHub repo.</p><p><strong>Give it the docs.</strong> Share the official docs page or the actual source file instead of letting it guess the API.</p><p><strong>Run it.</strong> Tests and compilers don’t hallucinate.</p><h3>🎁 Bonus: one prompt to rule them all</h3><p>Add this to ChatGPT’s custom instructions, Claude’s personal preferences or .github/copilot-instructions.md, so it applies to every chat:</p><pre>- If you don&#39;t know or aren&#39;t sure, say so. Never guess.<br>- Don&#39;t invent facts, sources, APIs, packages or numbers.<br>- Base answers on the context I provide when available.<br>- Mark anything you can&#39;t verify as [unverified].<br>- Ask me a question if my request is unclear.</pre><h3>Conclusion</h3><p>AI is like a fast, confident new teammate. Smart and helpful, but it rarely says “I’m not sure” unless you ask.</p><p>So <strong>trust, but verify.</strong> Give it context, let it admit what it doesn’t know, and always check what matters.</p><p>The AI won’t be embarrassed by a wrong answer. You will.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b7274e85bf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Burning Tokens : How I Pick the Right AI Model for Every Coding Task ]]></title>
            <link>https://medium.com/@hardikfc/stop-burning-tokens-how-i-pick-the-right-ai-model-for-every-coding-task-17f93677aa21?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/17f93677aa21</guid>
            <category><![CDATA[cursor]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-token-optimization]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ai-model]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 16:27:25 GMT</pubDate>
            <atom:updated>2026-09-23T16:34:53.326Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Same prompt, same code, 20x difference in the bill..</em></p><p>Since our team started using <strong>Cursor</strong> and <strong>GitHub Copilot</strong> daily, one question keeps coming up: <em>“Why did my usage run out so fast?”</em></p><p>We were sending every request, from renaming a variable to designing a new service, to the most powerful and most expensive model.</p><p>Here is what I learned about model choice, <strong>Auto</strong> vs. <strong>manual</strong> selection, and saving tokens.</p><h3>1. One tool, many models, many prices</h3><p>AI tools charge by <strong>tokens</strong>: the ones you send (<strong>input</strong>) and the ones the model writes back (<strong>output</strong>). Output usually costs 5x or more than input.</p><p><strong>GitHub Copilot</strong> puts models from OpenAI, Anthropic and Google in one model picker. Hover over a model to see its cost. Code completions are included and don’t use credits.</p><p><strong>Cursor</strong> goes further, adding xAI and its own <strong>Composer</strong> model. More choice means more ways to save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dm9sLDojeDTmNFXRpMZ2Cg.png" /></figure><p>The same task can cost <strong>$2.50 or $50</strong> per million output tokens, only because of the model you picked.</p><h3>2. Match the model to the job</h3><p><strong>Most of my daily work does not need the smartest model.</strong></p><p>Commit messages, comments, simple unit tests and renames are easy jobs. A small model does them just as well, and faster. Big models earn their price on architecture, tricky bugs and large refactors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ty07afRwvStHPAQJEvoAKg.png" /></figure><p><strong>Start with the mid-tier model. Move down for boring work, move up only when it struggles.</strong></p><p>A nice trick in Copilot: use the <strong>Plan agent</strong> with a strong model like <strong>Opus</strong> to make the plan, then switch to a cheaper model like <strong>Sonnet</strong> to write the code.</p><h3>3. Auto vs. picking the model yourself</h3><p><strong>Cursor’s Auto mode</strong> picks a model for each request. You can set it to focus on <strong>Cost</strong>, <strong>Balance</strong> or <strong>Intelligence</strong>. Since August 2026, each Auto request is charged at the price of the model it was routed to.</p><p><strong>GitHub Copilot</strong> has Auto too. It looks at the task (reasoning, code complexity, debugging) and picks a model for it. Since June 2026, Copilot bills by tokens used, and Auto gives you a <strong>10% discount</strong> on the model cost compared to picking that same model yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6aoxZLEpsiUtlK-efv_HQ.png" /></figure><p>So which is better? Here is a simple example: one week, <strong>100 coding tasks</strong> (60 simple, 30 medium, 10 hard), priced three ways:</p><ul><li><strong>Top model for everything costs 2.5x more</strong>, and <strong>$18 of the $30</strong> goes to <em>simple</em> tasks.</li><li><strong>Auto is a big improvement</strong> and a good default if you don’t want to think about it. With Copilot’s 10% discount, it gets even closer to manual.</li><li><strong>Manual was the cheapest</strong>, and you know the price <em>before</em> you hit enter. With Auto, you don’t control which model gets your hard task.</li></ul><p><em>(Illustrative numbers: 50K input + 5K output tokens per task, list prices, no caching.)</em></p><p><strong>My take:</strong> use Auto for exploring and mixed small work. Pick manually when you know the task.</p><h3>4. Token optimization tips</h3><p>Choosing the model is half the story. The other half is <strong>how many tokens you send</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N6al9yquaQHhOZOrigOxFA.png" /></figure><p>Every message re-sends the whole conversation. So a chat open all day gets more expensive with every question. Starting a new chat every 5 messages sends <strong>~70% fewer tokens</strong> here.</p><p><strong>1. Start fresh between tasks.</strong> Press Ctrl+N (⌘N on Mac) in Copilot Chat, or open a new chat in Cursor.</p><p><strong>2. Compact long sessions.</strong> Type /compact in Copilot Chat to summarize older messages and free up space.</p><p><strong>3. Be specific.</strong> <em>“Improve this code”</em> makes the AI scan everything. <em>“Add validation to login() in auth.ts”</em> goes straight to the point. Point at the right file with #file in Copilot or @file in Cursor.</p><p><strong>4. Turn down the thinking.</strong> Thinking tokens are billed as output. Keep the thinking effort at default, and raise it only for hard problems like architecture.</p><p><strong>5. Keep your rules file short.</strong> .github/copilot-instructions.md or Cursor rules load into <em>every</em> request. Keep only the essentials.</p><p><strong>6. Disable unused tools.</strong> Every MCP server adds context. Use the <strong>Configure Tools</strong> button in Copilot Chat to turn off what you don’t need.</p><p><strong>7. Plan before you build.</strong> Use the <strong>Plan agent</strong> first. Fixing a plan is cheaper than rewriting code.</p><p><strong>8. Stop early.</strong> Going the wrong way? Hit <strong>Stop</strong> right away.</p><p><strong>9. Don’t paste huge logs.</strong> Grep for the errors and share only those.</p><p><strong>10. Check your usage weekly.</strong> In Copilot, hover over the context window control in chat for session cost, or open the Copilot status dashboard. In Cursor, check the usage dashboard.</p><h3>Conclusion</h3><p>AI coding tools are amazing, but they are not free, and the most expensive model is not always the best choice. The biggest savings come from two simple habits:</p><ol><li><strong>Pick the right model for the job</strong> (or at least let Auto do it, instead of always using the top model).</li><li><strong>Keep your context small</strong> by clearing, compacting, and being specific.</li></ol><p>You don’t have to pick between quality and cost. Use the big model where it matters, and let the small ones handle the rest.</p><p>I hope this makes your AI learning journey more fun! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17f93677aa21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Took My Requests Agent Off My Laptop and on to Azure]]></title>
            <link>https://medium.com/@hardikfc/i-took-my-requests-agent-off-my-laptop-and-onto-azure-bfce6db9b1f5?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfce6db9b1f5</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 21:39:13 GMT</pubDate>
            <atom:updated>2026-09-22T16:55:17.631Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@hardikfc/i-built-a-requests-agent-with-langgraph-mcp-and-a-bunch-of-prompts-5b50c88c9c1b?sharedUserId=hardikfc">Part 1</a> was the agent: LangGraph loop, MCP tools, human in the loop. This article is about getting it to run when I close the laptop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0dpDQyLnqyG591MtPyKtg.png" /></figure><p>Ship a Python FastAPI agent as a Linux <strong>App Service</strong> (Python 3.12). Per-environment settings live in <strong>Azure App Configuration</strong>. Secrets live in <strong>Key Vault</strong>, and App Config stores a <em>reference</em> to the vault secret, never the raw value. <strong>Application Insights</strong> collects traces, so when HITL “does nothing” I can tell whether the request never arrived or the graph never resumed.</p><ul><li>/health returns 200 on the App Service URL</li><li>/chat behaves like local, including session_id handling</li><li>rotating the OpenAI key means “update Key Vault,” not “redeploy the zip”</li><li>a bad deploy never reaches prod, because you never deployed to prod first</li></ul><h3>How I Built It</h3><p>Portal first so you understand the boxes, then have the computer repeat it. Copilot wrote my YAML only after the portal version worked once.</p><ol><li>Create a resource group.</li><li>Create the Linux App Service (Basic SKU is fine) with the startup command below.</li><li>Add Application Insights with defaults.</li><li>Create a Key Vault (RBAC). Grant yourself <em>Secrets Officer</em> and the app identity <em>Secrets User</em>.</li><li>Create the App Config store and grant the identity <em>Data Reader</em>.</li><li>Put non-secrets (model name, MCP URL) in App Config. Put the OpenAI key in Key Vault and add a Key Vault reference in App Config.</li><li>On the App Service, set only bootstrap settings: the App Config endpoint and the environment label.</li><li>Zip deploy from the laptop once and watch the log stream until /health is 200.</li><li>Only then build the pipelines.</li></ol><pre>uvicorn app:create_app --factory --host 0.0.0.0 --port 8000</pre><h3>Where Each Setting Lives</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7LiKJBwubUl8mVNKN1fsw.png" /></figure><p>The app reads the bootstrap settings, loads App Config via its identity, resolves the vault references, <em>then</em> builds the agent. Create the OpenAI client inside the FastAPI factory, not at import time, or you get empty keys and a mysterious crash.</p><p>Keep the App Config JSON in git as templates with placeholders, never live secrets. The MCP URL should differ per environment. To rotate a secret, add a new version and restart the app, since it may have cached the old one.</p><p>If the vault has a firewall, allow trusted Azure services. Otherwise non-secrets load, the reference stays unresolved, and OpenAI returns 401.</p><h3>Application Insights</h3><p>Enable it from the App Service blade. I tracked /chat duration, tool-node exceptions, and custom events at each HITL pause and resume. &quot;The agent ignored me&quot; is usually a new session_id or a restarted instance, and Insights shows both. Log counts, tool name, duration and error type, never payloads containing people&#39;s names.</p><h3>Pipelines</h3><p>I use two, so I can redeploy last week’s green build.</p><ul><li><strong>Build</strong> (PR + main): install, pytest, zip, publish the artifact. Never zip .env or .venv.</li><li><strong>Deploy</strong>: pick an artifact, import the App Config template for that environment, deploy the zip with the startup command, curl /health, and fail the job if it isn&#39;t 200.</li></ul><p>Prod uses an ADO <strong>Environment</strong> with a manual approval. It’s cheap insurance against a bad commit at 11pm. Give the service connection least privilege, meaning deploy rights on those apps and import rights on that store, not Contributor on the subscription. Variable groups hold endpoints and resource names, never the OpenAI key.</p><h3>HITL After Deploy</h3><ul><li><strong>Checkpointer:</strong> in-memory checkpoints die on restart and break with more than one instance. For a demo, use one instance. For anything real, use Redis with the connection string in Key Vault. I set CHECKPOINT_BACKEND=memory in dev and redis in prod before Redis existed, so I wouldn&#39;t pretend prod was safe.</li><li><strong>session_id:</strong> the follow-up POST must reuse the same one. I used a new UUID in a test script and blamed Azure. Azure was fine.</li><li><strong>Timeouts:</strong> App Service has idle limits, so a long-absent human may not resume on in-memory state. Say so in the UI copy.</li></ul><h3>Post-Deploy Checklist</h3><ol><li>/health returns 200.</li><li>Insights shows the request.</li><li>/chat &quot;hi&quot; returns the intro and example questions.</li><li>“Overdue” with no project returns the pause text.</li><li>The same session_id plus project/1042 calls the tool.</li><li>An empty open list triggers the archive yes/no pause.</li><li>“yeah” resumes without calling the tool twice.</li></ol><p>If 4–6 fail and 1 passes, it’s the agent, not Azure. Don’t rebuild the pipeline.</p><p>I hope this makes your AI learning journey more fun! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfce6db9b1f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ I Built a Requests Agent with LangGraph, MCP, and a Bunch of Prompts]]></title>
            <link>https://medium.com/@hardikfc/i-built-a-requests-agent-with-langgraph-mcp-and-a-bunch-of-prompts-5b50c88c9c1b?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b50c88c9c1b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 21:38:26 GMT</pubDate>
            <atom:updated>2026-09-21T21:41:11.847Z</atom:updated>
            <content:encoded><![CDATA[<p>This time I wanted a small team tool I could actually talk to. In this article, I will walk you through how I built an <strong>Data Retrieval Agent</strong>, step by step. This agent is integrated with an <strong>Orchestrator</strong> which calls this agent and few other agents too.</p><p>Concept to a chat loop that looks up real request records, remembers the session, and pauses when it should not guess.</p><p>This is part 1. <a href="https://medium.com/@hardikfc/i-took-my-requests-agent-off-my-laptop-and-onto-azure-bfce6db9b1f5">Part 2</a> is how I shoved it onto Azure. Don’t start there. Get the loop working on your laptop first or you will debug App Service logs for a problem that was always in the prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UCbXbTjMO8leGZh2o-0KGA.png" /></figure><p><strong>Stack, so you can decide if this is your afternoon:</strong></p><ul><li><strong>Language / runtime:</strong> Python 3.12</li><li><strong>Agent loop:</strong> <a href="https://langchain-ai.github.io/langgraph/">LangGraph</a></li><li><strong>Tools:</strong> <a href="https://modelcontextprotocol.io/">MCP</a> (Model Context Protocol) — a tiny local server, not a public one</li><li><strong>Model:</strong> OpenAI gpt-4o-mini via langchain-openai (Groq / local Ollama also work if they speak the OpenAI chat + tools API)</li><li><strong>API layer:</strong> FastAPI + Uvicorn</li><li><strong>Config:</strong> python-dotenv</li><li><strong>Editor:</strong> VS Code + Copilot (Cursor or Claude in the browser work the same way)</li><li><strong>Backend data:</strong> a JSON file standing in for a real requests API</li></ul><h3>The Idea</h3><p>Think of a shared list: title, status, who it’s assigned to, who opened it, due date, which project it belongs to. People already type this stuff into a tracker. The agent’s job is to let you ask in English instead of clicking five filters.</p><p>You “win” when you can say things like:</p><ul><li>what did I open last week</li><li>anything assigned to me that’s still open</li></ul><p>…and the answer matches the data. Not “vibes.” The data.</p><p>You fail when:</p><ul><li>it invents a request that doesn’t exist</li><li>it picks a project for you instead of asking</li><li>it answers “nothing found” because it looked in the wrong place and never asked</li></ul><h3>Getting your OpenAI key</h3><p>You need a model. I used OpenAI’s API.</p><ol><li>Sign in at platform.openai.com</li><li>Profile → API keys → Create new secret key. I named mine data-retrieval-agent-local</li><li>Copy it now. sk-… shows once</li><li>Billing: add a little credit, set a monthly cap so a runaway loop can’t surprise you</li></ol><p>I used gpt-4o-mini for the loop. If you don&#39;t want to pay, use a free model. The agent code mostly just changes base_url and the model name.</p><pre># .env - local only<br>OPENAI_API_KEY=sk-REDACTED<br>OPENAI_MODEL=gpt-4o-mini<br>OPENAI_BASE_URL=<br>REQUESTS_MCP_URL=http://localhost:8001/mcp<br>MY_NAME=hardikfc_dev<br>TIMEZONE=America/New_York</pre><h3>How to create it</h3><p>VS Code plus Copilot. Python 3.12. I didn’t write it from scratch — Copilot did most of the typing, I did the debugging.</p><pre>pip install langgraph langchain-openai mcp httpx python-dotenv fastapi uvicorn</pre><p>How the prompts evolved:</p><ol><li>one python file, openai chat loop, read the key from .env, type quit to exit. don’t hardcode anything</li><li>add a get_requests tool that reads a local requests.json (id, title, status, assignee, opened_by, due_date, project_id). model decides when to call it</li><li>rewrite as a langgraph, agent node + tools node, loop until there are no tool calls</li><li>wrap the json behind a tiny MCP server with a get_requests tool, agent calls MCP not the file. also a discover_tools that lists what’s on the server</li><li>keep conversation in graph state, session_id so two chats don’t mix. if i send a new question on the same session, append it, don’t ignore it</li><li>system prompt: only answer from tool results. if the tool errored, say so. never invent request ids or people</li><li>pass today + timezone into the prompt — “overdue” and “last week” are wrong without that</li><li>if project_id is missing, PAUSE and ask. parse something like project/123. do not guess, do not call get_requests until you have it. pause BEFORE the tool runs so resume doesn’t call it twice</li><li>if get_requests comes back empty, pause and ask if i also want archived/closed requests. yes/no. handle yeah, yep, nah, skip — if it’s nonsense, ask again, don’t treat it as no</li><li>the payload is huge, trim it before the model sees it. keep title, status, due, assignee, opened_by. if we truncate, keep “mine” and soonest-due at the front</li><li>match my username against assignee and opened_by — tag each row assigned_to_me / opened_by_me so the model isn’t fuzzy-matching in prose</li><li>fastapi /chat with session_id. if a pause is pending, the next post with the same session_id resumes, it does not start a new question</li><li>unit tests for name matching, yes/no parsing, empty result detection, and the interrupt/resume path</li><li>first reply if they just say hi: who you are, 3 example questions, mention you’ll ask for a project id if not given</li></ol><p>I ran it after almost every prompt. When it broke I pasted the traceback, not a new essay.</p><h3>Human in the loop</h3><p>What I wanted: the graph <strong>interrupts</strong>. State is checkpointed under the session id, my reply is a resume, and the waiting tool call runs once.</p><p>Two separate interrupts:</p><ul><li><strong>Missing project.</strong> If the project wasn’t provided, stop and ask. Parse the free text. If you still can’t parse it, ask again rather than calling the tool with garbage.</li><li><strong>Empty list on the default filter.</strong> Zero rows often means the work is archived, not that the project is empty. Ask: check closed/archived too? If yes, re-call with include_closed=true. If no, it&#39;s actually empty.</li></ul><p>Pause <strong>before</strong> the tool runs, or at least don’t re-run a completed call on resume — resume replays the node you stopped in. Fine for a read, not fine if your tool ever writes.</p><h3>Running it locally</h3><pre>python -m uvicorn app:create_app --factory --host 0.0.0.0 --port 7073</pre><pre>Requests Agent. Try:<br>- what&#39;s overdue on this project<br>- assigned to me, still open<br>- what did I open last week</pre><pre>you &gt; whats overdue<br>agent &gt; Which project? Use project/{id} or just the id.<br>you &gt; 1042<br>[tool] get_requests(project_id=1042, include_closed=false) -&gt; 3 items<br>Three open and past due: &quot;Vendor contract review&quot; (Tue, you), …<br>you &gt; anything in the archive for the same thing<br>agent &gt; I can include closed/archived requests. Want me to? (yes/no)<br>you &gt; yeah<br>[tool] get_requests(project_id=1042, include_closed=true) -&gt; 11 items<br>…</pre><p>If /health isn&#39;t green, don&#39;t start prompting the model — you&#39;re not debugging the agent yet.</p><p>I have added <a href="https://medium.com/@hardikfc/i-took-my-requests-agent-off-my-laptop-and-onto-azure-bfce6db9b1f5">part 2 of this article showing how to deploy this to cloud from your local</a>.</p><p>I hope this makes your AI learning journey more fun! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b50c88c9c1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js Is Replacing React.js as the Go-To Choice for Developers ‍]]></title>
            <link>https://medium.com/@hardikfc/next-js-is-replacing-react-js-as-the-go-to-choice-for-developers-52c628ffb1ee?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/52c628ffb1ee</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 23:01:41 GMT</pubDate>
            <atom:updated>2025-09-15T23:01:41.992Z</atom:updated>
            <content:encoded><![CDATA[<p>We were starting a new project in our team, and while discussing the tech stack something new came up to us. I have been working with React.js for last 4 years. Since I started my journey in UI development, I have used Angular, and React so far.</p><p>In all previous project which we started from scratch in last 2 years, we have been using React.js. The reason was simple, Its easy to get started with React, learning curve is easy, and once you start using React for one project you feel more confident to use that for another project.</p><p>When we gave a thought to use Next.js for our next project we started exploring modern development trends. We noticed that more and more teams are using Next.js. You have probably noticed same industry trend as well.</p><p>Why is this happening. Let’s find.</p><h3>What is Next.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbLXr-EjnDdHr9RISW6J_Q.png" /></figure><p>Next.js is a full stack framework that provided server side rendering, capability to handle file based routing, built in performance optimization. and more importatnly, Next.js is built on top of React.js.</p><p>With server side rendering capabilities, it you want to create a single project for both frontend and backend, you can do that using Next.js. That server side rendering is a big factor to SEO optimization.</p><p>It brings the best of two, powerful React UI capabilities with out of the box optimization for performance.</p><p>overall, I see Next.js as the powerful version of React.js. It has all the valid reason to choose over react.js</p><h3>Why choose Next.js</h3><p>Next.js has already proved to be successful in modern day web development. More and more tech companies are adopting Next.js.</p><p>It gives out of box capabilities which react doesn’t have today. Its very imporatant for rapid build and deployment to production environment.</p><p>It has a great eco system. It is moving fast with constant updates, documentations and growing community.</p><p>Next.js ‘s capability of server side rendering improves its SEO capabilities, as when SEO crawler moves, it can read the content of page. It has file based URL routing, which produces clean, semantic URLs preferred by search engines</p><p>Overall when using Next.js, there is nothing to lose over React.js, you all getting additional functionality along with existing React.js.</p><p>Overall, I think react will always be the foundation, but Next.js is how React apps meant to be built in production.</p><p>If your existing project has React.js or you are starting projects with Create React App, consider Next.js as your stack. Hope this gives you a reason to look for adopting a new stack in your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52c628ffb1ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Multiplayer Space Game in Minutes Using Github Copilot]]></title>
            <link>https://medium.com/@hardikfc/i-built-a-multiplayer-space-game-in-minutes-using-github-copilot-aeb148ac59f6?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeb148ac59f6</guid>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[github-copilot]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Tue, 09 Sep 2025 03:30:57 GMT</pubDate>
            <atom:updated>2025-09-09T03:30:57.514Z</atom:updated>
            <content:encoded><![CDATA[<p>Game development is something that requires weeks of coding, deep programming knowledge, and lots of debugging. With today’s AI tools, you can literally create a fun, playable game in minutes.</p><p>In this article, I will walk you through how I created a 2-player space game using just simple prompts in Copilot. You will see how step by step, with just a few instructions, I transformed a simple concept into a full interactive game.</p><p><strong>The Game Idea : </strong>I wanted to create a 2 player space themed game where 2 players race against each other. They navigate through obstacles and reach to a destination, Whoever reaching the first to the destination wins the game.</p><p>If any player crashes to an object then the player is eliminated from game.</p><p><strong>How to create it</strong> : I used my visual studio code to create this game and Github copilot plug — in inside my VS code to give prompts. You can give prompt directly on web and copy paste code to a html file.</p><p>I didn’t write game from scratch, instead I game prompt to generate game. I gave series of prompts refining the game visuals and mechanics. This is how evolution went:</p><ol><li>Create a game in Html canvas. The game theme is space. There will be 2 players playing the game. player has a space craft. He need to pass through space object and reach to the end point. Who ever reaches the first is considered winner. Once any one player reaches, end the game and show which player won. One players will navigate through arrow keys, another player will navigate using a,s,d,w keys</li><li>Update it to make start point at bottom and end point at top of screen.</li><li>Make this difficult by adding more object in between and make them also moving.</li><li>Update code in a way that if the moving object touches the space craft the player is out</li><li>Make spacecraft object look more like a plane?✈️ ( At this point I downloaded small png file and saved to my local folder )</li><li>Make icon more like a star an planet objects</li><li>Make change to show destination point as a earth planet 🌍</li><li>Update code to include 2 more differnt type of object along with star and planet, that would be satellite and asteroids.</li><li>Update code to ensure that there is no object around the planes when game starts</li><li>Update code to make every object type moving at different speeds</li><li>Make the background black</li><li>Add a message that says use A, S, D, F and arrow key to move space craft, pause the game for 5 seconds at start and countdown from 5 to 1, and launch.</li></ol><p>Here is how final version of game looks like. What’s powerful here is not just the game itself, but how fast it came together.</p><p>With just a series of prompts, AI can act like your personal game developer.</p><p>Here is how the game looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Odq9L4L_wHAmMgIodWR4sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gUwZMhnJOR3V1spDLJQew.png" /></figure><p>Here is the entire code, just add a few images to code and it will be all running like this.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Space Race Game&lt;/title&gt;<br>    &lt;style&gt;<br>        body { margin: 0; overflow: hidden; }<br>        canvas { display: block; background: black; }<br>        #message, #winner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.7); color: white; padding: 20px; display: none; text-align: center; }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;canvas id=&quot;gameCanvas&quot;&gt;&lt;/canvas&gt;<br>    &lt;div id=&quot;message&quot;&gt;Use keys A, S, D, F and arrow keys to move spacecraft.&lt;br&gt;Game starts in &lt;span id=&quot;countdown&quot;&gt;5&lt;/span&gt; seconds...&lt;/div&gt;<br>    &lt;div id=&quot;winner&quot;&gt;&lt;/div&gt;<br>    &lt;script&gt;<br>        const canvas = document.getElementById(&#39;gameCanvas&#39;);<br>        const ctx = canvas.getContext(&#39;2d&#39;);<br>        canvas.width = window.innerWidth;<br>        canvas.height = window.innerHeight;<br><br>        const player1 = { x: canvas.width / 2 - 100, y: canvas.height - 60, width: 50, height: 50, color: &#39;blue&#39;, controls: { up: &#39;ArrowUp&#39;, down: &#39;ArrowDown&#39;, left: &#39;ArrowLeft&#39;, right: &#39;ArrowRight&#39; }, active: true, image: new Image() };<br>        const player2 = { x: canvas.width / 2 + 50, y: canvas.height - 60, width: 50, height: 50, color: &#39;red&#39;, controls: { up: &#39;w&#39;, down: &#39;s&#39;, left: &#39;a&#39;, right: &#39;d&#39; }, active: true, image: new Image() };<br>        player1.image.src = &#39;plane1.png&#39;;<br>        player2.image.src = &#39;plane2.png&#39;;<br>        const players = [player1, player2];<br>        const obstacles = [];<br>        const endPoint = { x: canvas.width / 2 - 25, y: 0, width: 50, height: 50, image: new Image() };<br>        endPoint.image.src = &#39;earth.png&#39;;<br>        let gameOver = false;<br><br>        function init() {<br>            // Create some obstacles (stars, planets, satellites, and asteroids)<br>            for (let i = 0; i &lt; 7; i++) {<br>                let obstacle;<br>                do {<br>                    obstacle = { x: Math.random() * canvas.width, y: Math.random() * canvas.height, width: 30, height: 30, dx: (Math.random() - 0.5) * 2, dy: (Math.random() - 0.5) * 2, type: &#39;star&#39;, image: new Image() };<br>                } while (isNearPlayers(obstacle));<br>                obstacles.push(obstacle);<br><br>                do {<br>                    obstacle = { x: Math.random() * canvas.width, y: Math.random() * canvas.height, width: 50, height: 50, dx: (Math.random() - 0.5) * 1.5, dy: (Math.random() - 0.5) * 1.5, type: &#39;planet&#39;, image: new Image() };<br>                } while (isNearPlayers(obstacle));<br>                obstacles.push(obstacle);<br><br>                do {<br>                    obstacle = { x: Math.random() * canvas.width, y: Math.random() * canvas.height, width: 40, height: 40, dx: (Math.random() - 0.5) * 3, dy: (Math.random() - 0.5) * 3, type: &#39;satellite&#39;, image: new Image() };<br>                } while (isNearPlayers(obstacle));<br>                obstacles.push(obstacle);<br><br>                do {<br>                    obstacle = { x: Math.random() * canvas.width, y: Math.random() * canvas.height, width: 60, height: 60, dx: (Math.random() - 0.5) * 1, dy: (Math.random() - 0.5) * 1, type: &#39;asteroid&#39;, image: new Image() };<br>                } while (isNearPlayers(obstacle));<br>                obstacles.push(obstacle);<br>            }<br>            obstacles.forEach(obstacle =&gt; {<br>                if (obstacle.type === &#39;star&#39;) {<br>                    obstacle.image.src = &#39;star.png&#39;;<br>                } else if (obstacle.type === &#39;planet&#39;) {<br>                    obstacle.image.src = &#39;planet.png&#39;;<br>                } else if (obstacle.type === &#39;satellite&#39;) {<br>                    obstacle.image.src = &#39;satellite.png&#39;;<br>                } else if (obstacle.type === &#39;asteroid&#39;) {<br>                    obstacle.image.src = &#39;asteroid.png&#39;;<br>                }<br>            });<br>            showInstructions();<br>        }<br><br>        function isNearPlayers(obstacle) {<br>            const safeDistance = 100;<br>            return players.some(player =&gt; {<br>                return Math.abs(obstacle.x - player.x) &lt; safeDistance &amp;&amp; Math.abs(obstacle.y - player.y) &lt; safeDistance;<br>            });<br>        }<br><br>        function showInstructions() {<br>            const messageDiv = document.getElementById(&#39;message&#39;);<br>            const countdownSpan = document.getElementById(&#39;countdown&#39;);<br>            messageDiv.style.display = &#39;block&#39;;<br>            let countdown = 5;<br>            const countdownInterval = setInterval(() =&gt; {<br>                countdown--;<br>                countdownSpan.innerText = countdown;<br>                if (countdown === 0) {<br>                    clearInterval(countdownInterval);<br>                    messageDiv.innerText = &#39;Launch!&#39;;<br>                    setTimeout(() =&gt; {<br>                        messageDiv.style.display = &#39;none&#39;;<br>                        gameLoop();<br>                    }, 1000);<br>                }<br>            }, 1000);<br>        }<br><br>        function gameLoop() {<br>            if (gameOver) return;<br>            ctx.clearRect(0, 0, canvas.width, canvas.height);<br>            update();<br>            draw();<br>            requestAnimationFrame(gameLoop);<br>        }<br><br>        function update() {<br>            players.forEach(player =&gt; {<br>                if (!player.active) return;<br><br>                if (player.controls.upPressed &amp;&amp; player.y &gt; 0) player.y -= 5;<br>                if (player.controls.downPressed &amp;&amp; player.y &lt; canvas.height - player.height) player.y += 5;<br>                if (player.controls.leftPressed &amp;&amp; player.x &gt; 0) player.x -= 5;<br>                if (player.controls.rightPressed &amp;&amp; player.x &lt; canvas.width - player.width) player.x += 5;<br><br>                // Check if player reached the end point<br>                if (player.x + player.width &gt; endPoint.x &amp;&amp; player.x &lt; endPoint.x + endPoint.width &amp;&amp;<br>                    player.y &lt; endPoint.y + endPoint.height) {<br>                    gameOver = true;<br>                    document.getElementById(&#39;winner&#39;).innerText = `${player.color.toUpperCase()} Player Wins!`;<br>                    document.getElementById(&#39;winner&#39;).style.display = &#39;block&#39;;<br>                }<br><br>                // Check for collisions with obstacles<br>                obstacles.forEach(obstacle =&gt; {<br>                    if (player.x &lt; obstacle.x + obstacle.width &amp;&amp;<br>                        player.x + player.width &gt; obstacle.x &amp;&amp;<br>                        player.y &lt; obstacle.y + obstacle.height &amp;&amp;<br>                        player.y + player.height &gt; obstacle.y) {<br>                        player.active = false;<br>                    }<br>                });<br>            });<br><br>            // Update obstacles<br>            obstacles.forEach(obstacle =&gt; {<br>                obstacle.x += obstacle.dx;<br>                obstacle.y += obstacle.dy;<br><br>                // Bounce off walls<br>                if (obstacle.x &lt; 0 || obstacle.x + obstacle.width &gt; canvas.width) obstacle.dx *= -1;<br>                if (obstacle.y &lt; 0 || obstacle.y + obstacle.height &gt; canvas.height) obstacle.dy *= -1;<br>            });<br><br>            // Check if all players are out<br>            if (players.every(player =&gt; !player.active)) {<br>                gameOver = true;<br>                document.getElementById(&#39;winner&#39;).innerText = `All players are out!`;<br>                document.getElementById(&#39;winner&#39;).style.display = &#39;block&#39;;<br>            }<br>        }<br><br>        function draw() {<br>            // Draw players<br>            players.forEach(player =&gt; {<br>                if (!player.active) return;<br>                ctx.drawImage(player.image, player.x, player.y, player.width, player.height);<br>            });<br><br>            // Draw obstacles<br>            obstacles.forEach(obstacle =&gt; {<br>                ctx.drawImage(obstacle.image, obstacle.x, obstacle.y, obstacle.width, obstacle.height);<br>            });<br><br>            // Draw end point (Earth)<br>            ctx.drawImage(endPoint.image, endPoint.x, endPoint.y, endPoint.width, endPoint.height);<br>        }<br><br>        window.addEventListener(&#39;keydown&#39;, (e) =&gt; {<br>            players.forEach(player =&gt; {<br>                if (e.key === player.controls.up) player.controls.upPressed = true;<br>                if (e.key === player.controls.down) player.controls.downPressed = true;<br>                if (e.key === player.controls.left) player.controls.leftPressed = true;<br>                if (e.key === player.controls.right) player.controls.rightPressed = true;<br>            });<br>        });<br><br>        window.addEventListener(&#39;keyup&#39;, (e) =&gt; {<br>            players.forEach(player =&gt; {<br>                if (e.key === player.controls.up) player.controls.upPressed = false;<br>                if (e.key === player.controls.down) player.controls.downPressed = false;<br>                if (e.key === player.controls.left) player.controls.leftPressed = false;<br>                if (e.key === player.controls.right) player.controls.rightPressed = false;<br>            });<br>        });<br><br>        init();<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>I hope this makes your AI learning journey more fun !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeb148ac59f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Code Assistant : CoPilot Vs Cursor]]></title>
            <link>https://medium.com/@hardikfc/ai-code-assistant-copilot-vs-cursor-9751d90a08bb?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/9751d90a08bb</guid>
            <category><![CDATA[cursor-ai]]></category>
            <category><![CDATA[ai-code-assistant]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 23:01:35 GMT</pubDate>
            <atom:updated>2025-09-09T03:33:03.716Z</atom:updated>
            <content:encoded><![CDATA[<h3>CoPilot Vs Cursor : Which AI Tool Actually Makes Coding Easier?</h3><p>Our company recently rolled out Cursor for developers.<br>since I have been using Copilot for over a year, I got chance to work with both tools. In this post, I want to share my personal experience with both of these tools, what works well and which s better over the other.</p><p>Also, it matters on how you code and use cases. however as someone who works regularly across both backend and frontend, using Visual Studio 2022 and VS Code, I think many developers will relate to what I have found.</p><ol><li>Introduction — What are these tools?</li></ol><p><strong>Github Copilot:</strong> <br>Copilot has been around for a while now, and chances are you would already have used it. It is an AI pair programmer assistant directly integrated to editors like VS Code, and Visual Studio. It offers real time code suggestions as you type, and it is helpful for asking questions and generating small code snippets.</p><p><strong>Cursor:<br></strong>Cursor is newer than copilot. It’s a AI first code editor built on top of VS Code. Cursor itself feels like working in visual studio with AI superpowers. It integrates with models like GPT-4 and Claude, and in my experience, Claude is the best models currently available for coding.</p><p><strong>2. Experience</strong></p><p><strong>Github Copilot: <br></strong>Copilot works really well for inline code suggestions. When I am working in Visual Studio, it helps fill in functions, create boilerplate code, and even suggests potential exception handling. The Copilot Chat feature is helpful for debugging or rewriting smaller blocks of code.</p><p>However there are some limitations, that you have to provide the proper context to copilot. If you don’t provide proper context, when working with larger architecture, Copilot can make incorrect assumptions.</p><p><strong>Cursor:<br></strong>Using Cursor feels like having a conversation with your codebase. Cursor automatically understands context of full project. You don’t have to explain everything, and it figures out how things are connected.</p><p>For example, you can use cursor to find all instances of a variable across files, or convert a function into a reusable, generic one. It does that very well. Experience with cursor is more interactive, and it feels like true AI pair programming.</p><p>These both are amazing tools, but cursor feels superior for the developer as it has been built with AI first approach.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9751d90a08bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading Function App From .NET 6 In-Process to .NET 8 Isolated]]></title>
            <link>https://medium.com/@hardikfc/upgrading-function-app-from-net-6-in-process-to-net-8-isolated-17c33dc64b10?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/17c33dc64b10</guid>
            <category><![CDATA[azure-function-app]]></category>
            <category><![CDATA[net8]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 22:01:17 GMT</pubDate>
            <atom:updated>2025-09-09T02:41:06.293Z</atom:updated>
            <content:encoded><![CDATA[<h3>Upgrading Function App From .NET 6 In-Process to .NET 8 Isolated♨️</h3><p>Recently I upgraded our Azure Functions from .NET 6 In-Process to .NET 8 Isolated. This did bring many benefits, including enhanced performance, features and flexibility take advantage of .NET 8’s capabilities.</p><p>This article walks you through the essential steps, prerequisites, and important knowledge on upgrading.</p><h3>Pre-Requisites and Knowledge</h3><p><strong>Understanding In-Process vs Isolated Function Apps:</strong></p><ul><li><strong>Isolated</strong>: In this model, your function app runs in its own process separate from the Azure Functions runtime. This provides isolation for better security and more control over the environment, particularly useful for managing dependencies and configurations independently of the runtime.</li><li><strong>In-Process</strong>: In this model, the Azure Functions runtime runs in the same process as your application. This means your function app and the runtime share the same environment.</li></ul><p>I have written a separate article on more detailed knowledge on<strong> InProcess</strong> vs<strong> Isolated</strong> worker model — <a href="https://medium.com/@hardikfc/azure-functions-inprocess-and-isolated-worker-models-5ee578f56f54">Azure Functions : InProcess and Isolated Worker Models</a>.</p><p><strong>Azure Functions Tools</strong></p><h3>Azure Functions Tools</h3><p>Ensure you have the latest version of Azure Functions Tools for Visual Studio or the Azure Functions Core Tools installed.</p><p>You can install it from here. <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&amp;pivots=programming-language-csharp#install-the-azure-functions-core-tools">Azure Functions Core Tools</a></p><h3>Backup existing function app code:</h3><p>Before making any changes, always back up your existing function app, we created a new instance of function app on Azure temporarily and made it running until the time upgrade was completed. This will ensure that you can restore the previous state if anything goes wrong during the upgrade.</p><h3>Steps to Upgrade</h3><h3>Step 1: Create a New Isolated Function App Project</h3><p>The first thing you’ll need to do is create a new Azure Functions project that targets .NET 8 and uses the Isolated Worker model.</p><p>While creating the function app make sure you select .NET 8 as the target framework. When prompted, choose the <strong>Isolated Worker model</strong>.</p><p>The project template for .NET 8 will automatically configure the isolated runtime, meaning you no longer need to run the functions in-process.</p><h3>Step 2: Migrate Code to the Isolated Model</h3><p>The biggest challenge in upgrading is to refactor your code to be compatible with the isolated model. While much of the code remains the same, there are several key areas where changes are required.</p><p><strong>2.1. Modify the Program.cs File</strong></p><p>In the isolated model, the configuration setup is slightly different. In .NET 6 In-Process apps, you would typically use the <strong>startup.cs </strong>or <strong>program.cs</strong> file to configure services. However, in the Isolated model, the setup occurs directly in <strong>Program.cs</strong>.</p><pre>using Microsoft.Extensions.Hosting;<br>using Microsoft.Extensions.DependencyInjection;<br>using Azure.Functions.Worker;<br>using Azure.Functions.Worker.Extensions.Http;<br><br>var host = new HostBuilder()<br>    .ConfigureFunctionsWorkerDefaults()<br>    .ConfigureServices(services =&gt;<br>    {<br>        services.AddSingleton&lt;IServiceName1, ServiceName1&gt;(); <br>    })<br>    .Build();<br><br>await host.RunAsync();</pre><h4>2.2. Update Function Signature</h4><p>In .NET 6 In-Process, your function methods may have signatures similar to this:</p><pre>public static async Task Run([HttpTrigger] HttpRequestMessage req, ILogger log)</pre><p>For the isolated worker model, the method signature changes slightly. It now accepts <strong>FunctionContext</strong> for logging and other function runtime interactions:</p><pre>public static async Task Run([Function(&quot;FunctionName1&quot;)] FunctionContext context)<br>{<br>    var logger = context.GetLogger(&quot;FunctionName1&quot;);<br>    logger.LogInformation(&quot;FunctionName1 executed&quot;)<br>}</pre><h3>Step 3: Update Dependencies</h3><p>In .NET 8, the Azure Functions SDK and related libraries have undergone changes. You will need to update the NuGet packages in your project to reflect these changes.</p><h3>Step 4: Test Locally</h3><p>Once you have updated the project files and migrated the code, it’s time to test the function locally.</p><p>Make sure all of your functions endpoints work as expected. If you have not installed the Azure Function core tools you may see error. If needed you can install the <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&amp;pivots=programming-language-csharp#install-the-azure-functions-core-tools">function App core tools here</a>.</p><h3>Step 5: Deploy to Azure</h3><p>After successful local testing, we will deploy the updated function app to Azure.</p><p>If you are connected to Azure subscription, just right-click on your project in Visual Studio and select Publish.</p><p>Choose your target Azure Function App or you can create a new one in the Azure portal.</p><p>Deploy the updated function app.</p><p>Upgrading from .NET 6 In-Process to .NET 8 Isolated for your Azure Functions app provides many advantages around security and performance.</p><p>Migration process requires code refactoring, dependency management, and local testing, it ultimately gives you a more robust and scalable Azure Function app.</p><p>By following the steps outlined in this article, you should be able to perform the upgrade and take full advantage of .NET 8’s new features. Hope this helps you when upgradig your application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17c33dc64b10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Functions : InProcess and Isolated Worker Models]]></title>
            <link>https://medium.com/@hardikfc/azure-functions-inprocess-and-isolated-worker-models-5ee578f56f54?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ee578f56f54</guid>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[azure-function-app]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Sun, 06 Jul 2025 19:46:59 GMT</pubDate>
            <atom:updated>2025-07-06T19:46:59.136Z</atom:updated>
            <content:encoded><![CDATA[<h3>Azure Functions : InProcess and Isolated Worker Models</h3><p>Azure Functions is a popular compute service that lets you run code in response to events. The service allows to execute small blocks of code, known as functions, triggered by events like HTTP requests, messages in queues, or updates in databases.</p><p>For Azure Functions, we can choose between two main execution models: the <strong>InProcess</strong> model and the <strong>Isolated</strong> model. Each model offers different trade-offs in terms of performance, and complexity.</p><p>We recently did the .Net upgrade of our function app and during that we also updated the worker model from <strong>InProcess</strong> model to I<strong>solated </strong>model. I want to share my knowledge gained during this.</p><p>I will explain their key benefits, prerequisites, and how to choose the right one for your use case.</p><ol><li><strong>InProcess Worker Model</strong></li></ol><p>The InProcess model is the default execution model for Azure Functions. In this model, the function code runs within the same process as the Azure Functions runtime.</p><p>In the InProcess Model the function code and the Azure Functions runtime run within the same process. This means there is no separation between the them. Function code directly interacts with the runtime environment, sharing memory and other resources.</p><p>The key Benefits of the InProcess Model is that, since the function runs in the same process as the Azure Functions runtime, there is minimal overhead. This leads to better performance as there is no need for inter-process communication.</p><p>The InProcess model is easier to configure and manage. Functions are tightly integrated with the Azure Functions runtime, which makes it easier to use built-in services like logging, configurations, and bindings.</p><p>This model is easier for local development and debugging since your function runs in the same environment as the Azure Functions host.</p><p><strong>Framework:</strong> You can use .NET Core or .NET Framework for function development. The InProcess model primarily supports functions written in C# or other .NET languages.</p><p>2<strong>. Isolated Worker Model</strong></p><p>The Isolated worker model provides more flexibility, It allows your function code to run in a completely isolated process from the Azure Functions runtime. The function code and the runtime are executed in separate processes. This means they do not share memory or resources.</p><p>Communication between the function code and the Azure Functions runtime happens through an API. This allows you to have more control over how your function behaves.</p><p>The Key benefit of the Isolated model is that is helps you to isolate your code for security, compliance, or customization reasons. In this model, you can include custom libraries and dependencies that may not be supported in the InProcess model. This gives you more flexibility in terms of third-party libraries and frameworks.</p><p>The Isolated model provides more control over the lifecycle of your functions. You can customize the environment and behavior more than in the InProcess model.</p><p><strong>Framework:</strong> You must use the .Net 5+ in order to use the Isolated model. This is especially beneficial if you want to leverage the new features and capabilities of the latest .NET framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hi7FRg9C_R__YVbslnnpgQ.png" /><figcaption>Comparision between InProcess and Isolated worker models</figcaption></figure><p>Both InProcess and Isolated worker models in Azure Functions have their unique advantages, If you need more control, isolation, or the flexibility to use custom dependencies, the <strong>Isolated model </strong>is the option. If you need simplicity and framework version is older than .Net 5, inProcess model is the option.</p><p>Hope this helps to decide the better worker model for your function app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ee578f56f54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshoot missing telemetry in Azure Application Insights using .Net 6.0]]></title>
            <link>https://medium.com/@hardikfc/troubleshoot-missing-telemetry-in-azure-application-insights-using-net-6-0-e2334b24075?source=rss-62d7c9188b73------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2334b24075</guid>
            <category><![CDATA[azure-application-insight]]></category>
            <category><![CDATA[net6]]></category>
            <dc:creator><![CDATA[Hardik P]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 22:34:24 GMT</pubDate>
            <atom:updated>2023-08-09T22:39:44.219Z</atom:updated>
            <content:encoded><![CDATA[<h3>Troubleshoot missing telemetry in Azure Application Insights using .Net 6.0</h3><p><strong>Azure Application Insights </strong>is a powerful tool provided by Microsoft for monitoring and diagnosing the performance and availability of applications. However, like any technology, it can sometimes present challenges, especially when integrating with your application. The challenge is mainly due to the way how it works. Refer below diagram from Microsoft learn website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CoUIycYEOeh8-mlF.png" /></figure><p>so, if your application telemetry doesn’t show in Azure portal, error might be occurring at any stage.</p><p>Recently I came across issues while configuring Application insights into my .Net 6.0 web API. After going through many articles and experiments I figured out the issue. I will share few steps you can do to identity the issue and fix it.</p><ol><li><strong>Check for access to Azure application insights &amp; Log Analytics workspace</strong></li></ol><p>You should start with checking your access to Application Insight instance where you are trying to push your logs. What most of people may miss is to check access for Log Analytics workspace too. Your DevOps should ideally give access of both Application Insight and Log Analytics workspace. However Azure allows capability to change log analytics workspace even after creating Application Insights.</p><p>You can see link to Log analytics workspace on overview panel of Application Insights.</p><p><strong>2. Check for Local Authentication configuration</strong></p><p>Select Properties under the Configure heading in the menu on the left. Select Enabled (click to change) if the local authentication is enabled. Select Disabled and apply changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*WLxO37DQGEdX0sr0ba_0nw.png" /></figure><p>When this configuration is set to Disabled, your logs will not go to Application Insight. Change this to Enabled, or make sure you are configuring Telemetry client using authorized Azure Identity. This identity should have <strong>Monitoring Metrics Publisher </strong>role on your application insights.</p><p><strong>3. Make sure you have installed latest and stable version of Nuget</strong></p><p>Another check you need to do is go to your project and check the installed version of nuget package <a href="https://www.nuget.org/packages/Microsoft.Extensions.Logging.ApplicationInsights">Microsoft.Extensions.Logging.ApplicationInsights</a></p><p>This nuget package provides you capability to inject ILogger via constructor injection and logged messages or exceptions are sent to application insights.</p><p><strong>4. Send sample telemetry record using powershell</strong></p><p>If you are able to send a sample telemetry record, then large portion of pipleline is eliminated.</p><p>Below sections provide information about sending a sample telemetry record using PowerShell. This script creates a REST request and delivery telemetry result to Application insights component.</p><pre># Info: Provide either the connection string or ikey for your Application Insights resource<br>$ConnectionString = &quot;&quot;<br>$InstrumentationKey = &quot;&quot;<br>function ParseConnectionString {<br>param ([string]$ConnectionString)<br>  $Map = @{}<br>  foreach ($Part in $ConnectionString.Split(&quot;;&quot;)) {<br>     $KeyValue = $Part.Split(&quot;=&quot;)<br>     $Map.Add($KeyValue[0], $KeyValue[1])<br>  }<br>  return $Map<br>}<br># If ikey is the only parameter supplied, we&#39;ll send telemetry to the global ingestion endpoint instead of regional endpoint found in connection strings<br>If (($InstrumentationKey) -and (&quot;&quot; -eq $ConnectionString)) {<br>$ConnectionString = &quot;InstrumentationKey=$InstrumentationKey;IngestionEndpoint=https://dc.services.visualstudio.com/&quot;<br>}<br>$map = ParseConnectionString($ConnectionString)<br>$url = $map[&quot;IngestionEndpoint&quot;] + &quot;v2/track&quot;<br>$ikey = $map[&quot;InstrumentationKey&quot;]<br>$lmUrl = $map[&quot;LiveEndpoint&quot;]<br>$time = (Get-Date).ToUniversalTime().ToString(&quot;o&quot;)<br>$availabilityData = @&quot;<br>{<br>  &quot;data&quot;: {<br>        &quot;baseData&quot;: {<br>            &quot;ver&quot;: 2,<br>            &quot;id&quot;: &quot;SampleRunId&quot;,<br>            &quot;name&quot;: &quot;Microsoft Support Sample Webtest Result&quot;,<br>            &quot;duration&quot;: &quot;00.00:00:10&quot;,<br>            &quot;success&quot;: true,<br>            &quot;runLocation&quot;: &quot;Region Name&quot;,<br>            &quot;message&quot;: &quot;Sample Webtest Result&quot;,<br>            &quot;properties&quot;: {<br>                &quot;Sample Property&quot;: &quot;Sample Value&quot;<br>                }<br>        },<br>        &quot;baseType&quot;: &quot;AvailabilityData&quot;<br>  },<br>  &quot;ver&quot;: 1,<br>  &quot;name&quot;: &quot;Microsoft.ApplicationInsights.Metric&quot;,<br>  &quot;time&quot;: &quot;$time&quot;,<br>  &quot;sampleRate&quot;: 100,<br>  &quot;iKey&quot;: &quot;$ikey&quot;,<br>  &quot;flags&quot;: 0<br>}<br>&quot;@<br># Uncomment one or more of the following lines to test client TLS/SSL protocols other than the machine default option<br># [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SSL3<br># [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS<br># [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS11<br># [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS12<br># [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS13<br>$ProgressPreference = &quot;SilentlyContinue&quot;<br>Invoke-WebRequest -Uri $url -Method POST -Body $availabilityData -UseBasicParsing</pre><p>You should see 200 OK in response. if not, based on the API response you will be able to narrow down your problem.</p><p>If you are not able to identify your problem you can raise a support ticket here — <a href="https://ms.portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/overview?DMC=troubleshoot">Microsoft Azure Support</a></p><p>I hope you found this post helpful. Please let me know if you have any corrections / questions in the comments below.</p><p>If you like this post, please feel free to clap your hands 👏👏👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2334b24075" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>