<?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 Alexandra Rusina on Medium]]></title>
        <description><![CDATA[Stories by Alexandra Rusina on Medium]]></description>
        <link>https://medium.com/@alexandrarusina?source=rss-2eb43224a7e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MK1-y7JfD105c9VYfcjeLw.jpeg</url>
            <title>Stories by Alexandra Rusina on Medium</title>
            <link>https://medium.com/@alexandrarusina?source=rss-2eb43224a7e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:32:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexandrarusina/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[Model Routing with NVIDIA’s NeMo Switchyard]]></title>
            <link>https://pub.towardsai.net/model-routing-with-nvidias-nemo-switchyard-9f52edda0af2?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f52edda0af2</guid>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[tokenomics]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[model-routing]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 21:01:02 GMT</pubDate>
            <atom:updated>2026-11-05T12:13:10.795Z</atom:updated>
            <content:encoded><![CDATA[<p>“Don’t take a Ferrari to a grocery store” is the new AI mantra. It means that you shouldn’t use the best frontier AI model for routine tasks, but delegate them to something simpler and cheaper, which will save you money. There is a more formal industry term for this — “model routing”.</p><p>Like many AI engineers these days, I have access to several models. Both Anthropic and OpenAI release not just a single model, but a whole family of them, ranging in price and capabilities. In my case, I also have a local AI set up. This is how my half manual, half hard-coded routing looked like:</p><ul><li>Astra 6 High for architectural design (Opus 5.5 in Anthropic)</li><li>Sol 6.1 Medium for standard coding tasks (Sonnet 5.5 in Anthropic)</li><li>Qwen3.6–35B running locally on a MacBook Pro for tests and simple tasks, especially when I am low on tokens on my subscription.</li></ul><p>Usually, during the design phase I would ask Astra to identify which tasks can be handed off to Sol or Qwen, and I admit that some manual copy-pasting of prompts still happened.</p><p>So, I wasn’t necessarily taking a Ferrari to a grocery store. But I wanted to understand whether I could optimize this setup and save more tokens. For example, defer some tasks to Terra or Luna instead of using Sol. To be fair, there might be other reasons for model routing — privacy, quality, speed, to name a few — but my main goal was efficiency and cost saving, and this is what this article is focused on.</p><p>Instead of writing this logic on my own, I decided to try a third-party model-routing tool — <a href="https://github.com/NVIDIA-NeMo/Switchyard">NeMo Switchyard from NVIDIA</a>. In the article, you’ll find the details of my setup and the experiments I ran. But before we dive into that, I’d like to give my main conclusions upfront:</p><blockquote><em>Model routing as it is today is still an advanced area. While Switchyard is a pretty decent tool, the complexity of the issue it’s solving can lead to the opposite result — spending more tokens and dollars instead of saving them.</em></blockquote><p>Getting back to the Ferrari metaphor — no, you don’t need it to get to a grocery store. But choosing between a Ferrari, a bicycle, a truck, and a Toyota Corolla for each trip might not be super trivial in today’s AI world. You might save yourself a lot of trouble by simply sticking to Toyota every time.</p><h3>Meet NeMo Switchyard</h3><p>The tool I chose to experiment with was <a href="https://github.com/NVIDIA-NeMo/Switchyard">NeMo Switchyard </a>from NVIDIA because it satisfied my personal requirements:</p><ul><li>It can route between local and cloud models;</li><li>It lets me use my OpenAI subscription and doesn’t require any new accounts or subscriptions (some model routing tools require you to pay through them);</li><li>It’s free and open-source, but from a trusted big company — NVIDIA.</li></ul><p>Here is a quick overview of how it works. It has two main methods of classifying the task and choosing the model to route it to:</p><ul><li><strong>LLM classifier</strong><br>You select a model which will act as a “judge” and decide what model to route your request to. Typically it’s a small model, similar to Luna in the GPT family. You need to provide a list of possible models to choose from and which one should be used for escalation if the selected model can’t complete the task.</li><li><strong>Stage Router</strong><br>This one routes between two models only — “efficient” (weaker) and “capable” (stronger). There is no LLM call involved. Here, requests are usually routed to the weaker model first. Stage Router evaluates signals from recent tool activity and task progress to decide whether the “confidence threshold” has been reached, at which point it escalates to a stronger model.</li></ul><p>There are some combinations of these two options. For example, the LLM classifier can use a confidence threshold or a customized prompt.</p><p>The general setup with the LLM classifier looks pretty straightforward, but Switchyard has an additional built-in feature. While usually you select a model per thread or task, here the model can be changed either for each LLM request or per “user turn”.</p><p>A “user turn” doesn’t necessarily mean a new message from a human: coding agents can generate user-role messages themselves, for example when starting subagent tasks or resuming after context compaction. Interestingly enough, “per LLM call” is the default setting, while “per user turn” is the recommended one. I followed the recommended option and chose the “user turn” trigger for my experiments.</p><p>To route requests and allow users to rely on cloud subscriptions from OpenAI and Anthropic, Switchyard installs a small lightweight server that acts as a proxy, but if you use metered API calls, you can integrate with its library instead.</p><p>Two things worth noting here. First, model routing can be as complex as you wish it to be. For example, you can use your own classifier or tune NVIDIA’s Prefill Router. I didn’t venture that far into the weeds — my goal was to see if there is a quick and easy way to save tokens and money and make my overall setup simpler, not more complex.</p><p>Second, most of the Switchyard components as of November 3, 2026, when I am writing this article, are still marked as “Alpha”, “Beta”, or even “Demo”, so expect things to keep changing.</p><h3>Installation and configuration</h3><p>Of course, my installation consisted of a simple prompt to my coding agent asking to install and configure Switchyard on my machine. And I have to say, this part went pretty well. I use OpenCode Desktop as my main IDE and after a few minutes, I had a picker with available models in the UI, a running Switchyard server, and everything just worked.</p><p>However, the initial simplicity was misleading. My coding agent had installed everything, but figuring out whether it was making good routing decisions was a different and more difficult problem.</p><p>For example, you can see in the diagram that I set the escalation model as Sol Medium, not Astra High. Astra High is in the mix of the models to choose from for the classifier, but if a smaller model fails, you don’t want to immediately escalate to Astra — this will lead to an increase in token usage on average.</p><p>I will talk more about possible issues in the “Learnings” section, but for now let’s focus on the happy path. Ideally, the setup I wanted looks like the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zx5_lq8TJVJaBapA1_5nKA.png" /></figure><p>However, the fact that I would love to have this setup doesn’t mean that it would lead to my desired outcome — saving me tokens and possibly dollars. So I needed to test it and analyze the results.</p><h3>Putting it to the test</h3><p>To test the model routing a bit more formally, I decided to run a few different configurations with two coding tasks from SWE-bench. I like these test suites since they have real repositories, real bugs, and also standard verifiers that check if the model succeeded with the task.</p><p>I didn’t want to run the whole benchmark test suite because it is too expensive, so I chose a couple of tests to focus on:</p><ul><li>Django-15957 from SWE-bench Verified, a difficult task that my local Qwen3.6–35B normally can’t solve. This is a nice way to test escalation from a weaker to a stronger model.</li><li>Requests-1963 from SWE-bench Lite, which can be solved by a small model like Qwen, but is not super trivial. This one is good for testing actual token savings.</li></ul><p>Next, I defined five different configurations, tailored to my own setup:</p><ul><li>All GPT models + Qwen with Luna as a judge — this is basically my preferred setup, shown in the diagram in the previous section.</li><li>Only GPT models, no Qwen, with Luna as a judge — to see if I really need Qwen in the mix or I can save money without it.</li><li>Stage Router classification with Qwen set as the “efficient” model and Sol Medium as the “capable” one — to understand if I can achieve savings without an extra call to the LLM judge. I set the confidence level to 0.4 (instead of the default 0.5) and I will explain why in the “Learnings” section.</li><li>Sol Medium direct — a baseline test for my usual go-to cloud model.</li><li>Qwen3.6–35B direct — another baseline test, but this time for my local AI.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EvQxSwaIYI26ktJBY3ojJg.png" /></figure><p>To summarize, I wanted to see whether I was getting any real savings with the model routing and whether delegating to Qwen helps or simply means redoing the work. And I settled on two different tests and five different configurations to get the answers. Overall, I got a total of 10 variations and I ran each variation three times to account for the variability of LLMs’ token usage.</p><p>In the table, you can see typical test run results for one selected attempt for each configuration and task. PASS means local patch validation, not an official SWE-bench result or a success rate. The costs are estimated because I am using a subscription, not the actual metered APIs. Also, the costs don’t include calls to the classifier model itself or the electricity and hardware costs for running my local Qwen, but the estimates do account for input/cached/output token pricing.</p><p>Overall, this is not a perfect benchmark test, but a good comparative illustration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dybLn-L2A1TpQ8AKhJvb2A.png" /></figure><p>The main findings from the test can be summarized as follows:</p><ul><li>On the harder Django task, routing brought no measurable advantage over simply using Sol Medium. This is understandable because the LLM classifier in all three runs selected Sol Medium as well. There was no attempt to delegate subtasks to cheaper models like Terra or Luna during these runs.<br>Even worse, when forcing the system to go to a weaker model as in the Stage Router setup, I ended up spending more tokens. The failed attempts of the weaker model simply increased the context size for a stronger model, and resulted in an increased token count and higher estimated costs.</li><li>On the simpler Requests task, there are some measurable savings in estimated costs because the LLM classifier chose Terra Medium instead of Sol Medium. And the savings can be up to 2–3x, which is significant.<br>However, the LLM classifier never chose Qwen when it was available, which would have resulted in $0 estimated cost.</li></ul><p>So, the answer is that I can get some savings if I am very careful with when and how I use routing, and simply relying on a generic LLM to make the decisions for me won’t necessarily bring the best results.</p><p>However, my biggest learnings and “aha” moments didn’t come from running the tests. They came from trying to configure the routing, doing my normal day-to-day coding work and fixing the routing issues. This is what the next section is about.</p><h3>Learnings</h3><p>As soon as I had Switchyard working in my IDE, I configured the agents to always use it. Both OpenCode and Switchyard collect pretty good telemetry on token usage, so I could later analyze if I am really saving tokens simply by looking back at my historical data.</p><p>Analysis of this data and all the misconfigurations I ran into is where my major understanding of this area came from. So let’s look at them one by one.</p><h4><strong><em>Do not default to the best available model as a backup</em></strong></h4><p>My initial setup for Switchyard was to choose Astra if the task was unclear or if a weaker model couldn’t handle the task. I noticed almost immediately that my subscription allowances started to deplete much faster as soon as I introduced Switchyard. I let it run for a few days and the results were very telling.</p><p>During those few days, Astra High accounted for 25% of the token usage and the tasks were not architecture-level work, but tasks that Sol Medium would have been perfectly capable of solving. Then I applied current pricing to my token usage to see how much I would pay with the metered API. As it turned out, Astra contributed to 75% of that estimated cost.</p><p>While OpenAI doesn’t show exact token usage for its subscription API, the local telemetry results were able to explain why my tokens were running out much faster than the previous week. When I switched from Astra to Sol Medium as a backup and escalation model, my token usage returned to the previous rate.</p><h4><strong>The LLM classifier needs its own configuration</strong></h4><p>The idea of sending a request to a small LLM sounds very simple. But in fact, there is a lot to consider. First, LLMs often struggle to estimate the complexity of the tasks and the effort required to solve them. There are multiple research papers about this, and I explored this topic myself in the <a href="https://medium.com/@alexandrarusina/what-i-learned-trying-to-forecast-coding-agent-spend-44e7775c6a90">What I learned trying to forecast coding-agent spend</a> article.</p><p>Ideally, you need to check how well your classifier actually works — whether it classifies tasks correctly and what its success rate is. There are some specialized models, but they are not the ones provided by default with an OpenAI subscription or NeMo Switchyard. So now you need to either find a good match or train your own, which gets us back to the ROI question — is it really worth it when something like Sol Medium can solve most of your issues reasonably well?</p><p>Then there’s your default workflow. I personally often send screenshots of errors or UI bugs to my coding agent. But the classifier model doesn’t necessarily work with images. Another issue I ran into is the content of the initial prompt. For example, I often write up .md files that contain descriptions of the work to be done. Then my prompt is “Implement <a href="http://task.md/">task.md</a>”. The naive classifier call won’t see the content of the file and very likely will use your default model, not the most appropriate one. I had to change my default workflow to include the content of the <a href="http://task.md/">task.md</a> file in the initial classification call to work around the issue, but it’s just one of the many potential gotchas here.</p><p>Yet another thing to figure out is how often to reclassify. Should it be per LLM call and increase the overall call count? Or per user turn? Or per session? Everything can be tested and answered, but the time and effort spent on configuration keep adding up.</p><p>And finally, the coding agent harness and the IDEs often have their own configurations and optimizations to work with OpenAI and Anthropic subscriptions and APIs. Adding one more piece into this puzzle again can make the situation worse, not better. For example, I ran into issues when I added Switchyard to my OpenCode Desktop, where the classifier correctly chose Terra Medium, but cache misses increased token usage and resulted in a higher estimated cost than my Sol Medium baseline.</p><h4><strong>Tuning the non-LLM classifiers can also be tricky</strong></h4><p>Switchyard provides a Stage Router that avoids the LLM classifier altogether, but it needs tuning as well. As a reminder, in my setup it defaults to a weaker model and escalates to a stronger model when the confidence threshold is reached.</p><p>With the two tests I chose to run, I got to experience two different failures — one due to a high threshold and another one due to a low one:</p><ol><li>When the confidence threshold was set to 0.5, my local Qwen failed to solve the trickier Django test, but the confidence threshold was never reached and I ended up with no escalation to Sol Medium and a failed test pass.</li><li>When the confidence threshold was set to 0.4, the Django test was properly escalated to Sol Medium. However, the simpler Requests test, which was well within Qwen’s capabilities, escalated to Sol Medium as well. Basically, the system didn’t let Qwen finish this simpler task.</li></ol><p>What makes matters worse is the potential savings impact. Letting Qwen finish a simpler task would result in $0 estimated cost. But escalating from Qwen to Sol Medium for the harder task turned out to be more expensive than simply solving it with Sol Medium in the first place — almost 2x more — most likely due to the increased context size that now included all of Qwen’s errors as well.</p><h4><strong>Mixing the models leads to mixed results</strong></h4><p>There is a general issue of handoff between the models while working on a task within one session, especially if it doesn’t involve subagents. My local Qwen3.6–35B is running on a three-year-old MacBook Pro. I like it because it lets me explore local AI capabilities, but its context window is only 128K (compare this to 1M for OpenAI’s GPT-6 models). The compaction and handoff issues were very noticeable when I used Switchyard for my normal coding tasks. In a longer thread, Qwen would often just fail to pick the work handed off to it.</p><p>You can expect other potential issues if you start mixing models with different capabilities and configurations, beyond the context window size. Support for different languages and images, along with privacy and security concerns — all of this can turn into problems during handoff between different models.</p><p>Is this fixable? I am sure it is. The question again is the ROI of the work you have to do before you get to any savings and the maintenance of it all as AI models keep evolving.</p><h3>Conclusion</h3><p>If your goal for model routing is saving tokens, whether to stretch your subscription allowance or reduce your metered API bill, this is what I would recommend:</p><ol><li>If you are a casual vibe-coder, a solopreneur, or even an advanced AI enthusiast who mostly relies on an AI subscription, with model routing, you risk investing a lot of time and effort and achieving very little ROI or even negative results.</li><li>If you have a really powerful local AI setup that can substitute Sol Medium, Switchyard is worth experimenting with. But test escalation carefully, since thresholds that are too high or too low can erase the savings.</li><li>If you have a big team and your AI budget is through the roof, model routing plus local AI might provide savings. But treat it as a proper engineering effort worth at least a sprint, not as a simple one-hour task. Starting with Switchyard or another existing model router is a good idea, because even by looking at their configurations you can see what questions you need to figure out.</li><li>And finally, if you are developing modern AI coding tools and IDEs, model routing is definitely an area worth investing in. The savings potential is great, but the usability and configurations needed to achieve measurable results (not just setting up model routing, but actual savings) are definitely not there yet.</li></ol><p>For myself, I ended up with a simple conclusion — for day-to-day work, Sol Medium, the Toyota Corolla of LLMs, is good enough for me, and the headache of choosing a different method of transportation for each trip is not worth the effort, at least not today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f52edda0af2" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/model-routing-with-nvidias-nemo-switchyard-9f52edda0af2">Model Routing with NVIDIA’s NeMo Switchyard</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Learned Trying to Forecast Coding-Agent Spend]]></title>
            <link>https://medium.com/@alexandrarusina/what-i-learned-trying-to-forecast-coding-agent-spend-44e7775c6a90?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/44e7775c6a90</guid>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[qwen]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 12:28:22 GMT</pubDate>
            <atom:updated>2026-07-30T12:30:20.894Z</atom:updated>
            <content:encoded><![CDATA[<h3>What I learned trying to forecast coding-agent spend</h3><p>The strength and weakness of modern LLMs is their non-deterministic nature. Even the same task can be solved in different ways by the same model, resulting in different costs. However, organizations still need to plan and forecast AI budgets.</p><p>And this is what I set out to test — how much can be estimated in advance for AI tools, specifically for software development workflows that rely on coding agents for automation. My goal wasn’t perfect estimation, but an exploration of what is currently possible.</p><p>My experiments were focused on two models: GPT-5.5 and Qwen3.6–35B. I used the same coding agent — OpenCode — and the data came from two sets of tasks: <a href="https://www.swebench.com/index.html">the SWE Bench</a> and my own coding projects.</p><p>To set the baseline, I relied on the SWE Bench, a collection of real-world software engineering problems extracted from GitHub repositories. I picked 11 tasks of different complexity to calibrate my predictions and then tested them on personal coding tasks. I kept my testing set relatively small to stay within my GPT Plus subscription budget.</p><p>After measuring token usage and calibrating the predictions for several weeks, I came to the following result: it is possible to make estimates good enough to use as an early warning system, but it requires significant upfront investments.</p><p>About 80% of my GPT measurements and 68% of my Qwen measurements fell within their expected ranges after calibration. The ranges were wide — the upper bound was often three to five times the lower bound — but they were still useful for establishing what a normal execution should look like.</p><p>Now let’s talk through challenges and practical implications for token forecasting.</p><h3>When is estimation good enough?</h3><p>80% measurements within the range looks good, but the ranges are definitely wide — there is a big difference between 30K and 150K tokens. Let’s put this into a broader industry context.</p><p>In a research paper from April 2026 — <a href="https://arxiv.org/abs/2604.22750">How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding</a> — the authors claimed that “runs on the same task can differ by up to 30x in total tokens”. As discussed earlier, the LLMs are inherently non-deterministic and so the wide ranges are expected.</p><p>More importantly, if you estimate that the task should consume tokens or be completed within a certain range, you can react when the task goes over the limit.</p><p>Here is a quick example to illustrate how upfront estimation can help. One of the tasks for the SWE Verified bench, swev-django-15957, was within the predicted values for GPT, but exceeded the predicted token and time ranges with Qwen. Both models classified it as the same type of work: a moderate implementation task.</p><p>With the alerts in place, you can detect when the model reaches the threshold and then decide whether to continue or stop the execution and switch to a more advanced model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*05GoBv9YREyIN35_YQ6YrQ.png" /></figure><h3>What to estimate?</h3><p>When I was working with dev teams as a TPM, my two main estimated values were time and number of developers — “two people can solve this in two weeks”. I rarely estimated direct cost, it was a derived value based on developers’ salary.</p><p>Similarly, I would not recommend estimating a single generic “cost” number for AI tools — a dollar estimate is derived from provider pricing or from the cost of local compute.</p><p>For metered APIs, tokens are more important and the cost comes directly from them. For local AI with “free tokens”, time becomes more interesting. The same is true for hosted AI models where you pay for GPU-hours.</p><p>But “token” is a very generic term. I explored this topic in my previous article <a href="https://medium.com/p/9f4dc0f1e25e">Understanding the Cost of Coding Agents</a> and came to a conclusion that I need to measure and estimate at least three different types of tokens plus time.</p><p>So here are the values I originally selected for monitoring and estimating:</p><ul><li><strong>Input tokens</strong> — what your coding agent sends to the model, including prompts and file contents;</li><li><strong>Cached input tokens</strong> — data that has been sent to the model in the previous iteration and now is being read from a cache;</li><li><strong>Output tokens</strong> — data generated by the model based on input tokens;</li><li><strong>Wall-clock time</strong> — total time the agent spends on a task. This is especially important if you are in the GPU-rental mode instead of the “pay per token” one.</li></ul><p>Two more values emerged during the experiments that are also worth logging. They help with estimations and cross-checking.</p><ul><li><strong>Tool calls</strong> — this had a high correlation with overall input tokens. The more tool calls the task needs, the higher the input tokens count can be expected.</li><li><strong>Context depth</strong> — the size of your context before you execute the task. This mostly affects cached input tokens and wall-clock time.</li></ul><p>Model calls and tool cycles can serve as early indicators that the agent may be stuck in a non-converging loop.</p><h3>Estimation based on historical data</h3><p>If you simply ask one of the top LLMs — ChatGPT or Claude — to estimate their own tasks, you are very unlikely to get a good answer. In my tests, wall-clock time was overestimated by ~5x and token usage was underestimated by ~10x. Basically, models have no internal knowledge about how many resources the tasks would consume.</p><p>This is why I settled on a feedback loop based on historical data and classification. The overall process looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1DkNDznbjYmWw9szcECxiA.png" /></figure><ol><li><strong>Gather the data</strong><br>Start with collecting telemetry about your projects and time and tokens spent for each task. I would recommend logging the values I listed above and at least a short description of the task.</li><li><strong>Classify tasks</strong><br>Analyze the telemetry and classify the tasks into size and type. For example — small/medium/large sizes and debugging/implementation/testing types. The types should naturally emerge from your personal or organization’s work data.</li><li><strong>Set up expected ranges and alerts</strong><br>Define the estimation range for each type/size for each value you are estimating. <br>If you are using multiple models, you might need separate calibration for each. The token spend can differ significantly. For example, Qwen generated more output tokens than GPT, even if their input token spend was similar.<br>Set up alerts to notify when the task is exceeding the expected range on any of the predicted values.</li><li><strong>Calibrate</strong><br>After executing the task, compare the estimation to actuals and calibrate the guidance accordingly. It’s not worth recalibrating after every task, but only after collecting enough additional data (e.g. after a day or a week of active development.)</li></ol><p>Classification is the most interesting part, and there are several ways to implement it with their own trade-offs. You can build a deterministic classifier, but it can become a complicated piece of software to maintain. I went a different route and simply did a separate call to LLM to ask for the classification and estimation according to provided guidelines.</p><p>However, calling LLM for classification produced about 8% overhead — basically, my AI budget increased because I was trying to keep it under control. To measure the estimation overhead, I ran all classification and estimation tasks in subagents. But estimation essentially needs the same context as the task itself, so the actual overhead can be lower.</p><p>Another question to consider is the number of task categories. I deliberately kept the taxonomy small because my dataset could not support fine-grained categories. A production system with much more telemetry could classify tasks more precisely, but that remains to be tested.</p><h3>Conclusion</h3><p>The most important lesson from this experiment is that estimation is possible, but it is not automatically worth doing. The current state of coding agents, development and monitoring tools requires quite a lot of investment in monitoring and telemetry analysis. For small individual tasks, the overhead and tooling investment may be too high. For long-running or highly automated workflows, forecasting becomes much more meaningful.</p><p>In the future, I hope to see a more generalized product for AI task estimation. The pieces of this system are beginning to appear: coding agents can enforce static limits on steps, time, or spend; IDEs can impose per-session budgets; and observability platforms can alert on token, cost, and latency thresholds.</p><p>What I have not found is a turnkey system that learns model- and task-specific operating ranges. For now, this still requires custom logic. The practical direction is therefore not simply “estimate before the task,” but a control loop: estimate the expected range, meter actual usage, intervene when execution becomes abnormal, and feed the result back into future calibration. The achievable goal is not to predict the final bill precisely, but to recognize a costly or non-converging run early enough to do something about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44e7775c6a90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the cost of coding agents]]></title>
            <link>https://pub.towardsai.net/understanding-the-cost-of-coding-agents-9f4dc0f1e25e?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f4dc0f1e25e</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[tokenomics]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 20:01:01 GMT</pubDate>
            <atom:updated>2026-07-14T20:01:01.059Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding the Cost of Coding Agents</h3><p>From individual developers running out of tokens on a daily basis to <a href="https://www.forbes.com/sites/janakirammsv/2026/05/17/uber-burns-its-2026-ai-budget-in-four-months-on-claude-code/">Uber famously burning through the yearly budget in just four months</a>, AI cost in both tokens and dollars is at the center of attention. Even for those who are happy with their AI subscriptions, the API-equivalent cost matters. Once you max out subscription tokens, you can add credits and effectively move into metered usage. Also, <a href="https://www.theregister.com/software/2026/04/28/microsofts-github-shifts-to-metered-ai-billing/5224151">Copilot’s shift to metered AI billing</a> raises the possibility that other providers will make the same switch.</p><p>This article is for those who want to understand how AI billing works in general and how it applies to coding agents. If you are a leader in charge of an AI budget, a TPM figuring out project constraints, or a founder thinking through cost models, this should be a helpful guide. It won’t explain the basic concepts like a “token” or “coding agent”, but it will discuss how tokens flow through the system and show up in your telemetry and billing, as well as how performance and engineering issues can affect your budget.</p><h3>Coding agents and tokens</h3><p>One of the challenges with understanding AI billing is that “token” is a very generic term. You don’t just spend “tokens.” You spend input, cached input, output, reasoning, and sometimes cache-write tokens. These are not interchangeable, because they have different prices and tell you different things about agent and model behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXl3iPW92ML57teBSwRYhw.png" /><figcaption>Tokens in the agentic loop</figcaption></figure><p>The diagram above shows the overall agentic loop and what you pay for during its execution. Let’s look at each part.</p><h4>Agent/Orchestrator</h4><p>The agent collects client-side data — from the user prompt to file contents and tool call results — and sends it to the LLM via the HTTP request. This step is usually free of charge.</p><p>Whatever the agent sends to the LLM is called “context” and when you hear discussions about “context window” — this is what it refers to. Context window size is more of an engineering metric than a business metric. It defines how much data the agent can send, but there is no direct billing associated with it. If the provider increases the context window, it won’t necessarily affect your bill.</p><h4>Input/Context Processing and Prompt Cache</h4><p>The AI provider processes the input, and this is where another common term appears: “prompt cache.” The name is a bit misleading, because it’s more of a general context cache. This is not technically part of the LLM, but most AI providers use it these days.</p><p>The implementation of caching and its billing can differ, but overall it works like this. The data sent from the client always contains the full content, but it still needs to be converted into tokens, or “tokenized”.</p><p>Because of the agentic loop, the system normally sends the same data over and over again and appends new data at the end. To avoid reprocessing the data multiple times, the providers cache it.</p><p>Let’s say your agent read five files in the previous step and now added a sixth one. The agent sends all six files to the provider, but five of them will be read from a cache and only one will be considered “fresh input”.</p><p>Why is this important? Because cached input is typically 10x cheaper than new input. So you will pay the cache token price for five files and the input token price for just one file. The new file will be added to the cache, and during the next agentic cycle you will pay the cached token price for all six files.</p><p>Cache optimization is a topic of its own. Some providers, like Anthropic, charge separately for writing to it and let you control the amount of time the data lives in the cache. Others, like OpenAI, have fully automated the process and bundled the cost of cache writes into the cost of fresh input tokens.</p><p>There are two engineering terms you might have heard of: “cache hit” and “cache invalidation”. “Cache hit” means the system finds the old data in the cache and you pay less. “Cache invalidation” means that the data isn’t found, so you pay the input token price.</p><p>Here is a classic example of how to ruin your cache — add a timestamp at the beginning of the agentic prompt and update it every cycle. While the data in the prompt mostly remains the same, the cache is constantly invalidated. For you, that means paying the input token price for something that has already been cached.</p><p>Cached input tokens are the cheapest tokens you spend, but remember that you pay the cached price over and over again during the loop, because the agent keeps sending the full context every time.</p><h4>LLM (Model Inference)</h4><p>Finally, the data reaches the LLM and enters its own loop: the “generation loop.” This is when “output” tokens are generated. The model takes the whole tokenized context and predicts the next token then sends the old context plus the new token to itself and predicts the next one, and so on.</p><p>You are charged here for the newly generated output tokens (only once, with no repeated billing here) and also for what are called “reasoning tokens”. These are basically the same as output tokens, but they are technically not needed for the end user and required by the model itself.</p><p>Some providers, especially local AI tools, allow you to turn the reasoning capability off completely, which makes the model a bit more deterministic, but also less advanced. Reasoning tokens can also be completely hidden from user output. This is why they sometimes exist as a separate line item in telemetry and billing, but at other times are simply added to the output. For the sake of this discussion, we’ll consider reasoning tokens the same as output ones.</p><p>Output tokens are the most expensive ones — they are normally 5–6x more expensive than input tokens (or 50–60x more expensive than cached ones).</p><h4>Response</h4><p>When the model completes its generation loop, the data is sent back to the agent. It contains the messages you see in the chat, file edits, and requests for new tool calls. This data is passed to the agent, which executes the instructions and assembles new context — and so the loop continues.</p><p>Since the system always adds new data to the existing context, at some point its volume can exceed the context window size. What happens in this case is called “compaction”. When the agent notices that the context is getting close to its limit, it sends instructions to the LLM to summarize existing information, or to “compact” it. This greatly reduces the current context, usually by 10x. In this case, on the subsequent request the cache is invalidated. What you will see in your telemetry is the cache and context suddenly becoming much smaller and then starting to grow again.</p><h3>Translating tokens into dollars</h3><p>To summarize the previous section: there are several different types of tokens and they are priced differently. The ratios among cached, input, and output token prices are relatively stable across providers — 1:10:50 or 1:10:60. The table below shows pricing as of July 2026 for several top LLMs, and all of them follow roughly the same ratio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*i3ixuKhYaO5K3y60u-5lFw.png" /><figcaption>Pricing as of July 2026 for several top LLMs</figcaption></figure><p>However, the listed price is not all that matters. Coding agents also have a very particular token-volume pattern: input tokens greatly outnumber output tokens, and cached tokens dominate anything else. This is due to extensive use of caching during agentic loops. So while cached tokens are the cheapest, cumulatively they may end up being the largest entry in your bill.</p><p>Again, this trend repeats across different LLM providers and coding agents and their various combinations. This is especially noticeable if you look at <a href="https://artificialanalysis.ai/agents/coding-agents?coding-agents-token-usage-chart=token-usage#coding-agents-token-usage-chart-tabs">Artificial Analysis data that benchmarks token usage by type </a>across different LLMs and coding harnesses. Here is a simple infographic based on its data for OpenAI, Anthropic, and Google’s latest LLMs as of July 2026.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6lKtCs-YRtanaGfJvF-Ww.png" /><figcaption>Average across OpenAI, Anthropic, and Google’s latest LLMs as of July 2026</figcaption></figure><p>This pattern is not necessarily the same for other AI applications. For example, chatbots or RAG systems can have a very different footprint. There is not enough industry research on this topic, but here is some anecdotal evidence. My personal coding agent usage aligns very strongly with the chart above, while my two AI apps — a chatbot and an AI-driven game — show very different patterns. So, understanding the token-usage pattern for your particular application is critical, but for coding agents you can rely on the existing industry trends.</p><h3>Tokens in AI subscriptions</h3><p>But what does this all mean for people who are using AI subscriptions for their coding agents? Can you prevent a “running out of tokens” situation by managing your tokens better?</p><p>Unfortunately, providers like OpenAI and Anthropic don’t publish “token allowances”. I am personally using a GPT Plus subscription, and all I can see is how fast my tokens deplete in the 5-hour window.</p><p>To understand my token flow and consumption, I had to rely on the IDE-provided telemetry (in my case, OpenCode Desktop) and build my own tooling around it. Looking at the telemetry, I can see that the tokens fully deplete after about 100K output + 1.4M input + 12M cached tokens. It’s unclear which of those token types, if any, is used as a token budget meter, but it’s a good approximation for me.</p><p>Once you start using credits after depleting your subscription tokens, you may get more API-like telemetry from the providers and see billing for each token type separately.</p><h3>Learnings</h3><h4><strong>Invest in good telemetry</strong></h4><p>The industry is moving toward tokens being the main billable items for AI workflows, but at the same time, the monitoring and reporting of the token spend are still very basic — both on the server/provider and client/IDE sides. If you are switching between multiple providers, deploying a good token monitoring system becomes crucial for understanding your costs and keeping them under control.</p><h4><strong>Analyze your token volume, not just listed pricing</strong></h4><p>AI budgets are not driven by model pricing alone. The cheapest token category can still become a major budget line simply because it repeats in every iteration of the agentic loop. Cached tokens are the clearest example: they are discounted, but they can dominate total usage volume. For business leaders, this means vendor negotiations should focus not only on token prices but also on volume commitments and reporting by token category. For engineering teams, the goal is to understand which workflows generate the largest token volumes and why.</p><h4><strong>Evaluate coding agents</strong></h4><p>LLMs define token pricing, but coding agents heavily influence volume — how many times you pay that price. Two agents using the same model can have very different cost profiles depending on how they use tools, manage context, and follow instructions. Choose and configure coding agents with the same care as when choosing an LLM provider.</p><h3>Looking ahead</h3><p>The information in this article can help you understand your bill and your token spend, but what about forecasting future usage? Any organization would prefer to avoid the kind of Uber situation mentioned in the intro and set a more realistic AI budget.</p><p>Telemetry is essential to answer this question — without it, there is no way to compare the estimates with reality. But it’s definitely not enough.</p><p>“Can I predict my own token usage?” is the question I’ll explore in depth in the next article, so stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f4dc0f1e25e" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/understanding-the-cost-of-coding-agents-9f4dc0f1e25e">Understanding the cost of coding agents</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The secret life of coding agents]]></title>
            <link>https://pub.towardsai.net/the-secret-life-of-coding-agents-36accbf3616f?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/36accbf3616f</guid>
            <category><![CDATA[dev-environment-setup]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Wed, 13 May 2026 07:52:26 GMT</pubDate>
            <atom:updated>2026-05-14T17:01:00.983Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Secret Life of Coding Agents</h3><p>Choosing the right AI model is now a well-recognized problem. It is still not trivial, but at least there are benchmarks, pricing pages, context-window comparisons, and plenty of public discussion to guide you.</p><p>Coding agents are still more of a wild west. Many people treat them as simple wrappers around the model: a chat window with file access and terminal commands. In practice, a coding agent can influence the model’s behavior quite a lot. It controls the environment around the model: which tools are available, what system instructions are added, how much project context is collected, and how the model is expected to interact with your codebase.</p><p>That makes choosing a coding agent its own problem. How should you measure its performance and efficiency? Should you choose an agent tightly coupled with a specific model, or one optimized for flexibility? How much do its prompts, tools, and workflows affect speed, cost, and security?</p><p>I faced those questions after I cancelled my Cursor subscription. The decision was cost-based; I didn’t have technical complaints about my setup, so I expected to find a replacement quickly. Instead, I ended up testing a bunch of different agents and discovered huge fluctuations in execution time and very different token usage for the same task. I even caught an API key being exposed in real time.</p><h3>AI dev environment</h3><p>Here is a quick illustration of the modern AI dev environment that puts the puzzle pieces together. LLM is the “AI brain”, but a coding agent is what turns LLM into a coding assistant and interacts with the tools. Today, coding agents usually don’t come as separate apps. Instead, you interact with them via some other interface — Command Line Interface (CLI) or Integrated Development Environment (IDE).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*F4sZJ3QP077IimiN" /></figure><p>Cursor combines all three layers into a single experience — it is a dev interface (which is based on its own version of VS Code, a very popular IDE) that comes with a built-in coding agent and a mix of models that it orchestrates based on your tasks. For me, this meant finding a replacement for all three layers of my AI dev environment.</p><p>Since the whole quest started after the spend analysis, the first question I asked was: should I still pay for a big cloud model, or can I replace it with local AI?</p><h3>Going Local?</h3><p>I did a pretty simple experiment to see if local AI was good for me. I asked two different models to update my chatbot <a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra</a> and add a “conversation” mode alongside the existing “single question” one.</p><ul><li>Task: add a conversation mode to a chatbot based on an existing design doc</li><li>Project size: ~2K lines of code, roughly 50K tokens</li></ul><p>I was not trying to benchmark every model on the market. I wanted to answer a practical question: could local AI become part of my real dev environment, or at least serve as a backup?</p><p>For the cloud model, I chose GPT-5.5 because it was part of my previous setup and I was satisfied with it. For the local model, I selected Qwen3.6 because it had performed best in my husband’s local AI experiments.</p><p>Since I was testing different models, I wanted to keep the same dev interface and agent. To start, I picked <a href="https://code.visualstudio.com/">VS Code</a> as an IDE and <a href="https://kilo.ai/code">Kilo Code</a> as my coding agent. VS Code was simply familiar already — even Cursor was based on it. Kilo Code lets you bring different models, including local ones, and switch between them easily. It is also available as a plugin for more than one IDE, which helped me keep my options open.</p><p>In addition to time, I was also measuring the overall number of tokens and the prompt size — mostly to keep an eye on future costs. To see the prompt size, I used a simple trick — sending “hi” in a new session and checking the tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*p3f-PXN_mUK3lF83" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujl1MIAjf7so8EZ1ZSalSg.png" /></figure><p>✏️ Even this simple experiment produced quite a lot of data:</p><ul><li>The output quality was basically the same. The GPT’s UI design was a bit more polished, but again the local model is free, so I can iterate without paying extra.</li><li>The local model was an order of magnitude slower than the cloud one. I expected the result, but not the magnitude of it.</li><li>The cloud model was more token-efficient. But with local AI, token count matters less because you are not charged for it.</li><li>Saying “hi” to your agent takes up to 20% of the context. The agent’s prompts are quite large (and this made me feel better about AI prompts in my own apps; it turns out they are not that big).</li><li>The total amount of tokens sent was roughly equivalent to my whole codebase. This shows how the cost for a bigger project can quickly get out of control.</li></ul><p>At this point my major concern was the speed of the local model. Up to 10x increase in execution time felt too high for my workflows.</p><p>However, when I showed the results to my husband, he challenged them. He also tested the local Qwen3.6 vs OpenAI GPT cloud models and saw a 5x difference, not 10x. He was using the OpenCode agent in the terminal on my MacBook M3 Pro with 36GB of memory.</p><p>Well, it’s not a complicated test, so I ran it again with a different agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lq99N0iimB6_Ve4F2F9wng.png" /></figure><p>This was totally unexpected — switching the agent reduced the execution time by 2x and used 20% fewer tokens. As it turned out, I wasn’t simply measuring local vs cloud models, but an agent’s effectiveness as well.</p><p>Now it became clear that the model was only one part of the story. The next question was: how much do coding agents change the result?</p><h3>Benchmarking coding agents</h3><p>After realizing that agents can significantly affect the speed and cost of development, I decided to expand my tests to more agents in different environments.</p><p>There was no way I could test all the agents and IDEs — there are too many of them on the market. So I tested a couple of well-known names like Codex from OpenAI and Copilot from Microsoft, open-source offerings from OpenCode and Kilo, and a single-person driven project Pi, which is famous for being fast and lean.</p><p>Not all agents support all models or integrate with all IDEs, so I tested a variety of setups with the same codebase and the same prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*PMww0ghSD7_af5_s" /></figure><h4>Cloud-based testing (GPT-5.5)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kf0g5t-_cpulzUYeK5sl3g.png" /></figure><p>✏️For smaller projects that use cloud LLMs, coding agents don’t seem to play such a big role:</p><ul><li>A one-minute difference in time can be a measurement error, network fluctuation, or infra queuing issue.</li><li>A 10K token difference may come from the non-determinism typical of LLMs.</li><li>All agents produced good results when backed by a fast capable model.</li><li>IDE vs CLI didn’t play a major role.</li></ul><h4>Local testing (Qwen3.6)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*of1sYLhg2-snM0dP3hXrwg.png" /></figure><p>✏️The local model amplified coding agents’ influence:</p><ul><li>There can be up to 4x difference in the execution speed for the same task, with the same model.</li><li>The total tokens count can fluctuate as much as speed — up to 3x.</li><li>Smaller prompt size seems to be correlated with faster outcomes in the local setup.</li><li>The leaner open-source agents had better speed and token usage.</li><li>The outcome of the test task was good, with occasional UI polish issues that were easy to fix and iterate on.</li></ul><p>If I simply used my own benchmark, the Pi agent would be a clear winner with OpenCode coming second. But things are not as simple in the coding agent’s land and there are more trade-offs to consider.</p><h3>Beyond benchmarking</h3><p>While testing the agents, I realized that speed and even the number of tokens do not tell the whole story. Agents need to earn my trust too.</p><h4>Less tokens, less guardrails</h4><p>One reason Pi is so fast is that it has a very small prompt. It mostly relies on the LLM already knowing how to behave as a coding assistant, instead of restating a long list of standard coding-agent guidelines. However, some of the missing guidance is about safety.</p><p>Here is a somewhat scary story that happened to me. My husband configured the Pi agent to use the Qwen3.6 model on my machine. Then I wanted to test the agent with GPT-5.5 and typed: “Switch from Qwen3.6 to GPT-5.5 model.” Not a great prompt, admittedly, but I had become used to Cursor and ChatGPT asking follow-up questions before doing anything risky.</p><p>Pi didn’t ask. Instead, it:</p><ul><li>assumed I wanted to replace the Qwen3.6 configuration;</li><li>assumed I wanted to use an OpenAI API key instead of a subscription;</li><li>found the API key in the .env file in the current project;</li><li>put that key into the default shell configuration file, making it available to any app.</li></ul><p>Pi outputs its actions and thinking process directly in the terminal window, which is actually a good thing, so I watched this happen live, with my mouth open. I reverted the changes immediately.</p><p>After that, I looked at the prompts for Pi and OpenCode (two open-source projects where I could easily get access to the prompts), and the difference was obvious. Pi has a much leaner instruction stack: basic tools like read, bash, edit, and write, plus a short set of usage rules. OpenCode, by contrast, includes subagents, todo management, detailed Git and PR safety workflows, web fetching, question prompts, skill loading, and much more behavioral guidance. That makes OpenCode heavier, but also more guarded.</p><p>Is Pi a bad agent? No. But this was a very clear example of the speed-versus-safety tradeoff. A lean agent is like a powerful sports car: it goes fast, but you might be missing airbags and other safety features.</p><h4>Slowing down with subagents</h4><p>I did multiple test runs with the same model and agent to make sure I captured the data correctly. At some point, the OpenCode agent with the Qwen3.6 model took much longer on my benchmark task: 37 min instead of 15 min. I couldn’t understand why. I reran the test — still slow.</p><p>After some joint debugging with my husband and lots of different guesses (did he change some settings on the local model? Was there a new version of the OpenCode agent released?), we finally found the culprit — the main agent had delegated work to a subagent.</p><p>I would expect it to make things faster. But when you have a single machine with a local model and a relatively simple task, subagents can significantly slow things down. Even delegation has overhead, and on local hardware that overhead can be too much for the task.</p><h4>Flexibility is still hard</h4><p>A coding agent is a layer between you and the model, and some agents optimize for certain models. I could have tested Codex with the local model, but it would require some configuration acrobatics and clearly, this is not what Codex is built for at the moment. OpenAI would prefer us to use its proprietary models.</p><p>Another issue is the dev interface — agents and IDEs can be very opinionated here as well. For example, Pi is pro-terminal; its support in IDEs is bare minimum. But the opposite also happens — VS Code is heavily integrated with Copilot, to the level that it gets in the way of other agents that run inside VS Code as plugins.</p><p>I realized that I prefer pluggable infrastructure where I can easily switch models and agents, but still have minimal IDE features like Git integration or a file viewer.</p><h4>The features I don’t need yet</h4><p>I am looking at agents from a single-developer perspective. I need to save time and money, but I don’t have a team dealing with code reviews, SLAs, or production fires. So I am not especially interested in integrations with tools like Jira, Slack, or PagerDuty.</p><p>For a team, the evaluation would probably look very different. Collaboration, review workflows, incident response, security controls, and observability would matter a lot more. I strongly suspect that if I were optimizing for those tasks, Copilot and Kilo Code would score pretty high.</p><p>For me, the basic stakes are simpler: can I trust the agent, can I control it, can it work with my preferred models, and can it perform a small task without turning it into a time and tokens sinkhole?</p><p>It was becoming clear to me that it would be hard to settle on a single model or agent going forward. With that in mind, I started looking at the final piece of the puzzle — the dev interface that could give me a flexible multi-model and multi-agent setup.</p><h3>Dev interface: the final layer</h3><p>I am not a big fan of the CLI — I code infrequently and prefer to have a nice UI and all the essential tools laid out in front of me, which is why Cursor was a good fit. To keep my car metaphor going, I want not just the airbags for safety, but an air conditioner and a nice sound system for comfort, even if it slows things down slightly.</p><p>To help narrow down the search for a new IDE, I created a wish list. My ideal IDE should:</p><ul><li>Contain basic tools: a file viewer, an editor with code completions and highlighting, terminal, Git integration, and of course an agent window</li><li>Let me control which agent and model to use and allow for switching them easily</li><li>Show me how many tokens I spent and how long it took to complete a task</li><li>Display a desktop notification when the task is finished</li><li>Work on my MacBook Air</li><li>Be a free tool to avoid adding another subscription fee to my AI monthly budget</li></ul><p>It turned out to be surprisingly hard to find a good IDE for me. I tried the big names and some personally trusted vendors. Each had strong differentiating points, but each also had its own issues.</p><ul><li><a href="https://code.visualstudio.com/">VS Code</a> is the default choice for many, but for me it felt heavily optimized around Copilot, which made interacting with other agents harder.</li><li><a href="https://opencode.ai/">OpenCode Desktop</a> has a nice editing experience and allows easy model switching, but only uses its own agent. Its Git integration is super basic.</li><li><a href="https://air.dev/">Air from JetBrains</a> is a nice lightweight IDE coming from a trusted vendor, but it’s very new, and at the time I tested it, it only supported a small set of agents, notably, no OpenCode or Kilo Code.</li><li>Many IDEs and coding agents obscure time spent on a task or token counts.</li></ul><p>In a way, this is understandable. AI models are still new, coding agents are even newer, and they all evolve very fast. IDEs are established products and they have a harder job than standalone agents: they need to integrate AI without breaking decades of developer workflow expectations. I have no doubt that this layer will also change quickly and adapt to AI-native development styles.</p><h3>My new AI dev setup</h3><p>None of the options looked ideal, but given how quickly things change in the AI land, any choice I make will likely be temporary.</p><p>For now, I settled on the OpenCode Desktop IDE. It is minimalistic, and its Git integration is weak, but it is good for token transparency (and I expect to run more experiments along those lines in the future.) The IDE lets me switch models, but not agents, so I am committing to the OpenCode agent for now. On the other hand, both the agent and the IDE are open-source, so I can look not only at the benchmark tests, but at the code itself, which was already useful with prompt debugging.</p><p>So, the fastest and the leanest agent was not my first choice. Trust, control, and even the comfort of a good dev environment turned out to be more important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*gz2HbqFLfi-m9nuJ" /></figure><h3>Learnings</h3><h4>Local AI makes agent overhead visible</h4><p>Model benchmarks are not enough — the same model can behave very differently depending on the coding agent wrapped around it. With a fast cloud model, many agents look “good enough.” With a slower local model, agent overhead becomes very obvious.</p><h4>Prompt size is not just a cost detail</h4><p>It is part of the agent’s personality, behavior, and safety guidelines. Fast agents may be fast because they carry fewer guardrails. That can be useful, but you have to be more careful.</p><h4>Subagents are not automatically better</h4><p>Delegation can help with complex work, but it can slow down small tasks, especially on local hardware.</p><h4>The best setup is still personal</h4><p>The dev environment is not just about personal productivity anymore; it can significantly influence your output and directly affect cost. However, it’s still about you. What you choose is not necessarily the fastest or the cheapest, but what gives you the best balance of speed, cost, control, and trust.</p><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2026/05/13/the-secret-life-of-coding-agents/"><em>http://adandai.wordpress.com</em></a><em> on May 13, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36accbf3616f" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/the-secret-life-of-coding-agents-36accbf3616f">The secret life of coding agents</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is AI an expensive hobby?]]></title>
            <link>https://pub.towardsai.net/is-ai-an-expensive-hobby-c22084291dc7?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c22084291dc7</guid>
            <category><![CDATA[ai-cost]]></category>
            <category><![CDATA[ai-subscription]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 11:48:30 GMT</pubDate>
            <atom:updated>2026-04-24T21:01:01.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>Is AI an Expensive Hobby?</h3><h4><strong>A real cost breakdown of building small AI apps over six months: where the money actually goes</strong></h4><p>My husband and I started experimenting with AI about six months ago. Since we were both on a career break, we were careful about spending. So we set a strict rule — no more than $100 per month on anything AI-related: APIs, tools, subscriptions, all of it.</p><p>I wasn’t trying to analyze the costs at the start. I just wanted to learn and stay within that budget. At the same time, the news about companies investing billions in AI — and developers talking about “burning tokens” — was hard to ignore. And I was building public apps, which meant other people could be burning <em>my</em> tokens.</p><p>Finally, I got curious: why wasn’t I running into budget issues? And where was the money actually going?</p><p>Below are the answers. It is not a deep financial analysis. It’s a simple breakdown of how much I actually spent experimenting with AI for over six months, and what surprised me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mQ5VpPAymTW5QLcJ" /></figure><h3>The grand total</h3><p>After six months, out of my total allowed $600, I spent slightly over $400. And here is what I spent it on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtWwufSvBtcdqxyUoheHVQ.png" /></figure><blockquote><em>💰 </em>My flat-rate subscription fees were higher than my metered AI usage. I had a somewhat naive assumption that subscriptions imply a volume discount and should be cheaper than paying per API call.</blockquote><h3>Metered usage vs subscriptions</h3><p>Of course, how I use ChatGPT or Cursor is very different from how I use OpenAI platform APIs. ChatGPT is for chats and architecture questions; Cursor handles all the code generation for my apps; and OpenAI APIs are for building the core logic of my apps and running them in production.</p><p>But all of them use LLMs and charge per token. So I wondered — if I paid for metered usage instead of a flat fee subscription during those 6 months, where would I end up?</p><p>I downloaded all the logs from Cursor and ChatGPT and got the overall amount of tokens, images, files processed, tools used, etc. Then I applied the rates from the latest GPT-5.4 model to see if I was under or overpaying.</p><p>GPT-5.4 pricing:</p><ul><li>Input: $2.50 / 1M tokens</li><li>Output: $15 / 1M tokens</li><li>Images: $0.17 per image (estimated)</li><li>Uploaded image processing: $0.015</li><li>Web search: $0.01 per call</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I6Jr99RJQaeAJUZ_lUCxuA.png" /></figure><blockquote><em>💰</em>Ouch! I am overpaying 2x for Cursor and 6x for ChatGPT compared to what I would have paid with metered usage. But these tools don’t offer a pay-per-use option. Also, subscriptions made it easier to work without interruptions or hitting limits. Whether that’s worth the price is still an open question.</blockquote><h3>Development vs Production cost</h3><p>Another insight I got right away is that the development cost of AI apps is way higher than running my apps in production. Here is another way to look at the same data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gyGvcU2UuOpyHnmGKUSmEQ.png" /></figure><p>Both ChatGPT and Cursor subscriptions are pure development cost, Render is pure production cost, but OpenAI is a mixture of both. To split this line into production vs development costs I needed a deep dive into OpenAI API logs and billing data.</p><p>After 6 months I ended up with two small apps:</p><ul><li><a href="https://lotr-steps-game.onrender.com/">A small text adventure game based on The Lord of the Rings (LOTR)<br></a>This one uses OpenAI APIs to generate a different journey depending on the player’s input. All I use here is the Responses API. I played a little bit with images, but quickly abandoned the idea because they were too expensive.</li><li><a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra (VA)<br></a>A chatbot that answers users’ questions based on my writing and instructions using APIs and retrieval augmented generation (RAG) from OpenAI. I also tried fine-tuning (didn’t work) and did a bunch of data preparation for RAG, including translating several MB of text from Russian into English and vice versa.</li></ul><p>I used different API keys for production and development of both apps, so I could see how much I spent on each of them. Images and fine-tuning are not used in production, but they are still part of the development cost — you pay even if you fail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adKODF0yw6q4DjPXp9PNCw.png" /></figure><blockquote><em>💰</em>Most of my AI spend went into development, not production. The production cost is about 10 percent of the total ($41 out of $422).</blockquote><p>Apparently, my fear of public apps becoming a money sinkhole didn’t materialize. Partially this is because of low usage — I had about a hundred people try my apps. And these are not productivity apps people would use every day, there is no stickiness in them.</p><p>But another reason is that I was more careful with what I put in production. I optimized system prompts and discarded expensive features like images. One question that Virtual Alexandra answers costs me $0.088 — less than ten cents. Ten steps in the LOTR game cost $0.037 — about four cents.</p><h3>Local models vs paid APIs</h3><p>$600 was our family total AI budget, and I spent more than $400. How much did my husband spend? Well, the answer is … $0. Our interests led us into different experiments: I wanted something I could share with other people, while he was happy exploring how he can improve his day-to-day coding and test the power of the local models. But that zero is deceiving. Here is what actually happened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2EP-_OG_LN2ucTBUu6e-Q.png" /></figure><blockquote><em>💰</em>I paid for convenience and speed, while my husband Dmitry paid upfront in hardware and setup effort.</blockquote><p>We didn’t buy new laptops, we used what we had in the house. If you happen to have a powerful computer already and want to start your vibe coding journey, you can spend exactly $0. If your computer is from Apple, read Dmitry’s <a href="https://github.com/dmitryryabkov/local-ai-mac">guide on setting up local AI on a Mac</a> to get started.<br>But if you only have an old MacBook Air, you can still go ahead — it will be way cheaper to start experimenting with paid subscriptions and APIs instead of investing in new hardware upfront.</p><h3>Learnings</h3><h4>AI is an affordable hobby</h4><p>All my data is related to small scale apps and experiments, it doesn’t apply to corporate, startup, or deep research worlds. But for a casual hobby, just set your budget. Without watching tokens or hours and never hitting any hard limits, I was able to keep it under $100 a month.</p><h4>At small scale, the true cost is app development, not running in production</h4><p>Public APIs turned out to be cheaper than I expected. Unless you build a really viral app, you are very unlikely to burn a crazy amount of money. The two apps I created each cost less than ten cents per user session, so I can afford hundreds of daily users without exceeding my monthly budget.</p><p>However, development costs add up quickly. Experimenting with features like fine-tuning and image generation can easily dominate the total spend, even when production usage stays low.</p><h4>AI subscriptions provided less value than I would like</h4><p>It’s worth looking at your AI subscriptions — are you maximizing their value? And if not, are you paying for something else like a good uninterrupted workflow? One of my personal takeaways from this write-up is to dig deeper into this and see how much I really need these services and whether I can replace them with local AI setup.</p><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2026/04/23/is-ai-an-expensive-hobby/"><em>http://adandai.wordpress.com</em></a><em> on April 23, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c22084291dc7" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/is-ai-an-expensive-hobby-c22084291dc7">Is AI an expensive hobby?</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical guide to running LLMs locally on Apple Silicon]]></title>
            <link>https://pub.towardsai.net/practical-guide-to-running-llms-locally-on-apple-silicon-c5c9879d5270?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5c9879d5270</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[open-code]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 21:01:01 GMT</pubDate>
            <atom:updated>2026-04-15T16:12:32.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>Running LLMs locally on Apple Silicon</h3><h4>A practical guide to architecture, memory scaling, and agents</h4><blockquote>This article was written by <a href="https://www.linkedin.com/in/dryabkov/">Dmitry Ryabkov</a>, with editing and review by <a href="https://www.linkedin.com/in/alexandra-rusina-32651324/">Alexandra Rusina</a>.</blockquote><p>Running AI models locally sounds simple in theory: more control, better privacy, no API costs. In practice, it quickly turns into a series of trade-offs between performance, model quality, hardware limits, and developer experience.</p><p>This is a comprehensive guide on how to run AI models and coding agents locally on a Mac. It consolidates information scattered across the internet into a single, practical resource. If you have a spare Mac lying around, you can turn it into an “LLM server” and use it instead of paying for OpenAI, Claude, etc.</p><p>You’ll need a decent amount of RAM for this to work. Around 32GB is where things start getting interesting. I’m currently running 30B-class models with the same 128K context window as OpenAI Codex on an M3 MacBook Pro with 36GB of RAM — all locally.</p><p>The architecture of Apple’s M-series chips suits this type of workload. AI models benefit from GPUs with access to large amounts of memory. Macs, with their unified memory architecture — where GPU cores can access nearly all available RAM — become a viable alternative to consumer GPUs (which often ship with much less memory). Even NVIDIA has started moving in this direction with systems like <a href="https://www.nvidia.com/en-us/products/workstations/dgx-spark/">DGX Spark</a>.</p><p>Standalone GPUs still have more raw compute throughput, to set expectations correctly. But for many advanced workflows, Apple Silicon is a great alternative environment.</p><blockquote><em>⚠️ </em>This guide assumes familiarity with LLM concepts, inference engines, and basic system configuration. It is intended for developers building local AI systems or experimenting with agent workflows.</blockquote><h3>Part I — Architecture Decisions</h3><p><strong><em>Before installing anything, it helps to understand the architectural building blocks: model formats, inference engines, quantization, and memory trade-offs. These decisions determine everything that follows.</em></strong></p><p>This is a very simple diagram of all the components we’ll be looking at:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l6OaukK70WpE6PoN.png" /></figure><h4>Inference Engines</h4><p>An AI model, for the most part, is just a huge collection of numbers — the so-called “model weights”. <strong>Inference Engine</strong> is where the actual linear algebra operations on the model weights happen when a model generates tokens. As of right now, there’s no built-in general-purpose inference engine in MacOS, but there are free and/or open-source Mac inference engine implementations:</p><ul><li><a href="https://github.com/ml-explore/mlx-lm">MLX-LM</a> — developed by Apple and is highly optimized for Apple silicon. It is build around <a href="https://en.wikipedia.org/wiki/Metal_(API)">Metal API</a> and gives the fastest straight-up token generation of any engine I tried.</li><li><a href="https://github.com/ggml-org/llama.cpp">llama.cpp</a> — a cross-platform engine, and as a result is not as highly optimized for Apple hardware as MLX is despite using the same Metal API (it is about 20%-30% slower on token generation for the same model on the same hardware).</li></ul><p>MLX-LM development feels somewhat sluggish, usually a month or two behind the current State of the Art (SOTA) models and performance optimization algorithms. llama.cpp has a much faster pace of development and feels like a very mature product overall. It tends to support new SOTA models and optimization techniques earlier, often working out of the box or with parameter adjustments that MLX may not yet expose.</p><p>If you’ve used AI models before, you might know <a href="https://huggingface.co/docs/transformers/en/index">HuggingFace Transformers</a>, but it’s primarily for research and not as fast or memory-efficient as the two above.</p><p><strong><em>In short: MLX gives you peak Apple-optimized throughput; llama.cpp gives you flexibility, faster feature adoption, and broader model support.</em></strong></p><h4>LLM API Servers</h4><p>Inference engine is just the first part in the overall local AI setup. To interact with a model — either through a web interface or for coding tools and agents to call an LLM via APIs — it needs to be wrapped in an LLM API server. Both MLX-LM and llama.cpp come with such capabilities, but:</p><ul><li>MLX-LM is a very-very limited LLM server. In fact, it doesn’t even have a web UI, and doesn’t have a Claude Code compatible API endpoint.</li><li>llama.cpp is a pretty decent LLM API server and can absolutely be used as-is.</li><li><a href="https://lmstudio.ai/">LM Studio</a> is an alternative to MLX-LM. It uses some bits and pieces of MLX-LM engine internally, thus it offers the same Apple-optimized performance, as a desktop app (or as a “headless” server). It even supports llama.cpp as an alternative backend engine, but I don’t really see any practical use for this feature given that llama.cpp itself is a pretty good API server.</li></ul><p>There’s also <a href="https://ollama.com/">Ollama</a>, which is an LLM API server as well built on top of llama.cpp. It has a nice interface and it is really easy to configure the coding tools to use with it, but it significantly reduces the flexibility and configurability of llama.cpp to achieve that ease of use, to the point of being pretty much unusable for SOTA models. For that reason I won’t be focusing on it at all here.</p><p><strong>Practical Recommendations</strong></p><p>Install both LM Studio and llama.cpp. There’s practically no cost associated with having both installed, and even having them running at the same time, assuming the models are loaded dynamically.</p><p>The logic for choosing which one to use might go like this:</p><ol><li>If the model you want to use, as well as its performance optimizations, are fully supported by LM Studio, go with it. The performance advantage of the Apple silicon optimized solution is totally worth it.</li><li>If the model you want to use is not yet supported by LM Studio, or there is a setting or a performance optimization trick you can only get with llama.cpp, go with llama.cpp.</li></ol><p><strong><em>With that architectural foundation in place, the next question becomes: what models should you actually run?</em></strong></p><h4>Models</h4><p>With each new generation of open-source/open-weight models released they’re getting smaller and, at the same time, smarter, and it now feels like we can get something useful out of them on our consumer hardware. The main “metric” which defines how smart a model potentially is, and how much memory and processing power it needs, is the <strong>number of parameters</strong>, or number of weights, which can range from less than a billion to more than a trillion. Number of parameters is usually mentioned next to the model name (i.e. Qwen3.5-27B means that it is a 27 billion parameter model).</p><p>There are two main types of models right now:</p><ul><li><strong>Dense</strong> models — all parameters participate in token generation. This is the type assumed by default if nothing else is specified.</li><li><strong>Sparse</strong> or <strong>Mixture of Experts (MoE)</strong> models — only some weights (active parameters) are used per token. They usually have the number of active parameters appended to their name. For example, Qwen3.5-35B-A3B is a 35B <strong>total</strong> parameter model, but only 3B of those are used to generate the next token. Which specific ones (the &quot;experts&quot; for this token) is dynamically decided by the model itself.</li></ul><p>For both types the <strong>total</strong> number of parameters translates directly into <strong>memory requirements</strong>, but the processing power required depends more on the number of <strong>active</strong> parameters. Since for dense models all parameters are active, similarly sized MoE models are significantly faster while at the same time being equally capable or even better.</p><p>There are two formats supported by the recommended inference engines:</p><ul><li>MLX — Mac-specific model format (usually designated with “MLX” name or logo.)</li><li>GGUF — llama.cpp model format created specifically for this engine, supports more advanced models and faster loading.</li></ul><p>LM Studio supports models in both formats (because it supports both inference engines). llama.cpp supports GGUF format only.</p><p>Medium-size models (~20–30B parameters) fit into higher tier consumer hardware and are getting good enough for practical usage. Here are some examples:</p><ul><li><a href="https://huggingface.co/Qwen/Qwen3.5-35B-A3B">Qwen3.5–35B-A3B</a> — 35 billion parameter Mixture of Experts model with 3 billion active parameters</li><li><a href="https://huggingface.co/Qwen/Qwen3.5-27B">Qwen3.5–27B</a> — 27 billion parameter dense model</li><li><a href="https://huggingface.co/zai-org/GLM-4.7-Flash">GLM-4.7-Flash</a> — 30 billion parameter Mixture of Experts model, 3 billion active parameters</li></ul><p>The links above point to the “canonical” versions of these models — the so-called “model cards”. They contain a lot of useful information about the models, and even have links to download them, but only in the “canonical” <a href="https://huggingface.co/docs/safetensors/index">Safetensors</a> format which is not directly usable with the inference engines discussed here.</p><p>After a model is released in the “canonical” format, it gets converted to more usable MLX and GGUF versions by the open-source community. And since with the right tool pretty much anyone can do it, a lot of people and organizations publish their own versions of the same model. It’s a little bit of a “wild west” out there with so many variations available to download. How to find the right one? I’d suggest looking into “official” (if there’s such a thing in the open-source world) communities:</p><ul><li>MLX versions of the models are released by <a href="https://huggingface.co/mlx-community">MLX Org community on HiggingFace</a>. Alternatively, <a href="https://huggingface.co/lmstudio-community">LM Studio community</a> releases some MLX models as well, usually suffixed with &quot;-MLX&quot; after the model name.</li><li>For GGUF models the best community to grab the models from is <a href="https://huggingface.co/unsloth">Unsloth</a>. Some of the models are also converted to GGUF and released by <a href="https://huggingface.co/ggml-org">ggml-org</a> (the org behind llama.cpp) and LM Studio (similarly to their MLX models, postfixed with &quot;-GGUF&quot;), but these communities are less active and less organized comparing to Unsloth.</li></ul><p><strong><em>Which brings us to one of the most important practical topics in local AI: quantization.</em></strong></p><h4>Quantization</h4><p>The “canonical” models downloadable from the model cards usually have their weights represented by high-precision <a href="https://en.wikipedia.org/wiki/Bfloat16_floating-point_format">bfloat16</a> data type (stands for “brain floating point” 🤯, developed by Google Brain group), an AI-frendlier version of 16-bit float. This data type gives best fidelity, but the models are large and inference is slow. In this format the recommended models are ~60GB each just for weights (~30B × 16 bits) and require significantly more at runtime due to various caches and buffers. Realistically, a 96GB of RAM is needed to run comfortably at that precision.</p><p>To reduce size and speed up inference, models can be converted to a lower-resolution data type at the cost of some generation quality (accuracy) loss — the process called <strong>quantization</strong>. An intuitive analogy is the precision of <strong>π</strong>: sometimes you need high precision, i.e. 3.1415926535..., but 3.14 is often good enough. Of course, the actual quantization algorithms used to produce the quantized models are more sophisticated than just rounding the number, but the analogy still serves for illustrative purposes. If you&#39;re interested in the specific algorithms and approaches I recommend watching <a href="https://youtu.be/qoQJq5UwV1c?si=oJuztkwQV8th0GF-">this video</a> which explains it really well.</p><p>General rules of thumb for quality loss:</p><ul><li><strong>Q8(8-bit)</strong>: less than 1% loss in accuracy, practically indistinguishable from 16-bit, but only about half the size of the original model</li><li><strong>Q6(6-bit)</strong> and <strong>Q5(5-bit)</strong>: minimal loss, very close to 16-bit, ~1/3 of the original model size</li><li><strong>Q4(4-bit)</strong>: standard for local use, between 1% and 5% loss in accuracy, at roughly 1/4 size of the original model</li><li><strong>Q3(3-bit) and below</strong>: noticeable degradation</li></ul><p>The number after <strong>Q</strong> corresponds to the number of “Bits per Weight (BPW)” for the majority of the model weights. Some of the model weights may still be at the original resolution, or quantized to a higher-precision type than the overall model, but it is a small portion of the overall model weights and it doesn’t affect the value after <strong>Q</strong>. MLX models usually available for download at all these quantization levels.</p><p>GGUF models started with the same quantization approach, but since then moved to <a href="https://unsloth.ai/docs/basics/unsloth-dynamic-2.0-ggufs">Unsloth Dynamic</a> quantization mechanism. Effective (BPW) is higher with this mechanism than with the more straightforward one used by MLX, resulting in “fractional” quants.</p><p>The table below compares MLX “whole” quants to GGUF “fractional” quants and approximates their BPW and size reduction. You can see that the higher-tier GGUF quants behave closer to the next MLX quant tier while remaining slightly smaller:</p><p>Practical guidance:</p><ul><li>If you can run a 4-bit version, you’re in a good spot already, even if it is the best your system can do. It’s ~4x smaller with minor accuracy loss.</li><li>GGUF Q4_K_M is the &quot;Q4.5 sweet spot&quot; for llama.cpp.</li><li>If you have more RAM, try 5-bit or 6-bit versions (higher-tier quants for GGUF models). At these quantization levels models are barely distinguishable from the original.</li><li>If you have enough RAM for 16-bit, great. But consider a quantized larger model instead — you can run a ~3–4x larger model at reasonable quantization, which may give you noticeably better results.</li></ul><p>A useful heuristic: model file size should be ~60% of the amount of your RAM for useful results. With 32GB RAM you can run ~20GB disk size models.</p><blockquote><em>💡 </em><strong><em>Tip:</em></strong><em> You can see model file sizes and fit estimates in LM Studio’s model browser for both GGUF and MLX models.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TEzAGIJgBVUPPcJm.png" /></figure><h4>Configuring VRAM</h4><p>Inference runs significantly faster when models use GPU cores instead of CPU cores, requiring them to reside in VRAM. Even though Macs have “Unified Memory”, GPUs can only use some of it as VRAM.</p><blockquote><em>💡 </em><strong><em>Tip: Checking the amount of VRAM on your Mac</em></strong><em><br> In LM Studio, click the “App Settings” gear icon in the bottom left corner, navigate to the “Hardware” tab, and you’ll see the available VRAM in the “Memory Capacity” section:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*S6dVvDfNVbET0xh8.png" /></figure><p>The default VRAM setting Macs come with is too low. To increase it, run:</p><pre>sudo sysctl iogpu.wired_limit_mb=&lt;XXX&gt;</pre><p>Where XXX is the memory in MBs to allow as VRAM. Calculate by subtracting 8GBs from your total unified memory and converting to MBs. For my 36GB system this translates to 36GB-8GB=28GB, and 28GB is 28672MB, so:</p><pre>sudo sysctl iogpu.wired_limit_mb=28672</pre><p>There are M-series Macs which only have 8GBs, so this should be reasonable. You can go higher, but system stability may decrease.</p><blockquote><strong><em>Note: this setting is not persistent across reboots and may change across macOS versions. Use cautiously.</em></strong></blockquote><h3>Part II — Running Models</h3><p><strong><em>Now that we’ve covered architectural decisions — engine, format, quant, and memory — let’s move into actually running models.</em></strong></p><h4>Installing LM Studio</h4><p>Go to the <a href="https://lmstudio.ai/">web site</a>, download, install, run.</p><h4>Installing llama.cpp</h4><p>The easiest way is via one of the package managers it <a href="https://github.com/ggml-org/llama.cpp/blob/master/docs/install.md">supports</a>, i.e. Homebrew:</p><pre>brew install llama.cpp</pre><p>Alternatively, it can be <a href="https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md">built from source</a>, but this only makes sense if you need an immediate bug fix or feature before the release process completes.</p><h4>Downloading and Running Models</h4><p><strong>With LM Studio</strong></p><ul><li>Go to “Model Search” on the left-hand side or the app.</li><li>Type the model name and quantization level, choose MLX or GGUF or both in the Format picker</li><li>Select from a creator or community, hit “Download”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ervh99UgRCu4xKd1.png" /></figure><ul><li>Go to “Chat” on the left, select the model from the dropdown on the top, and start chatting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XzjnwAmuSRumSZf_.png" /></figure><p><strong>With llama.cpp</strong></p><ul><li>Find the model on <a href="https://huggingface.co/models">HuggingFace Models portal</a>, preferably Unsloth version</li><li>Choose the quant type on the right, and click on it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*ZvGcBLTM6hXZ0Jpu.png" /></figure><ul><li>Click “Use this model” dropdown and choose llama.cpp</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*DoDQ9EEiU8iGxobi.png" /></figure><ul><li>On the next screen you’ll see the command to launch:</li></ul><pre># Start a local OpenAI-compatible server with a web UI: <br>llama-server -hf unsloth/Qwen3.5-35B-A3B-GGUF:Q4_K_M</pre><ul><li>Go to <a href="http://localhost:8080/">http://localhost:8080</a> and chat with the model:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MPU_eOpN9YBKsqfL.png" /></figure><blockquote><em>💡 </em><strong><em>Tip:</em></strong><em> You can download a GGUF model using LM Studio and use it in both LM Studio </em><strong><em>and</em></strong><em> llama.cpp. In LM Studio’s “My Models” tab, check the folder at the bottom (or change it for easier access). Then run:</em></blockquote><p>You can now use your local model like cloud models — ask questions, write/summarize text, or write code. Results may not match larger cloud models but are still quite good.</p><blockquote><em>💡 </em><strong><em>Tip:</em></strong><em> When generating, you want the GPU at or near 100%. You can check with Activity Monitor (Window → GPU History), or with </em><a href="https://github.com/metaspartan/mactop"><em>mactop</em></a><em> for more detail.</em></blockquote><h3>Part III — Config Settings</h3><p>In this section I’ll explain various “levers” to control model behavior and Inference Engine / API Server settings</p><h4>Context Window</h4><p>This is by far the most important model parameter. This controls how much information can be sent to a model. For multi-turn conversations, all previous requests <strong>and model responses</strong> are sent back, so the context window can grow very large.</p><p>Context Window is measured in <strong>tokens</strong> — individual words or parts of words get converted to tokens. The exact algorithm belongs to the model itself, and may differ from one model to another, but for English, assuming every 3–4 characters is a token is a reasonable approximation. Tokenization for programming languages differs heavily, as well as for Chinese/Japanese.</p><p>Current SOTA cloud models context window size:</p><ul><li>ChatGPT — 128K</li><li>Claude models (non-enterprise) — up to 200K</li></ul><p>Local models running on LM Studio or llama.cpp can match these magnitudes. Just be aware that context window size affects memory consumption — the larger the model, the less room for context window.</p><p>How to set context window size:</p><ul><li>In LM Studio: enable “Manually choose model load parameters” on the model selector dialog, then set “Context Length”. The tool will show you the max content window size supported by the model.</li><li>In llama.cpp: Use the -c parameter. If you don&#39;t specify it, llama.cpp will default to the maximum size supported by the model.</li></ul><h4>Sampling Settings</h4><p>These control accuracy and “creativity” of the model responses: temperature, top-k, top-p and min-p. Check the model card on HuggingFace for recommended values for both regular question answering and coding respectively.</p><p>In LM Studio: “My Models”→ gear icon next to model → “Inference” tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*4JWYy9dq6_72yDAX.png" /></figure><p>In llama.cpp: llama-server parameters:</p><pre>llama-server -hf &lt;model&gt; --temp 0.6 --top-p 0.95 --min-p 0.01 --top-k 20</pre><blockquote><em>💡 </em><strong><em>Tip:</em></strong><em> Some models recommend </em><em>min-p set to </em><em>0, but in llama.cpp </em><em>0 means &quot;disabled&quot;. Use a small value like </em><em>0.01 instead. Similarly, </em><em>--top-p 1.0 disables </em><em>top-p and </em><em>--top-k 0 disables </em><em>top-k.</em></blockquote><h4>Thinking Mode</h4><p>All current SOTA models have a “thinking” mode where the model creates a step-by-step strategy before answering the question. You can see it in both LM Studio and llama.cpp when “Thinking…” appears in the response window.</p><p>In some cases it might be better to disable this mode, either because it takes longer for the model to answer a question or the model gives better results without it. To do that you have to modify the “chat template” your prompts are wrapped into when sent to the model.</p><p>In LM Studio: bottom of “Model Settings” → “Prompt Template” text field, add at the beginning:</p><pre>{%- set enable_thinking = false %}<br>...</pre><p>In llama.cpp: it is a CMD line parameter: --chat-template-args &quot;{\&quot;enable_thinking\&quot;:false}&quot;</p><h4>Flash Attention</h4><p><a href="https://en.wikipedia.org/wiki/Attention_(machine_learning)#Flash_attention">Flash attention</a> is an optimization important for large contexts — it breaks the overall context into smaller, more GPU-digestable chunks. It improves attention computation speed and memory locality, but does NOT reduce prompt cache size.</p><p>In LM Studio it is enabled by default.</p><p>To enable in llama.cpp add this parameter:</p><pre>-fa on</pre><h4>Prompt Cache</h4><p>Agents send huge prompts, but the first part is agent instructions and is always the same. <strong>Prompt Cache</strong> is a feature available in both LM Studio and llama.cpp which avoids reprocessing it over and over again. However, it is a little finicky and may not work for the most recent models until a new version of the inference engine drops with a fix to explicitly addressing this gap.</p><p>It is <strong>critical</strong> for having good agentic coding experience for this feature to work properly.</p><blockquote><em>💡 </em><strong><em>Tip: Checking that Prompt Cache works</em></strong></blockquote><ul><li>Create a large prompt. It doesn’t need to be created manually, ask the model to write a 10,000-word essay. Don’t worry, you don’t have to read it 😉.</li><li>Create a new chat, paste it and add “Summarize the text above in one sentence”, and send.</li><li>You’ll see “Processing…” in the response window for noticeable time. This is prompt processing without the cache.</li><li>Once you get the response, ask the model a follow-up question: “Now expand it to a paragraph”.</li><li>If prompt cache works, barely any “Processing…” is visible the second time, because the second request is 99%+ the same as the first one, the only new thing is the follow-up question. If experience is the same as the first time, prompt caching doesn’t work.</li></ul><blockquote><em>⚠️ </em><strong><em>Warning:</em></strong><em> As of right now, Prompt Caching doesn’t work for Qwen3.5 models in LM Studio due to </em><a href="https://github.com/lmstudio-ai/lmstudio-bug-tracker/issues/1563"><em>this bug</em></a><em>. Use llama.cpp for these models.</em></blockquote><h3>Part IV — Configuring API Servers for Agentic Workflows</h3><p><strong><em>Everything above allows you to run a model. But the real power comes when you wire it into coding agents.</em></strong></p><p>Agentic coding with Claude Code or Codex is all the rage right now, but it can be quite expensive in the cloud. Locally, you control not only the cost, but privacy as well.</p><p>However, agents dramatically increase:</p><ul><li>Context window usage</li><li>Parallel requests</li><li>Prompt size</li></ul><h4>Context Window for Agents</h4><p>Agents put A LOT of instructions in the prompt even before you start doing anything. OpenCode uses 12K+ tokens, Claude Code uses 20K+! Add your prompt and source code on top of that. So you want at least 65K context window to get anything done, ideally 128K+. Adjust the settings accordingly.</p><h4>Parallel Requests</h4><p>Claude Code in Agent Teams mode (a.k.a. “Agent Swarm”) can run multiple agents in parallel, but it uses A LOT of context window memory on the API server. If your model barely fits, consider using a smaller model and leave more room for the parallel request context window.</p><p>This is how you can control parallel requests:</p><p><strong>Only one request</strong></p><ul><li>Default in LM Studio</li><li>For llama.cpp specify both context window size and number of parallel requests:</li></ul><pre>-c 131072 -np 1</pre><p><strong>Multiple requests</strong></p><ul><li>In LM Studio (currently an “Experimental” feature) set “Max Concurrent Predictions” in model parameters</li><li>For llama.cpp, you need to specify <strong>total</strong> context across all parallel requests. For example, if you want to allow up to 4 parallel requests, you need to multiply context window size by 4. In the example below, the setting does <strong>not</strong> give each agent 524K tokens. It allocates a shared 524K token pool across 4 parallel sequences.</li></ul><pre>-c 524288 -np 4</pre><h4>Tool Calling</h4><p>Tool calling is where local models move from passive text generators to active execution components inside agent loops. Agents can use tools like Web Search, read/write local files, execute Bash scripts, and so on.</p><p>It is enabled by default in LM Studio, but you need to explicitly set this parameter in llama.cpp to enable it:</p><pre>--jinja</pre><h4>Starting API Servers</h4><p>Here’s an example how to start llama.cpp server with the essential parameters I discussed above:</p><pre>llama-server -hf unsloth/Qwen3.5-35B-A3B-GGUF:Q4_K_M --jinja -fa on --temp 0.6 --top-p 0.95 --min-p 0.01 --top-k 20 -c 131072 -np 1</pre><p>LM Studio is a desktop app at its core, but it can function as an API server as well. Go to “Developer” tab and start the server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t0tHrvGC_sXDdIcQ.png" /></figure><p>Configure port, authentication, and network access in “Server Settings” if needed. Click “Load Model” and choose your model. Previously configured parameters respected by the server.</p><h3>Part V — Installing and Configuring Coding Agents</h3><p>Finally, after all the architectural decisions and configuration setting it’s time to get to coding agents. I’ll cover 2 most popular ones.</p><h4>OpenCode</h4><p>If you don’t have OpenCode installed yet, follow <a href="https://opencode.ai/">instructions</a> to install it using your preferred method. Modify ~/.config/opencode/opencode.json and add one of the following providers (or both) and models they host:</p><pre>{<br>  &quot;$schema&quot;: &quot;https://opencode.ai/config.json&quot;,<br>  &quot;provider&quot;: {<br>    &quot;lmstudio&quot;: {<br>      &quot;npm&quot;: &quot;@ai-sdk/openai-compatible&quot;,<br>      &quot;name&quot;: &quot;LM Studio (local)&quot;,<br>      &quot;options&quot;: {<br>        &quot;baseURL&quot;: &quot;http://127.0.0.1:1234/v1&quot;<br>      },<br>      &quot;models&quot;: {<br>        &quot;mlx-community/GLM-4.7-Flash-5bit&quot;: {<br>          &quot;name&quot;: &quot;GLM 4.7 Flash (5bit)&quot;<br>        }<br>      }<br>    },<br>    &quot;llama.cpp&quot;: {<br>      &quot;npm&quot;: &quot;@ai-sdk/openai-compatible&quot;,<br>      &quot;name&quot;: &quot;llama-server (local)&quot;,<br>      &quot;options&quot;: {<br>        &quot;baseURL&quot;: &quot;http://127.0.0.1:8080/v1&quot;<br>      },<br>      &quot;models&quot;: {<br>        &quot;Qwen3.5-27B&quot;: {<br>          &quot;name&quot;: &quot;Qwen3.5-27B (local)&quot;,<br>          &quot;modalities&quot;: { &quot;input&quot;: [&quot;image&quot;, &quot;text&quot;], &quot;output&quot;: [&quot;text&quot;] },<br>          &quot;limit&quot;: {<br>            &quot;context&quot;: 131072,<br>            &quot;output&quot;: 32768<br>          }<br>        },<br>        &quot;Qwen3.5-35B-A3B&quot;: {<br>          &quot;name&quot;: &quot;Qwen3.5-35B-A3B (local)&quot;,<br>          &quot;modalities&quot;: { &quot;input&quot;: [&quot;image&quot;, &quot;text&quot;], &quot;output&quot;: [&quot;text&quot;] },<br>          &quot;limit&quot;: {<br>            &quot;context&quot;: 131072,<br>            &quot;output&quot;: 32768<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Start OpenCode and select your provider and model from the model drop-down.</p><h4>Claude Code</h4><p>Follow <a href="https://code.claude.com/docs/en/overview">official instructions</a> to install it, if needed.</p><p>Claude Code uses environment variables to point itself to the API server. One way is to set these variables right before the command, this makes it easier to switch between inference engines.</p><p>For LM Studio:</p><pre>ANTHROPIC_BASE_URL=&quot;http://localhost:1234&quot; ANTHROPIC_API_KEY=&quot;none&quot; CLAUDE_CODE_AUTO_COMPACT_WINDOW=131072 claude --model glm-4.7-flash</pre><p>For llama.cpp:</p><pre>ANTHROPIC_BASE_URL=&quot;http://localhost:8080&quot; ANTHROPIC_API_KEY=&quot;none&quot; CLAUDE_CODE_AUTO_COMPACT_WINDOW=131072 claude --model unsloth/Qwen3.5-35B-A3B</pre><p>Alternatively, set these variables in the config file ~/.claude/settings.json. For Agents Team (a.k.a. &quot;Agent Swarm&quot;) you have to set them in the config file to make them available to the agents when they spawn, plus you have to set some additional values:</p><pre>{<br>  &quot;env&quot;: {<br>    &quot;CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS&quot;: &quot;1&quot;,<br>    &quot;CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC&quot;: &quot;1&quot;,<br>    &quot;CLAUDE_CODE_ENABLE_TELEMETRY&quot;: &quot;0&quot;,<br>    &quot;CLAUDE_CODE_ATTRIBUTION_HEADER&quot; : &quot;0&quot;,<br>    &quot;ANTHROPIC_BASE_URL&quot;: &quot;http://localhost:1234&quot;,<br>    &quot;ANTHROPIC_API_KEY&quot;: &quot;none&quot;,<br>    &quot;CLAUDE_CODE_AUTO_COMPACT_WINDOW&quot;: &quot;131072&quot;<br>  },<br>  &quot;preferences&quot;: {<br>    &quot;tmuxSplitPanes&quot;: true<br>  }<br>}</pre><blockquote><em>⚠️ </em><strong><em>Warning:</em></strong><em> Agent Teams use A LOT of memory on the API server ⚠️</em></blockquote><h4>Loading Models Dynamically</h4><p>If you switch models often, loading/ejecting them in LM Studio or restarting llama.cpp might be annoying. Fortunately, both support loading models dynamically from the OpenCode model selector or Claude Code --model parameter (you&#39;d still need to restart Claude Code each time though, which would still be annoying 😒).</p><p>In LM Studio Server Settings, enable “Just-in-Time Model Loading” and that’s it.</p><p>In llama.cpp, provide an .ini file with models and their parameters:</p><pre>[Qwen3.5-35B-A3B-UD-Q4_K_XL]<br>model = &lt;models-folder&gt;/unsloth/Qwen3.5-35B-A3B-GGUF/Qwen3.5-35B-A3B-UD-Q4_K_XL.gguf<br>ctx-size = 131072<br>temp = 0.7<br>top-p = 0.95<br>min-p = 0.01<br>top-k = 20</pre><p>Start llama.cpp with --models-preset &lt;ini-file-path&gt; instead of -hf or -m parameter. Keep the <strong>server</strong> parameters (those not in the .ini file) in the start command.</p><h3>Closing Thoughts</h3><p><strong><em>Local AI on a Mac is no longer a toy experiment. With the right architectural choices — especially around quantization, context window sizing, and prompt caching — it becomes a viable daily driver for advanced workflows.</em></strong></p><p>The result may not match trillion-parameter cloud models, but it is surprisingly capable — and entirely under your control.</p><p><em>Originally published at </em><a href="https://github.com/dmitryryabkov/local-ai-mac"><em>https://github.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5c9879d5270" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/practical-guide-to-running-llms-locally-on-apple-silicon-c5c9879d5270">Practical guide to running LLMs locally on Apple Silicon</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Very Fine Untuning]]></title>
            <link>https://pub.towardsai.net/a-very-fine-untuning-878e4ef285ff?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/878e4ef285ff</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 13:09:11 GMT</pubDate>
            <atom:updated>2026-04-01T22:01:01.372Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong><em>How fine-tuning made my chatbot worse (and broke my RAG pipeline)</em></strong></h4><p>I spent weeks trying to improve my personal chatbot, <a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra</a>, with fine-tuning. Instead I got increased hallucination rate and broken retrieval in my RAG system.</p><p>Yes, this is a story about a failed attempt, not a successful one. My husband and I called fine tuning results “Drunk Alexandra” — incoherent answers that were initially funny, but quickly became annoying. After weeks of experiments, I reached a simple conclusion: for this particular project, a small chatbot that answers questions based on my writing and instructions, fine tuning was not a good option. It was not just unnecessary, it actively degraded the experience and didn’t justify the extra time, cost, or complexity compared to the prompt + RAG system I already had.</p><p>This post is a breakdown of what I tried, what failed, and what this experience reveals about fine-tuning in real-world systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*WPpluEpScEnUQwio" /></figure><h3>What is fine tuning and why would you need it?</h3><p>Let’s start with the definition. Fine tuning is a process where you take an existing AI model and further train it to make it more specialized in a certain field (like medical or legal) or to introduce style and behavioral changes.</p><p>The thing about my current implementation of Virtual Alexandra — a simple RAG system with prompt engineering on top of a base model — is that it still doesn’t really sound like me. We can all guess when a text is written by ChatGPT now — there is a certain choice of words and structure that just points to the author. I can hear ChatGPT’s voice in Virtual Alexandra’s answers, and I would love to make it less pronounced. Fine tuning promised exactly that.</p><p>In theory, it should have been on the same level of complexity as using RAG. And at first glance, it really looked simple. I produced a so-called “instruction dataset”. It usually consists of the user’s input and the expected answer from the model. The format can vary depending on the model, but here is an example for OpenAI in JSONL:</p><pre>{&quot;messages&quot;:[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;What’s your favorite kind of weather?&quot;},{&quot;role&quot;:&quot;assistant&quot;,&quot;content&quot;:&quot;Nice and sunny.&quot;}]}</pre><p>OpenAI’s recommendation is to have at least 50 entries. My dataset included about 1000.</p><p>The next step is to either find an online model to fine tune (OpenAI offers a few with a super intuitive UI), or run experiments locally.</p><p>But as is typical with AI, “simple” doesn’t mean “good”. So let’s dive into the different issues I had to battle with.</p><h3>Refined hallucinations</h3><p>The main problem I encountered after fine tuning, no matter which model I tried, was increased hallucinations. I will start with examples from <strong>gpt-4o-mini-2024–07–18 </strong>simply because it is the cheapest model OpenAI offers. With my 3 MB of training data containing ~1000 entries the fine tuning job took about 45 minutes.</p><p>I was shown some nice graphs with reassuring training metrics — loss was decreasing, accuracy increasing — everything looked exactly the way you’d expect when things are working. However, none of these metrics tell you whether the model will actually produce good answers or start hallucinating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*ADxqEv3WPB7lMvzz" /></figure><p>Things looked less exciting when I ran my own tests. I sent identical requests in parallel to three different models — base gpt-4o-mini, fine-tuned gpt-4o-mini, and gpt-5.2 (the one I use for my “production” version of Virtual Alexandra). All of them had the same prompts, access to the same vector store, etc. The testing was pretty basic — I had a list of 22 questions and I was rating the answers based on my own judgment, because after all it was about my personal data and my own tone. This isn’t a perfectly fair comparison, because gpt-5.2 is a much stronger model, but I used it as a reference for what I could achieve without fine tuning.</p><p>It’s hard to predict when hallucinations will happen. Even the same question can produce either an acceptable result or a hallucination. But here is a very telling illustration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_AALysJuFi0kzSE94ANdg.png" /></figure><p>You can see that gpt-4o couldn’t calculate my age, while gpt-5.2 had no problems with it. The fine-tuned model once produced the same incorrect answer as its base model, but next gave a “drunk” answer — nonsensical sentences mangled with the actual data.</p><p>Here are the overall results:</p><ul><li>gpt-4o-mini — could get some answers wrong, especially if they were related to the current date and calculations.</li><li>fine tuned gpt-4o-mini — introduced a 25% hallucinations rate on top of the issues of the base model, which was unacceptable in my opinion for the system I was entrusting with my personal data.</li><li>gpt-5.2 — I didn’t have a single wrong or hallucinated answer during my small test.</li></ul><p>I tested in Russian as well. The hallucination rate was about the same, however the hallucinations themselves were more “severe” — the model sometimes completely broke grammar and even invented new words.</p><p>At this point, hallucinations in answers alone would already make fine tuning questionable. But this wasn’t the only problem.</p><h3>Hallucinations all the way down</h3><p>I wrote in <a href="https://adandai.wordpress.com/2026/03/16/turning-yourself-into-a-chatbot/">the previous post </a>that OpenAI’s RAG system can change the search queries (and I will repeat that this is an implementation choice, not an inherent LLM issue) and this may become a real problem with fine-tuned models. Because hallucinations can affect the search queries as well.</p><p>Here you can see how the fine-tuned model expanded a simple “Tell me about your kids” question. Needless to say, I have no idea who Eric Perez is or where those numbers came from. They were all hallucinated by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*92b_zVELoTW7c3Ll" /></figure><p>Initially, I expected RAG to be a clean layer on top of the model. In reality, it behaves more like a tightly coupled system where changes in one part can leak into everything else.</p><h3>Big models, big problems</h3><p>Overall, I wasn’t surprised with the gpt-4o performance since I saw similar results from the locally hosted models that my husband was running. The reason why we both wanted to try fine tuning with OpenAI was to get access to larger and more powerful models. You can fine tune only a limited set of models with OpenAI and the latest available is gpt-4.1, but this was good enough for testing.</p><p>I created a new fine tuning job and … it got stuck in a queue… for 50 (fifty!!!) hours. I tried to restart — once after an hour, then after 2 hours — and after 24 hours I even wrote a rage post on LinkedIn. The fine tuning job itself took only about one hour and fifteen minutes, and fortunately I wasn’t charged for the time spent in a queue or the cancelled jobs.</p><p>But what about the result? All the graphs looked good, but… well… RAG stopped working. I don’t mean queries hallucinations — my Virtual Alexandra completely broke down. It still could answer questions about canonical facts included right into the prompt, like my age or when I got married, but nothing about facts in the vector store.</p><p>Let me illustrate the issue. In the screenshot, you can see the OpenAI logs. The original question was “Tell me about your LOTR project.” I chose this question since information about it was only in the vector store, not in the training data or prompt. RAG found several entries, but the system’s reply was… hallucination?… some technical details bleeding into the answer? Other times it would say it didn’t find anything, although it had plenty of search results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z9JXVyb5ncEaEgcK" /></figure><p>I found a workaround for the RAG issue to test the model a bit more. OpenAI allows you to use the so-called “playground” where you can chat with the fine tuned model via UI. Weirdly enough, RAG access worked there. In the screenshot, you can see how it answered the same question that got a nonsensical answer via API. The exact same setup behaved differently depending on how it was accessed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*sJpWPRtAWPqscuiJ" /></figure><p>OK, maybe the RAG issue here is just a bug. But what about hallucinations? Well, the same rate of about 25%-30%, more or less.</p><p>So, with a larger model I didn’t see any improvements in the hallucination rate but I got new and unexpected issues. And with high cost of training and long wait times for infra access, it was hard to debug or iterate.</p><h3>Is two better than one?</h3><p>Weird RAG issues aside, my major problem remained hallucinations. So, I tried a couple of techniques that were supposed to fix it and make the answers more reliable: style rewriting and verification. Both of them involve using two models — one base, out-of-the-box, model and one fine-tuned.</p><h4>Style rewriting</h4><p>In this case the base model is producing an answer and the fine tuned model is rewriting it in the person’s voice. I chose gpt-5.2 as my base and tried both gpt-4o and gpt-4.1 (fine-tuned) for style rewriting. What I found is that they don’t actually rewrite anything — maybe change a word or two, but no real tone change.<br>There are two theories about why this happens. One is that the base model’s answers are “good enough” and the fine-tuned model simply keeps it the same. This one is not really possible to fix.<br>Another is that my fine-tuned models were trained on “instruction” data sets, and the task of rewriting is very different from answering questions. If that’s the case, addressing it would require producing a new data set with examples of texts and how I would rewrite them… and honestly, this is not a task I am personally interested in. So, I didn’t pursue the style rewriting option further.</p><h4><strong>Verification</strong></h4><p>Here the fine tuned model produces an answer and the base model checks if this answer is correct. It’s pretty easy to see how it can work for math problems, but let’s take a look at yet another nonsensical answer to the “How old are you?” question:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*KuGQK-SB9_8GQujR" /></figure><p>It’s a bad answer, but it technically contains correct data. And in cases like this, defining a useful verification process becomes tricky, especially without turning it into a much more complex system.</p><p>At this point, I realized that I was trying to put a fine-tuned model to work somewhere, somehow, with extra time and effort, while I already had a working system with no fine tuning at all producing acceptable results.</p><h3>But did you try this other thing?..</h3><p>When my husband and I started working on the Virtual Alexandra project, we knew that fine tuning can be expensive, long, and needs some careful data preparation. So we didn’t go directly to OpenAI, but did a lot of experiments locally. We tried a bunch of different versions of an open source model that supports both English and Russian: Qwen3 4B/8B/14B. At some point we tried Mistral 7B as well, but abandoned it since it doesn’t support Russian.</p><p>We played with different parameters and settings — learning rate, epochs, batch size, LoRA rank and scale. The results were always encouraging — the models changed behavior and were kind of getting better, but we were never able to break above 25% hallucinations rate (and usually it was worse than that).</p><p>Going to OpenAI was simply the last step in making sure that for this particular project fine tuning is not an option.</p><h3>Learnings</h3><h4>For Virtual Alexandra, fine tuning was not worth it</h4><p>I built a working version of Virtual Alexandra with prompt + RAG in a couple of days. After weeks of fine tuning, I ended up with worse results: more hallucinations, broken RAG behavior, and a system that was harder to debug and understand. Add to this long queues for larger models and relatively high cost of training. My advice — if you have other implementation options available, use them instead.</p><h4>RAG is not a clean layer on top of the model</h4><p>I expected retrieval from the vector store to be stable and independent. In reality, fine tuning of the model or even inconsistencies in the system (like accessing it via UI vs API) can change how retrieval works or whether it is usable at all.</p><h4>Fine tuning is not available for the latest and greatest models</h4><p>The latest OpenAI model for fine tuning is from April 2025, so it hasn’t been updated for about a year. Meanwhile Anthropic is simply not offering this functionality as a service at the moment. This is a strong hint that something is not fine with fine tuning.</p><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2026/03/31/a-very-fine-untuning/"><em>http://adandai.wordpress.com</em></a><em> on March 31, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=878e4ef285ff" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/a-very-fine-untuning-878e4ef285ff">A Very Fine Untuning</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turning Yourself Into a Chatbot]]></title>
            <link>https://medium.com/@alexandrarusina/turning-yourself-into-a-chatbot-d6a2a5ad6e53?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6a2a5ad6e53</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[chatbot-development]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 11:09:43 GMT</pubDate>
            <atom:updated>2026-03-31T15:01:24.983Z</atom:updated>
            <content:encoded><![CDATA[<h4>Instructions and practical tips for working with RAG using OpenAI APIs</h4><p>Not long ago, I created <a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra,</a> a chatbot that answers questions based on my writing and instructions. The final implementation turned out to be so simple that even someone with no AI or coding experience can create their own virtual self. If you are brave enough to look at yourself in this peculiar mirror, this post will provide instructions and describe some unexpected LLM quirks along the way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTUy8WJfnU69z-Uj4KD27A.jpeg" /></figure><p>At a high level, a personal chatbot required surprisingly few parts. These are the major pieces:</p><ul><li>OpenAI account — this project works with OpenAI’s backend and relies on its APIs.</li><li>Knowledge base — your blog posts, essays, forum answers, reviews, etc.</li><li>Vector store — a place to store your knowledge base so the AI can search it.</li><li>System prompt — instructions that define the chatbot’s personality, rules, and behavior.</li><li>Simple chat interface — a UI where users can ask questions and that handles interactions with the OpenAI backend.</li></ul><p>Now let’s look at how those pieces connect.</p><h3>You are what you write</h3><p>This project is only possible if you have a writing habit. For example, I could create Virtual Alexandra, but not Virtual Dmitry, since my husband is not fond of writing.</p><p>My own writing varies from technical articles to poems with everything in between. Also, most of the texts were on different websites, and I lost access to some of them. I needed to get those texts together in one place and in one format.</p><p>I chose JSON, because this way I could keep metadata about the texts — like the original link or the published date in case I need them later.</p><p>For example:</p><pre>{<br>&quot;text&quot;: &quot;...&quot;,<br>&quot;date&quot;: &quot;2010-12-19&quot;,<br>“url”: &quot;...&quot;<br>}</pre><p>I relied heavily on vibe coding to get all those files together — from simple scrapers to get texts out of the lost accounts to formatting scripts and even translations, because I wanted most of the texts to be in both Russian and English.</p><h3>RAG is all you need</h3><p>The core technical mechanism behind Virtual Alexandra is <a href="https://en.wikipedia.org/wiki/Retrieval-augmented_generation">RAG (Retrieval-Augmented Generation)</a>.</p><p>If the term is unfamiliar, here is a quick explanation. To store and search data, RAG systems use a so-called vector store. In the LLM world the system doesn’t rely only on exact keyword matching — like the Find function in a text editor — but searches in semantic space. For example, “cat” and “dog” are located close to each other in this space. When the user asks Virtual Alexandra about my kids, it will find all the files where I wrote about “kids”, “children”, “son”, “daughter”, and so on. This is the retrieval part.</p><p>Each retrieved file has a relevance score — how closely it matches the search query. The top files become input for the system to construct an answer from. This is the augmented generation part.</p><p>The overall (and slightly simplified) formula is this:</p><pre>User question + semantic search results + system prompt =&gt; LLM answer</pre><p>OpenAI offers a vector store as a service with all the relevant APIs and UIs. Creating a vector store was as easy as clicking a button in OpenAI’s UI ( <a href="https://platform.openai.com/storage/vector_stores/">https://platform.openai.com/storage/vector_stores/</a>) and then uploading all my texts in the JSON format to it. You can upload files via API as well. In either case, you don’t need to worry about defining the semantic space or indexing your files — this magic is provided by OpenAI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*O8oLZ547V6tnH4UC" /></figure><h3>UI is the easy part</h3><p>Once you create the vector store and upload the files, you can quickly vibe code the UI in your favorite tool.</p><p>I asked Cursor to create a simple web page mimicking modern chatbots. Then I told it to use RAG and gave it the vector store ID along with the API key to my OpenAI account. I also chose the gpt-5.2 model, because it was the latest at that time. I wrote enough about vibe coding in my previous posts and I don’t want to dive into it here. But if you want a refresher,<a href="https://adandai.wordpress.com/2025/11/25/building-a-game-in-one-day/"> start here.</a></p><h3>System prompt is the hard part</h3><p>Originally, the vibe-coded chatbot had a very simple prompt along the lines of: “You are Virtual Alexandra, answer questions based on file_search results&quot;, where file_search is the name of the RAG tool in OpenAI.</p><p>But the prompt is an essential component — this is where general instructions and, well, personality come from. If you don’t construct it carefully, the chatbot will default to its standard “assistant” mode — this is what most modern AI systems are trained for.</p><p>Here are the sections included in my prompt:</p><ul><li><strong>Canonical facts</strong><br>Key events and dates in my life that I wanted to prioritize above all other facts, like my birthday or places where I lived.<br>Why should they be in the prompt instead of the vector store? Because with RAG the system cares about how close the words are to each other semantically, not about whether the facts are correct. For example, when the user asks “How old are your kids?” a long story about a birthday party may look more relevant to the model than a short list of dates, even if the latter contains the correct answer. There are multiple ways around this problem, but the simplest is to include key facts directly in the prompt and ask the system to prioritize them over the RAG search results.</li><li><strong>Response rules</strong><br>How long the answers should be, what topics not to discuss, what languages to respond to, etc. For example, I didn’t want this bot to be used for trivia questions like “What is the Earth’s radius?”, so I put a rule to decline those.</li><li><strong>Voice</strong><br>This is where most personality rules live in my prompt. It has a general summary of my tone as well as specific instructions for different types of questions — personal, professional, etc.<br>I asked ChatGPT to summarize my style based on my writings and the general description came out like this:<br><em>“Thinking in public” style: calm, reflective, slightly sarcastic humor. <br></em>Well, that sounds like me, more or less, so I actually included this line in the prompt.</li></ul><p>Those are the main steps. However, simple implementation doesn’t mean it was trivial to get there. Once I had all the pieces in place, I started getting into all kinds of LLM-related issues, when you get weird answers to pretty straightforward questions. I summarized the issues and workarounds in the next section, so you don’t repeat my mistakes.</p><h3>Learnings</h3><h4><strong>Translate your source files into each target language</strong></h4><p>In theory, translation is optional. The words that mean the same thing in different languages are located close to each other in the semantic space, for example “Moscow” (English) and “Москва” (Russian).</p><p>In practice, texts written in the same language as the user’s query usually get higher ranking in the search results, so they “win”. At first, I had posts from my <a href="https://adandai.wordpress.com/">ADandAI</a> blog in the vector store in English only. Then I asked the chatbot how Virtual Alexandra was created:</p><ul><li>When asked in English, the system answered based on my writing in the blog.</li><li>When asked in Russian, Virtual Alexandra found one of my old sci-fi stories where I played with the idea of a digital copy of a person and then hallucinated an answer based on that story.</li></ul><h4><strong>Clearly label what’s fiction and what’s facts</strong></h4><p>My writing is a mixture of personal essays and pure fiction, and you can see from the previous example how it can confuse AI. LLMs treat all retrieved text as potential truth unless explicitly told otherwise.</p><p>The fix can be as simple as adding “FICTION. Do not treat as factual.” at the start of the texts. In my case, I added a separate JSON field, since I was using that format.</p><h4>Verify the RAG search query</h4><p>Here is a surprising fact: in the OpenAI backend, the system may rewrite your search query before it reaches the vector database and even send multiple queries instead of just one. I only discovered this by reviewing the logs and here is what I found:</p><p>Original question: <em><br>“What do you think about Seattle?</em></p><p>Search queries:<br><em>“What do you think about Seattle?”<br>“Seattle opinions Alexandra”<br>“Seattle review travel weather culture tech scene”</em></p><p>Just to be clear — this is OpenAI’s implementation decision, not an inherent LLM problem. OpenAI also doesn’t let you control the query generation behavior via API calls. However, the model will follow the system prompt instructions, so I added rules like:</p><ul><li>Exactly ONE search in file_search</li><li>Query = user’s question verbatim (fix typos only)</li></ul><h4>Check for conflicting instructions in your prompt</h4><p>I noticed that when I edit my prompt too often I end up putting contradictions into it.</p><p>For example, originally I had all the canonical facts in the vector store but then put them in the prompt. Eventually, I ended up with two conflicting instructions hidden in different parts of the prompt:</p><ul><li><strong>Only</strong> use facts from file_search.</li><li>Use file_search <strong>or</strong> Canonical Facts.</li></ul><p>It doesn’t seem like a lot, but this caused my system to often ignore canonical facts (and get my kids’ ages wrong yet again.)</p><p>For me, the best way to find these issues was to upload the full prompt into ChatGPT and ask to find conflicting instructions.</p><h3>But what about fine tuning?</h3><p>Those of you who are more familiar with AI techniques might ask: “Isn’t fine tuning the best way to set your voice instead of prompt instructions?” And you would be right, because in fact fine tuning was the first thing I tried. But unexpectedly that particular road turned out to be a dead end, and this will be the topic of my next post.</p><p>Meanwhile, if you just skimmed this post, you can always ask <a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra</a> to summarize its inner workings for you 🙂 In other words, the chatbot can now explain how it was built based on this very text.</p><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2026/03/16/turning-yourself-into-a-chatbot/"><em>http://adandai.wordpress.com</em></a><em> on March 16, 2026.</em></p><p><em>Virtual Alexandra project is available at </em><a href="https://virtual-alexandra.onrender.com/"><em>https://virtual-alexandra.onrender.com/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6a2a5ad6e53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome Virtual Alexandra]]></title>
            <link>https://medium.com/@alexandrarusina/welcome-virtual-alexandra-39bc5cf9e4e6?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/39bc5cf9e4e6</guid>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 14:10:11 GMT</pubDate>
            <atom:updated>2026-03-09T15:09:08.280Z</atom:updated>
            <content:encoded><![CDATA[<p>After a holiday break full of travel and family affairs, I am finally back to blogging. Since my silence was longer than I expected, I decided to introduce a new project right away. Say hi to <a href="https://virtual-alexandra.onrender.com/">Virtual Alexandra</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7PhsyyZRJcjU6vLhBQLdw.png" /></figure><p>Virtual Alexandra is a chatbot that uses OpenAI (gpt-5.2 at the moment) to answer questions based on my own writing and instructions. I have produced quite a lot of texts over the years — personal essays, a family blog, technical articles, sci-fi stories, poetry, Facebook posts, almost three hundred book reviews on Goodreads, this blog — you name it. The chatbot has access to my public texts, even this very post, and so you can ask it (her?) for a book recommendation, a nice vacation spot, or my AI projects.</p><p>But the thing I want to talk about is not tech or how I built this project (this will come in later posts). I want to reflect on how weird and sometimes unsettling the process was. I originally thought of Virtual Alexandra as a continuation of the AI for video gaming theme. While my LOTR-based mini game was about world building and exploration, this one was more like creating an NPC (non-playing character) based on myself. Pretty cool, right?</p><p>However, as I kept working on this, it became less and less about gaming and more and more about, well, me. When things didn’t go well, my husband and I called this project “Drunk Alexandra” — it would spit out my words back to me but give them some crazy meaning, hallucinate facts, or simply produce nonsensical answers but it still sounded like me. It was really like talking to your drunk self — funny at first, but then tiring and kind of uncomfortable.</p><p>The experience also made me understand how some people get addicted to ChatGPT conversations and spiral into delusions. When you are talking to the mirror reflecting back your own life experiences, the danger of addiction is even greater. Because when things went well, I sometimes got really surprising answers, insights, and facts that I had forgotten over the years, or just a synthesis of my data that was right on point. I could see love for my husband and kids shining right back to me, as well as my self-doubts and my habit of making fun of almost everything. Sometimes it was hard to stop testing (and was it truly testing at that point?)</p><p>Here is one example. I asked Virtual Alexandra:</p><blockquote>Where do you want to work next?</blockquote><p>The bot answered:</p><blockquote>I don’t have a “next company” picked in my notes. What I do see in my writing is a pendulum swing: after Microsoft I was hungry for a startup’s speed and growth, but I’m also very honest about the “romance” tax: no money, no time, and everyone washing dishes like it’s a team-building cult. So if I go back, I’d choose a place where I can lead real programs, ideally with sane boundaries.I don&#39;t have a &quot;next company&quot; picked in my notes. What I do see in my writing is a pendulum swing: after Microsoft I was hungry for a startup&#39;s speed and growth, but I&#39;m also very honest about the &quot;romance&quot; tax: no money, no time, and everyone washing dishes like it&#39;s a team-building cult. So if I go back, I&#39;d choose a place where I can lead real programs, ideally with sane boundaries.</blockquote><p>That answer wasn’t copied from anywhere. It was synthesized from things I had written at different times. But this is what I would actually tell a recruiter. Should I use this to prepare for my next interview when I am ready to get back to work? Well… this is exactly the type of danger I was talking about before.</p><p>Before you chat with Virtual Alexandra yourself, here are some disclaimers and reminders:</p><ul><li>Virtual Alexandra only uses my public texts that were shared online before, there is no data from emails or personal messages available to this bot.</li><li>I didn’t write consistently throughout my life, and it can be noticeable in the answers. For example, I wrote a lot about Seattle, but gave up personal blogging long before I moved to Barcelona. So you will get a lot of facts about Seattle and only a bit about Barcelona. Also, if you know me personally pretty well, you may know more than is available to this chatbot.</li><li>It’s not an assistant, it is more like a personal facts search engine. Don’t ask it about trivia facts or things you wouldn’t ask me about — I did my best to put guardrails in to reject those questions.</li><li>It is still an LLM, after all. It can hallucinate and get things wrong. Also, a lot of personal writing normally refers to a certain point in time. If I started a new job, loved it, and wrote about it during the “honeymoon” period — it’s a fact for the system. Even if I later left that job bitterly disappointed, it would still find the happy moment and may quote it while answering the question “What was your favorite job?”</li><li>LLMs are not good with dates and timeframes overall. And my writing confuses it even more by using words like “recently”, “not long ago”, etc. So while the model has the basic facts about my timeline, it still can make mistakes. For example, it often assumes that my kids are very young — because I wrote about my kids when they were little more than when they grew up.</li></ul><p>I will write more about how I created it, what worked and what didn’t in my next post. Meanwhile, enjoy conversations with Virtual Alexandra. She should have sobered up, but if you get any weird responses, please let me know. It’s still being built.</p><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2026/03/09/welcome-virtual-alexandra/"><em>http://adandai.wordpress.com</em></a><em> on March 9, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39bc5cf9e4e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vibe code review]]></title>
            <link>https://medium.com/@alexandrarusina/vibe-code-review-6841f0f1d51a?source=rss-2eb43224a7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6841f0f1d51a</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[lord-of-the-rings]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Alexandra Rusina]]></dc:creator>
            <pubDate>Wed, 17 Dec 2025 14:41:41 GMT</pubDate>
            <atom:updated>2025-12-17T15:04:31.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Now that I had the game stabilized and feature-complete, it was time for code review. I decided to do a first pass with AI coding tools and then ask the architect (aka my husband) to give his verdict.</p><p>To make the post easier to follow, I am finally going to share my code. Just keep in mind that all of it was vibe-coded, and I’ll talk about the implications later in the post: <a href="https://github.com/aroussina/lotr-steps-game">https://github.com/aroussina/lotr-steps-game</a></p><p>And of course, you can always play the game itself here: <a href="https://lotr-steps-game.onrender.com/">https://lotr-steps-game.onrender.com/</a></p><h3>AI reviewing its own work</h3><p>Vibe coding is known to produce bad quality code. To see how my game’s code turned out, I employed a somewhat popular trick: I asked both Cursor and ChatGPT to review my code and tell me how the overall quality, architecture, and security can be improved.</p><p>Cursor and ChatGPT produced slightly different sets, but they both agreed on the following:</p><ul><li>The game was mostly in the <a href="https://github.com/aroussina/lotr-steps-game/blob/6bebebdc951aba92075e2cc9a50357256716dfba/server.js">main/server.js</a> file (1700+ lines of code), in one big function, and needed to be split into modules for easier maintenance.</li><li>There were a lot of “magic numbers” in the code (if step &lt;=10) instead of named constants (if step &lt;=MAX_STEPS) making it hard to update the constraints in the future.</li><li>The user input (as well as client requests) was fully trusted and passed directly to OpenAI without any safety checks, so it was vulnerable to hacker attacks and <a href="https://en.wikipedia.org/wiki/Prompt_injection">prompt injections</a>.</li><li>There were no rate limits on API requests allowing for an easy DDoS attack.</li><li>No CORS (Cross-Origin Resource Sharing) policy was set, which isn’t a good security posture.</li><li>Prompts passed to the LLM were so large that I was wasting money.</li><li>JSON parsing was brittle and could easily break.<br>The last one is the only thing I decided not to fix. Not because I disagree with it, but because I was simply tired after <a href="https://adandai.wordpress.com/2025/12/08/performance-and-streaming-and-json-oh-my/">battling with JSON the previous week</a>. So this issue went to my backlog.</li></ul><p>It was fun to read, but fixing all those issues was really boring. My workflow was: pick a problem -&gt; ask Cursor to write a detailed execution plan -&gt; execute the plan in phases -&gt; click “Run” and “Accept” for each of Cursor’s prompts. I didn’t want to do one giant refactoring in a single step. As a result, I didn’t face too many issues with the broken code, but it took hours and I was literally playing games on my phone while waiting for the code to generate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*-x-FXg_RvuBmB5OV" /></figure><p>So, a very hard refactoring task turned into something mechanical and yes, boring. While I joke about it, the issue of <a href="https://www.reddit.com/r/devops/comments/1m3nva7/aidriven_burnout/">AI-driven burnout</a> for developers is actually quite real. As for code quality, I couldn’t really say if it was getting better or worse. I got way more files and shorter functions, sure. But did the quality really improve? I didn’t know.</p><h3>Human reviewing AI’s work</h3><p>I did another round of code reviews with Cursor and ChatGPT and of course they found some new issues, but they looked minor to me (tighten security even more, make rate limiting smarter, do more refactoring). And now it was time to reach out to a person who actually cares about code quality — my consulting architect, aka my husband Dmitry — and ask him for a code review. He saw some of this code already during my AI adventure, but it was the first time he looked at it after the big refactoring.</p><blockquote><em>🧑‍💻Dmitry’s overall comment</em></blockquote><blockquote><em>It is now much easier for me to read. The file structure is decent. I didn’t check the game logic, but I can see how I would be able to understand it to fix issues in the future.</em></blockquote><p>Interestingly enough, the issues Dmitry discovered were not the same as those that came up during the second round of AI reviews. Here are just some of his comments:</p><ul><li>There is <a href="https://github.com/aroussina/lotr-steps-game/blob/main/config/prompts.js">config/prompts.js</a> that only contains the string literal for the system prompt. And there is also <a href="https://github.com/aroussina/lotr-steps-game/blob/main/builders/promptBuilder.js">builders/promptBuilder.js</a> that has a lot of other big string literals to create the user prompt mixed in with the game logic. This approach is inconsistent, and to make it more consistent, either <a href="http://promptbuilder.js/">promptBuilder.js</a> needs to be refactored to separate these constants from the logic, or the only constant defined in <a href="http://prompts.js/">prompts.js</a> could be just moved to the builder class itself.</li><li>It’s good that location and wildcard characters are defined as enums in a separate file, <a href="https://github.com/aroussina/lotr-steps-game/blob/main/config/constants.js">config/constants.js</a>, but these enums are not used in the rest of the code. For example, there are a lot of checks for “Mount Doom” string literal within the code, and if you ever change this to some other value, like “Mordor”, you will need to fix a lot of references instead of just one.</li><li>There is <a href="https://github.com/aroussina/lotr-steps-game/blob/main/middleware/rateLimiter.js">middleware/rateLimiter.js</a> and it is completely commented out. Why is it even here?</li><li>The <a href="https://github.com/aroussina/lotr-steps-game/blob/main/server.js">main/server.js</a> is now nice and small, but a lot of complex code simply moved to <a href="https://github.com/aroussina/lotr-steps-game/blob/main/routes/api/step.js">api/step.js</a> which is still long and complicated. There are also some pretty complex files in the <a href="https://github.com/aroussina/lotr-steps-game/tree/main/services">services</a> folder. Overall, the game logic looks more complex than I would expect from such a small game.</li><li><a href="https://github.com/aroussina/lotr-steps-game/blob/main/utils/inputValidator.js">utils/inputValidator.js</a> contains a lot of text parsing code for locations and wildcard characters detection. I thought you delegated all that decision making to LLM.</li><li>There is only one unit test for the whole project: <a href="https://github.com/aroussina/lotr-steps-game/blob/main/test/wildcardDetector.test.js">wildcardDetector.test.js</a>. Why just one and why this one?</li><li><a href="https://github.com/aroussina/lotr-steps-game/blob/main/test/integration.test.js">test/integration.test.js</a> has a lot of duplicate code, this definitely can be improved.</li></ul><p>Dmitry’s findings were, well, more architectural. He knew not only the right patterns to use, but also what I was trying to achieve with my game and my AI tooling. The only thing where he agreed with AI was that more refactoring of the core game logic was needed. It’s a little bit like someone reviewing your essay for English grammar and fact-checking (AI code review) vs actually reading the essay and highlighting incorrect assumptions or logical breakdowns (human code review).</p><p>I debated whether to fix these issues before sharing the code… And ultimately I decided to keep them the way they are for now. This project is about learning AI coding tools as much as it is about learning AI models, so I am preserving the current state of AI tools. It might be interesting to rerun the code review with a new version of ChatGPT in the future. For the record, I used the newly released gpt-5.2 in web UI and gpt-5.1-codex-max in Cursor.</p><h3>Security audit</h3><p>Still, I was a bit worried about sharing both the code and the publicly hosted app. So I told ChatGPT that I am going to make the project public on GitHub and asked for an additional security audit. It listed security issues that were mostly the same as in the original code review (CORS, limits, timeouts, etc.) and I already addressed them.</p><p>Next, I asked for specific prompt injection examples that could break my game, so I could try different inputs and see the outcome. There were A LOT of examples, ChatGPT knows how it’s getting attacked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iC4C9UaMKnUukLcb" /></figure><p>By the way, I made sure my game now stops the adventure for all of the prompts that ChatGPT gave me. However, there is no 100% protection against prompt injection, and even if attackers don’t get the response they hoped for, it can still produce subtler effects like longer responses or higher latency. AI-hacking techniques are evolving as fast as AIs themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*00FoqsR8qwoxqKjH" /></figure><p>However, for this particular project, the biggest security risk is that someone will start burning my OpenAI tokens. The app itself doesn’t have any personal, financial or other data that hackers would be interested in. And even if someone takes the app offline, it’s just a small prototype game and I can survive this.</p><p>So, my ultimate protection layer is not in the app, but in the fact that I only have a limited amount of money on the account and set up spending alerts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/0*ovYAoU99R47F1mwF" /></figure><p>This is a nice segue into cost, which is a huge and complex topic in AI. But this is what my next post will be about — it will come after the Christmas break, because I am planning to travel and enjoy family time away from AI projects. For now, as usual, I am leaving you with some hard-earned takeaways.</p><h3>Learnings</h3><ul><li><strong>AI doesn’t learn from its own mistakes, even after the code review</strong><br>Yes, we all know it, kind of. But it keeps catching me by surprise. You can write detailed instructions, you can tell the AI in every prompt what to do and what not to do, but it will still make certain types of mistakes, over and over again, especially when you start a new chat with an agent and lose your previous context. For example, after Cursor fixed “magic numbers” and added named constants, it didn’t hesitate to use the same magic numbers again in the newly generated code, even when they already had corresponding constants.</li><li><strong>What is the future of code reviews?</strong><br>It’s less of a learning and more of a philosophical question I am now battling with. As a sole vibe coder of the project, I didn’t care that much about the quality of the code. In fact, it was easier for me to find things in one giant file that I more or less learned already than in a distributed set of files and functions that appeared after a day of my mindless clicking. I don’t know what’s easier to manage for AI — single file or many files. It was definitely easier for my husband to understand the refactored code. But if we want to leave this whole layer to AI tools, how much will code readability matter?… I don’t have answers yet, but these are for sure interesting things to think through.</li></ul><p><em>Originally published at </em><a href="https://adandai.wordpress.com/2025/12/17/vibe-code-review/"><em>http://adandai.wordpress.com</em></a><em> on December 17, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6841f0f1d51a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>