<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Miguel Diaz Kusztrich</title>
    <description>The latest articles on DEV Community by Miguel Diaz Kusztrich (@miguel_diaz_k26).</description>
    <link>https://dev.to/miguel_diaz_k26</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4131894%2F8989f44e-bf5e-4461-a09d-9c83a0d9ccab.png</url>
      <title>DEV Community: Miguel Diaz Kusztrich</title>
      <link>https://dev.to/miguel_diaz_k26</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miguel_diaz_k26"/>
    <language>en</language>
    <item>
      <title>Generating Code: Roslyn or AI?</title>
      <dc:creator>Miguel Diaz Kusztrich</dc:creator>
      <pubDate>Fri, 13 Nov 2026 12:05:04 +0000</pubDate>
      <link>https://dev.to/miguel_diaz_k26/generating-code-roslyn-or-ai-e8n</link>
      <guid>https://dev.to/miguel_diaz_k26/generating-code-roslyn-or-ai-e8n</guid>
      <description>&lt;p&gt;I'm continuing my work on automating code generation for &lt;strong&gt;AIDBDeveloper&lt;/strong&gt;, my application development platform, which combines application services, database management and artificial intelligence.&lt;/p&gt;

&lt;p&gt;The immediate goal is to migrate the editor of my personal blog, &lt;a href="https://software-tecnico-libre.es/en/stl-index" rel="noopener noreferrer"&gt;Free Technical Software&lt;/a&gt;, a Windows desktop application I developed years ago, to this new platform. But the real work is building automation mechanisms that I can reuse in other projects.&lt;/p&gt;

&lt;p&gt;In the previous article, I generated around 11,000 lines of C# and MySQL code using deterministic processes. The result was a database repository, with classes representing the tables in the blog's database schema, their corresponding interfaces, and stored procedures for updating the data.&lt;/p&gt;

&lt;p&gt;I only used AI to generate names, descriptions and other texts in English and Spanish. These were incorporated into the code through .NET attributes, which I use extensively to document classes, interfaces, properties and even user interface controls at runtime.&lt;/p&gt;

&lt;p&gt;The idea is to let conventional code do everything it can, and reserve AI for the tasks that actually need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Increasing the complexity
&lt;/h2&gt;

&lt;p&gt;I've been raising the level of complexity with each article in this series.&lt;/p&gt;

&lt;p&gt;In the first one, I automated the localisation of Windows Forms applications. The process added English and Spanish texts to resource files, then modified the designer code to replace literal strings in properties such as &lt;code&gt;AccessibleName&lt;/code&gt;, &lt;code&gt;AccessibleDescription&lt;/code&gt; and &lt;code&gt;ToolTipText&lt;/code&gt; with references to those resources.&lt;/p&gt;

&lt;p&gt;In the second article, I moved on to generating code from templates. Apart from C# classes and interfaces, the automation also generated MySQL stored procedures.&lt;/p&gt;

&lt;p&gt;Both tasks were relatively straightforward, at least compared with what comes next.&lt;/p&gt;

&lt;p&gt;This time, I wanted to generate a component that could be integrated directly into AIDBDeveloper, allowing users to work with the repository through the platform's existing user interface.&lt;/p&gt;

&lt;p&gt;That means implementing several predefined interfaces, inheriting from a base class and overriding some of its methods and properties.&lt;/p&gt;

&lt;p&gt;Fortunately, my platform already provides the necessary runtime infrastructure, so I was able to generate this component deterministically as well.&lt;/p&gt;

&lt;p&gt;Of course, we're still dealing with a standardised database repository. I already know what the generated classes must do and how they must interact with the rest of the application.&lt;/p&gt;

&lt;p&gt;The next steps won't be so simple.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the existing code matters
&lt;/h2&gt;

&lt;p&gt;As I move towards automating the development of more specific components, I'll have to analyse code that already exists.&lt;/p&gt;

&lt;p&gt;I'll need to examine classes, interfaces, properties and methods, then present the available implementation options to either the user or an AI.&lt;/p&gt;

&lt;p&gt;Some decisions cannot be derived from the code structure alone. But that doesn't mean the entire task has to be handed over to AI.&lt;/p&gt;

&lt;p&gt;We can still reduce the amount of information it needs to process, and the number of decisions it has to make.&lt;/p&gt;

&lt;p&gt;I'm not trying to demonstrate that everything can be done without artificial intelligence. My objective is to make automation profitable, avoiding unnecessary costs in both tokens and the human time required to supervise and validate the results.&lt;/p&gt;

&lt;p&gt;And since I'm working with .NET, why not use Roslyn?&lt;/p&gt;

&lt;h2&gt;
  
  
  Roslyn enters the picture
&lt;/h2&gt;

&lt;p&gt;Roslyn is Microsoft's open-source compiler platform for C# and Visual Basic .NET. It provides access to the syntactic and semantic structure of source code, allowing applications to analyse and transform it without having to develop their own parsers.&lt;/p&gt;

&lt;p&gt;In the video accompanying this article, I show a first, fairly basic use of Roslyn.&lt;/p&gt;

&lt;p&gt;My application already uses reflection to discover types and examine their attributes. It can also identify the assembly containing a type and locate the corresponding project.&lt;/p&gt;

&lt;p&gt;But finding the actual source file is another matter.&lt;/p&gt;

&lt;p&gt;Not every file has the same name as the type it contains. And not every file contains just one type.&lt;/p&gt;

&lt;p&gt;Roslyn allows me to locate those declarations in the source files, so the rest of the automation can work directly with them.&lt;/p&gt;

&lt;p&gt;Nothing particularly sophisticated, but it saves a lot of work.&lt;/p&gt;

&lt;p&gt;And, more importantly, once the mechanism exists, I can reuse it without asking an AI to examine the same source code again and again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Combining Roslyn and AI
&lt;/h2&gt;

&lt;p&gt;I put this new capability to work in another automation.&lt;/p&gt;

&lt;p&gt;My platform contains more than a hundred client and provider interfaces, distributed across several projects. Many of them lack the attributes I use to provide localised names, descriptions and categories.&lt;/p&gt;

&lt;p&gt;I could write all those texts manually. Or I could ask an AI to examine the source files and modify them.&lt;/p&gt;

&lt;p&gt;Instead, I use reflection to identify the interfaces, Roslyn to locate their declarations and extract the existing XML documentation, and AI to generate only the missing texts.&lt;/p&gt;

&lt;p&gt;The changes to the source files and resources are then performed deterministically.&lt;/p&gt;

&lt;p&gt;The AI doesn't need to understand the entire solution, and it doesn't need to generate C# code.&lt;/p&gt;

&lt;p&gt;I also save its results so that I can repeat the automation without making the same API calls again.&lt;/p&gt;

&lt;p&gt;In the video, I show the configuration, execution and results of this process, along with another automation I use to generate Function Calling definitions from .NET interfaces and attributes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating the repository provider
&lt;/h2&gt;

&lt;p&gt;Finally, I return to the original objective: generating the component that connects the repository to AIDBDeveloper.&lt;/p&gt;

&lt;p&gt;I reuse the code generation script from the previous article, extending it to generate the necessary metadata, command definitions and provider class.&lt;/p&gt;

&lt;p&gt;The resulting repository now contains approximately 13,300 lines of generated code, including 5,500 executable lines.&lt;/p&gt;

&lt;p&gt;The new provider component integrates with my existing infrastructure, including component connections, database queries, table selection commands, filtering and sorting.&lt;/p&gt;

&lt;p&gt;I demonstrate the result in the video, then examine the generated code in Visual Studio.&lt;/p&gt;

&lt;p&gt;The important thing is that the generated component works without requiring manual changes to its code. The process uses existing interfaces, templates, conventions and runtime services that have already been implemented and tested.&lt;/p&gt;

&lt;p&gt;The automation doesn't have to invent a new solution every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;The repository is now integrated into AIDBDeveloper. The next challenge is building the actual blog editor.&lt;/p&gt;

&lt;p&gt;That will be considerably more specific. I probably won't be able to automate everything, and I'll certainly need to make more decisions based on the existing code.&lt;/p&gt;

&lt;p&gt;But I intend to automate as much as possible, particularly the implementation of standard interfaces.&lt;/p&gt;

&lt;p&gt;And I suspect Roslyn will do more of the work than AI.&lt;/p&gt;

&lt;p&gt;The more I develop this infrastructure, the more I find that the real benefit of AI isn't necessarily having it write the code. It's also having it help me build tools that can do the work without it.&lt;/p&gt;

&lt;p&gt;Anyway, here's the video, where I demonstrate the whole process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/3BZ8RE7T2uc" rel="noopener noreferrer"&gt;Watch the video on YouTube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you find it interesting, and perhaps useful for your own projects.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and see you next time!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>roslyn</category>
      <category>automation</category>
      <category>productivity</category>
    </item>
    <item>
      <title>11,000 Lines of Code in 41 Seconds</title>
      <dc:creator>Miguel Diaz Kusztrich</dc:creator>
      <pubDate>Tue, 27 Oct 2026 09:19:49 +0000</pubDate>
      <link>https://dev.to/miguel_diaz_k26/11000-lines-of-code-in-41-seconds-52i3</link>
      <guid>https://dev.to/miguel_diaz_k26/11000-lines-of-code-in-41-seconds-52i3</guid>
      <description>&lt;p&gt;I'm continuing my work on code automation for my application, &lt;strong&gt;AIDBDeveloper&lt;/strong&gt;. This time, I've set my sights quite a bit higher: generating all the classes needed to implement the editor for my blog, &lt;a href="https://software-tecnico-libre.es/en/stl-index" rel="noopener noreferrer"&gt;Free Technical Software&lt;/a&gt;, as a class library integrated into the platform.&lt;/p&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/miguel_diaz_k26/ai-in-the-place-to-be-ip7"&gt;previous article&lt;/a&gt;, I took a fairly simple first step: automating resource localization for a control or form. It involved little more than modifying a few XML resource files and a couple of classes to declare their names.&lt;/p&gt;

&lt;p&gt;In this new article, I'll demonstrate a combination of automation techniques. On the one hand, the familiar VSIX project template for creating a Visual Studio project with a custom configuration. On the other, starting from the tables in my blog's configuration database, I'll generate 29 classes (one for each table), a repository class, a common base class for all the tables, an interface for the table objects, and another for the repository.&lt;/p&gt;

&lt;p&gt;Two additional interfaces will integrate the repository into the solution: one implemented by the provider component and the other by client components.&lt;/p&gt;

&lt;p&gt;I'll also need to modify the standard class I use to integrate these class libraries into the solution, exporting objects that must be available on demand, without requiring their types to be known in advance.&lt;/p&gt;

&lt;p&gt;And, of course, I'll need to add localized text resources for all of this, just as I did in the previous article.&lt;/p&gt;

&lt;p&gt;So, what will artificial intelligence be doing this time? Essentially the same thing as before: generating the text resources. English and Spanish texts for the categories, names, and descriptions used when editing objects in the user interface.&lt;/p&gt;

&lt;p&gt;These texts will be stored in a JSON file within the project, so even if I run the process a hundred times, I'll only need AI for the first run.&lt;/p&gt;

&lt;p&gt;But there's more. I've standardized how objects are updated in all my database repositories. I always use stored procedures, leaving the SQL complexities to the database. This way, even when several operations are required, they can all be performed in a single call.&lt;/p&gt;

&lt;p&gt;That means I'll also need to generate 29 stored procedures, using MySQL in this case, to update each of the tables.&lt;/p&gt;

&lt;p&gt;Incidentally, generating all of this takes just 41 seconds when AI is involved. Without it, the process takes less than a second, so making corrections and modifications is a breeze once the JSON file containing the resources is available.&lt;/p&gt;

&lt;p&gt;I'll also demonstrate another kind of automation. After all, automation isn't just about writing code. In my .NET applications, I make extensive use of attributes to attach metadata to types and guide various operations.&lt;/p&gt;

&lt;p&gt;For example, I can define the default configuration of each column in a DataGridView by decorating the corresponding properties with attributes. I can specify which properties represent primary keys, whether those keys are auto-generated, which properties are foreign keys, and what type of join should be used to link to the referenced table.&lt;/p&gt;

&lt;p&gt;I won't bore you with endless, tedious explanations of the code, although I'll highlight some of its more interesting details in the accompanying video. I'm hoping to keep improving the way I explain code in my videos, so any comments or suggestions would be very welcome.&lt;/p&gt;

&lt;p&gt;So, without further ado, here's the video. Let me know what you think!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/2qc6InEVY60" rel="noopener noreferrer"&gt;Watch in YouTube&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>automaton</category>
      <category>csharp</category>
      <category>mysql</category>
    </item>
    <item>
      <title>AI in the place to be!</title>
      <dc:creator>Miguel Diaz Kusztrich</dc:creator>
      <pubDate>Mon, 05 Oct 2026 07:47:14 +0000</pubDate>
      <link>https://dev.to/miguel_diaz_k26/ai-in-the-place-to-be-ip7</link>
      <guid>https://dev.to/miguel_diaz_k26/ai-in-the-place-to-be-ip7</guid>
      <description>&lt;h1&gt;
  
  
  Using AI Only Where It Adds Value in Code Automation
&lt;/h1&gt;

&lt;p&gt;When we talk about AI-assisted software development, the conversation often starts with agents: which model should generate the code, how much autonomy should it have, and how many tools should we give it?&lt;/p&gt;

&lt;p&gt;I want to start somewhere else.&lt;/p&gt;

&lt;p&gt;What if the goal is not to make AI do as much as possible, but to make it do as little as possible?&lt;/p&gt;

&lt;p&gt;That is the idea behind this new series of videos.&lt;/p&gt;

&lt;p&gt;For tasks based on well-defined patterns, traditional automation is still faster, cheaper, more predictable, and easier to validate. AI becomes interesting only at those particular points where interpretation or judgement is required and the decision cannot be conveniently formalized.&lt;/p&gt;

&lt;p&gt;In the first video, I use a deliberately simple example.&lt;/p&gt;

&lt;p&gt;I start with a C# WinForms designer containing literal UI texts in English and automate the process of converting them into multilingual resources.&lt;/p&gt;

&lt;p&gt;Most of the work does not require AI at all.&lt;/p&gt;

&lt;p&gt;The application can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;locate the relevant text properties,&lt;/li&gt;
&lt;li&gt;generate standardized resource names,&lt;/li&gt;
&lt;li&gt;replace literals with resource references,&lt;/li&gt;
&lt;li&gt;modify the &lt;code&gt;.resx&lt;/code&gt; files,&lt;/li&gt;
&lt;li&gt;update their generated designer code,&lt;/li&gt;
&lt;li&gt;collect the modified files,&lt;/li&gt;
&lt;li&gt;and present all changes for review before they are accepted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The language model only enters the pipeline for the part where language understanding is actually useful: adapting the texts into Spanish while taking their context into account and preserving class and control names.&lt;/p&gt;

&lt;p&gt;After that, the deterministic process takes control again.&lt;/p&gt;

&lt;p&gt;This is intentionally a very small example. The purpose is to establish the basic approach before applying it to increasingly complex code-generation tasks.&lt;/p&gt;

&lt;p&gt;The application becomes the assembly line.&lt;/p&gt;

&lt;p&gt;AI is not the assembly line. It is the specialist that is called in only when the assembly line reaches a problem that cannot be solved mechanically.&lt;/p&gt;

&lt;p&gt;That leads to the question I want to explore throughout the series:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How much of a code automation task actually needs AI?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Video
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://youtu.be/NwiX5qHW5NQ" rel="noopener noreferrer"&gt;Watch in YouTube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next examples, I’ll gradually increase the complexity while trying to keep the same rule: deterministic code should do everything it can, and AI should only deal with what remains.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>code</category>
      <category>automation</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Optimizing AI Workflows: What I Learned from Four Text-Analysis Trials</title>
      <dc:creator>Miguel Diaz Kusztrich</dc:creator>
      <pubDate>Mon, 21 Sep 2026 14:31:44 +0000</pubDate>
      <link>https://dev.to/miguel_diaz_k26/optimizing-ai-workflows-what-i-learned-from-four-text-analysis-trials-5f69</link>
      <guid>https://dev.to/miguel_diaz_k26/optimizing-ai-workflows-what-i-learned-from-four-text-analysis-trials-5f69</guid>
      <description>&lt;p&gt;Complex AI workflows can become expensive surprisingly quickly. Not necessarily because the models themselves are expensive, but because small design decisions are repeated hundreds or thousands of times.&lt;/p&gt;

&lt;p&gt;A system message that is too short to benefit from input caching, a model that explains every decision when nobody needs those explanations, a task that gives the model too much freedom, or a single step that gets stuck repeating the same function calls can have a surprisingly large effect once the workflow grows.&lt;/p&gt;

&lt;p&gt;I wanted to look at this using a real process rather than a synthetic benchmark.&lt;/p&gt;

&lt;p&gt;The experiment is based on a text-analysis workflow that splits a document into sentences, tokens and multi-word terms, and then performs several syntactic, secondary and free-form classifications. Each trial involved several thousand API requests and several million tokens. I ran four trials using the same two source texts under different conditions, and compared token usage, caching, estimated cost and preliminary result quality. &lt;/p&gt;

&lt;p&gt;The whole experiment was built and executed inside &lt;strong&gt;AIDBDeveloper&lt;/strong&gt;, the platform I introduced in a previous article. If you want some background on the application, its modular dashboards and its provider-independent context management, you can find that introduction &lt;a href="https://dev.to/miguel_diaz_k26/a-short-introduction-to-my-work-with-ai-3imi"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The video attached to this article contains the complete walkthrough. What follows is a shorter overview of the experiment and some of the results that I found most interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Hybrid Workflow Instead of One Big Agent
&lt;/h2&gt;

&lt;p&gt;The first design decision was not to ask one model to analyse the whole document.&lt;/p&gt;

&lt;p&gt;The application remains responsible for orchestration, data storage and everything that can be done deterministically. AI is used only for the individual tasks that actually require interpretation.&lt;/p&gt;

&lt;p&gt;The process starts by extracting sentences from the source text. For these trials I used GPT 5.6 Sol with low reasoning effort. Each sentence is then split into words, numbers and punctuation marks using GPT 5.4 mini. Multi-word units — which I call &lt;em&gt;terms&lt;/em&gt; — are extracted with GPT 5.6 Terra at medium reasoning effort, and Terra is also used for the subsequent classification steps. &lt;/p&gt;

&lt;p&gt;Token classifications are processed in batches of five, with ten model instances working in parallel on different sentences. Later steps reuse information produced by previous ones whenever that can reduce the model's decision space. &lt;/p&gt;

&lt;p&gt;This was one of the ideas I wanted to test throughout the experiment: instead of asking the model to be as intelligent as possible, try to make each individual task simple enough that it needs as little intelligence as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four Trials, Three Conditions
&lt;/h2&gt;

&lt;p&gt;I used two short articles about logical fallacies that I had written years ago. Each document was processed twice.&lt;/p&gt;

&lt;p&gt;The first trial on TEXT 1 used shorter system messages in an attempt to save input tokens. That turned out not to be particularly successful. Some steps did not use the input cache, term extraction was far too permissive, and the workflow produced many more classifications than necessary.&lt;/p&gt;

&lt;p&gt;For the second trial, the system messages were made considerably more explicit. Cache usage improved substantially and the number of extracted terms and classifications fell.&lt;/p&gt;

&lt;p&gt;TEXT 2 was then processed under essentially the same improved configuration. In its second trial, however, I deliberately removed one apparently trivial instruction: after finishing its function calls, the model was no longer told to answer with only a single full stop.&lt;/p&gt;

&lt;p&gt;That provided a useful demonstration of how expensive unnecessary politeness can become.&lt;/p&gt;

&lt;h3&gt;
  
  
  Results at a glance
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x5qbwb1rjs7toay9ntm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x5qbwb1rjs7toay9ntm.png" alt=" " width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The infographic above summarizes some of the structural differences between the four runs.&lt;/p&gt;

&lt;p&gt;One result remained completely stable: tokenization. TEXT 1 produced exactly 1,650 tokens in both trials, while TEXT 2 produced 1,762 in both.&lt;/p&gt;

&lt;p&gt;Term extraction was a different story. TEXT 1 went from &lt;strong&gt;1,114 terms in the first trial to 431 in the second&lt;/strong&gt;, after improving the instructions. The total number of classifications also fell from &lt;strong&gt;15,673 to 9,580&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That is not simply a token-saving exercise. In the first trial the model was identifying almost any group of words as a term, so the larger result was actually a symptom of poorer analysis.&lt;/p&gt;

&lt;p&gt;The two TEXT 2 trials were much closer structurally because the system messages and classification functions were essentially unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  This Was Not a Small Test
&lt;/h2&gt;

&lt;p&gt;The individual source documents were short, but the resulting workload was not.&lt;/p&gt;

&lt;p&gt;Across the relevant trials, total usage ranged from approximately &lt;strong&gt;3 to 8 million tokens per trial&lt;/strong&gt;, with roughly &lt;strong&gt;2,000 to 3,000 requests&lt;/strong&gt; each. Output remained around 600,000 tokens in most runs, except for the final trial where it rose to roughly 800,000. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl0uruydy66w0sz42j9zh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl0uruydy66w0sz42j9zh.png" alt=" " width="496" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The usage screenshot gives some idea of the scale involved. Once a process reaches this size, looking only at a final API bill is not particularly useful. You need to know which step generated those tokens, which context was used and what the model was doing at that moment.&lt;/p&gt;

&lt;p&gt;For that reason, every model-backed execution instance in my workflow records its configuration, start and end times, input and output data, token usage and a copy of the context that produced the result. &lt;/p&gt;

&lt;p&gt;That made it possible to analyse the workflow internally instead of treating the whole experiment as one large anonymous API workload.&lt;/p&gt;

&lt;h2&gt;
  
  
  Input Caching Worked — But That Was Not the Most Important Result
&lt;/h2&gt;

&lt;p&gt;One of the main goals of the TEXT 1 comparison was to improve input-cache usage.&lt;/p&gt;

&lt;p&gt;It worked.&lt;/p&gt;

&lt;p&gt;Between the two TEXT 1 trials, the estimated cost of uncached input fell by almost &lt;strong&gt;73%&lt;/strong&gt;. When all three input-related categories — uncached input, cached input and cache writes — were combined, the reduction was approximately &lt;strong&gt;18%&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;But something else happened at the same time.&lt;/p&gt;

&lt;p&gt;The output cost also fell by almost &lt;strong&gt;15%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That mattered much more than I initially expected because output tokens represented around &lt;strong&gt;64% of the total estimated cost&lt;/strong&gt; in that comparison. The total theoretical cost therefore fell from &lt;strong&gt;$11.39 to $9.59&lt;/strong&gt;, approximately &lt;strong&gt;16%&lt;/strong&gt; overall. &lt;/p&gt;

&lt;p&gt;In other words, I had been trying to optimize input caching, and caching did improve, but a large part of the final saving actually came from producing less output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fofrjg28hygh00rrid36j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fofrjg28hygh00rrid36j.png" alt=" " width="799" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The chart also shows the two TEXT 2 trials. The last one is deliberately worse, because the model was allowed to generate explanatory responses after completing its function calls.&lt;/p&gt;

&lt;p&gt;That apparently small change was enough to push the estimated cost from &lt;strong&gt;$11.67 to $14.97&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Output Tokens Are Easy to Waste
&lt;/h2&gt;

&lt;p&gt;Function calling introduces a slightly annoying detail.&lt;/p&gt;

&lt;p&gt;After the model has finished making all the requested function calls, it normally returns a final assistant message. In an interactive conversation that makes sense. In an automated classification process, it often does not.&lt;/p&gt;

&lt;p&gt;The useful information has already been delivered through the function calls. A final message saying what the model has done is just additional output.&lt;/p&gt;

&lt;p&gt;In most of the trials, the system instructions explicitly told the model to finish with a single full stop.&lt;/p&gt;

&lt;p&gt;When I removed that instruction in the second TEXT 2 trial, the model began explaining its work again and again. Nobody was going to read those explanations, but they were still generated and billed.&lt;/p&gt;

&lt;p&gt;One classification step gives a particularly clear example: its output increased from roughly &lt;strong&gt;234,000 tokens to 426,000 tokens&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Almost twice as much output for no useful additional result.&lt;/p&gt;

&lt;p&gt;That was one of the simplest lessons from the whole experiment: in an automated workflow, a natural-language answer can be pure overhead.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Failure Can Be More Informative Than a Successful Run
&lt;/h2&gt;

&lt;p&gt;The second TEXT 2 trial also produced another interesting problem.&lt;/p&gt;

&lt;p&gt;During one classification step, a model instance became stuck repeatedly calling the same functions for the same batch of five tokens, using exactly the same parameters.&lt;/p&gt;

&lt;p&gt;I managed to get it unstuck without stopping the complete process, but its token usage had already increased dramatically.&lt;/p&gt;

&lt;p&gt;The interesting part was that cached-input percentage barely changed. The repeated context was still being cached efficiently; the process was simply repeating far too much work.&lt;/p&gt;

&lt;p&gt;This is a useful reminder that good cache statistics do not necessarily mean that a workflow is efficient.&lt;/p&gt;

&lt;p&gt;You can cache an error very efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the Model Can Matter More Than Fine Optimization
&lt;/h2&gt;

&lt;p&gt;I also added a parameterized cost calculation that allowed me to apply a different model's rates to exactly the same recorded token usage.&lt;/p&gt;

&lt;p&gt;As an experiment, I replaced GPT 5.6 Terra with GPT 6 Astra in the calculation.&lt;/p&gt;

&lt;p&gt;The trials that cost roughly &lt;strong&gt;$10–15&lt;/strong&gt; using the actual model mix rose to approximately &lt;strong&gt;$42–65&lt;/strong&gt; with Astra pricing — around &lt;strong&gt;4.5 times as much&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;This is only a cost simulation. It does not imply that Astra would actually consume the same number of tokens or produce identical results.&lt;/p&gt;

&lt;p&gt;But it illustrates the scale of the decision.&lt;/p&gt;

&lt;p&gt;Choosing a model substantially more capable than the task requires can outweigh many of the smaller optimizations applied later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost Is Only Half the Problem
&lt;/h2&gt;

&lt;p&gt;There is little value in making a workflow cheaper if the results become worse.&lt;/p&gt;

&lt;p&gt;The preliminary quality review produced a very uneven picture.&lt;/p&gt;

&lt;p&gt;Sentence extraction was extremely consistent. Tokenization was even more stable: it produced identical results across equivalent trials.&lt;/p&gt;

&lt;p&gt;Word-level syntactic classification still needs some refinement, but the general quality was reasonably good.&lt;/p&gt;

&lt;p&gt;The harder part was multi-word analysis. Term extraction remained weak, even after improving the instructions. Syntactic classification of terms was considerably poorer than classification of individual words, and the secondary classification of terms was clearly inadequate. The free-form word tags looked more promising, although those are inherently more subjective. &lt;/p&gt;

&lt;p&gt;This changed the optimization question again.&lt;/p&gt;

&lt;p&gt;A cheap and stable step is probably not where more engineering effort should go. A step that is expensive and still produces poor results is a much better candidate for redesign.&lt;/p&gt;

&lt;p&gt;In some cases, the right optimization is not a better prompt. It is a different process.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Took Away from the Experiment
&lt;/h2&gt;

&lt;p&gt;The original purpose of these trials was mainly to explore context management and caching, but the broader conclusion ended up being more useful.&lt;/p&gt;

&lt;p&gt;Optimizing an AI workflow is not simply about reducing token counts.&lt;/p&gt;

&lt;p&gt;It means deciding which work genuinely requires a model, breaking that work into sufficiently small tasks, constraining the model's choices whenever possible, providing known information instead of making it infer it again, removing context that is no longer useful, avoiding unnecessary natural-language output, choosing the least expensive model that can perform each task reliably, and recording enough information to know where the cost is actually coming from.&lt;/p&gt;

&lt;p&gt;The application should do everything it already knows how to do.&lt;/p&gt;

&lt;p&gt;The model should be used for the uncertain parts.&lt;/p&gt;

&lt;p&gt;And both cost and result quality need to be measured together. &lt;/p&gt;

&lt;p&gt;The video goes much deeper into all of this. It includes the context structure, input caching, function calling and structured responses, the complete workflow, execution logs, examples of actual contexts, detailed token and cost charts, some of the errors I found, and the preliminary quality review.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/X3RT8wnQQRE" rel="noopener noreferrer"&gt;Watch the full video on YouTube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is still only the preliminary stage of the larger text-analysis experiment. The next work will focus much more heavily on improving and validating the linguistic results themselves.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>automation</category>
      <category>api</category>
    </item>
    <item>
      <title>A Short Introduction to My Work with AI</title>
      <dc:creator>Miguel Diaz Kusztrich</dc:creator>
      <pubDate>Sat, 19 Sep 2026 09:09:18 +0000</pubDate>
      <link>https://dev.to/miguel_diaz_k26/a-short-introduction-to-my-work-with-ai-3imi</link>
      <guid>https://dev.to/miguel_diaz_k26/a-short-introduction-to-my-work-with-ai-3imi</guid>
      <description>&lt;p&gt;I’ve been experimenting with AI integration in software applications for some time, not as an isolated chatbot feature, but as part of the application architecture itself.&lt;/p&gt;

&lt;p&gt;One of my first practical experiments was an AI-assisted chess database. The idea was simple: instead of navigating the application only through menus and forms, the user could interact with AI assistants able to understand the database, search games, add commentary, configure parts of the application and even play chess.&lt;/p&gt;

&lt;p&gt;That project was an important starting point for me because it showed that AI could become another way of operating an application, not just something added on top of it.&lt;/p&gt;

&lt;p&gt;Since then, the idea has evolved considerably. I’m now building a more general platform where AI, databases and application components share a common architecture. The application manages the context, exposes functions and resources to the models, and keeps control of the workflow.&lt;/p&gt;

&lt;p&gt;These two videos show that evolution quite well:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/BY7uQUw80ok" rel="noopener noreferrer"&gt;The chess database demo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtu.be/q-o2HpDuZ3E" rel="noopener noreferrer"&gt;The current architecture&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first is where the idea started. The second is where it is heading now.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
