<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Paweł Rojek — Writing</title>
  <subtitle>Notes on building software with coding agents and language models, from my own projects.</subtitle>
  <link href="https://pawelrojek.dev/writing/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="https://pawelrojek.dev/writing/" rel="alternate" type="text/html"/>
  <id>https://pawelrojek.dev/writing/</id>
  <updated>2026-11-21T09:00:00Z</updated>
  <author>
    <name>Paweł Rojek</name>
    <uri>https://pawelrojek.dev/</uri>
  </author>
  <entry>
    <title>Exact words from a noisy recording</title>
    <link href="https://pawelrojek.dev/writing/exact-words-from-a-noisy-recording" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/exact-words-from-a-noisy-recording</id>
    <published>2026-10-22T09:00:00Z</published>
    <updated>2026-10-22T09:00:00Z</updated>
    <summary>Forty-four minutes on one phone, outdoors, five people talking over each other. I needed who said what, word for word, for free and without the audio leaving my computer. The models got close, my ear did the rest, and my corrections decided which model to trust.</summary>
    <content type="html">&lt;p&gt;In October I needed an exact record of a conversation I had recorded on my phone: 44 minutes outdoors, five people and one side of a phone call on loudspeaker, with wind, walking and people talking over each other. The first transcript, Whisper large-v3-turbo over the whole file, repeated one sentence 430 times. With the loop fixed it still had garbled words, and it had no speakers at all.&lt;/p&gt;
&lt;p&gt;I built it on my experience from Wasabi, where I worked on multilingual speech-to-text and built diarization pipelines. Everything here runs on a Mac with local models.&lt;/p&gt;
&lt;h2&gt;The only judge who was there&lt;/h2&gt;
&lt;p&gt;No model knows what was actually said, and I was there. So my time went into an answer key: four test passages, four and a half minutes of audio, corrected by ear. They covered two people speaking clearly, an argument with overlap, the phone call and the exchange that mattered most to me, 530 words in 50 lines. Then I measured every model, filter and trick against my corrections instead of against each other.&lt;/p&gt;
&lt;h2&gt;What the measurements said&lt;/h2&gt;
&lt;p&gt;Four systems, each on the raw audio, on a light ffmpeg filter, and on audio cleaned by DeepFilterNet at full strength and with its attenuation capped at 18 dB. Word error rate on my passages:&lt;/p&gt;
&lt;div class="table-wrap"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Raw&lt;/th&gt;
&lt;th&gt;Light filter&lt;/th&gt;
&lt;th&gt;DeepFilterNet&lt;/th&gt;
&lt;th&gt;DeepFilterNet, capped&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Whisper large-v3&lt;/td&gt;
&lt;td&gt;14.9%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;11.1%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;27.9%&lt;/td&gt;
&lt;td&gt;19.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whisper large-v3-turbo&lt;/td&gt;
&lt;td&gt;17.4%&lt;/td&gt;
&lt;td&gt;19.2%&lt;/td&gt;
&lt;td&gt;31.5%&lt;/td&gt;
&lt;td&gt;19.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NVIDIA Parakeet-TDT-0.6B-v3&lt;/td&gt;
&lt;td&gt;20.6%&lt;/td&gt;
&lt;td&gt;22.6%&lt;/td&gt;
&lt;td&gt;33.0%&lt;/td&gt;
&lt;td&gt;31.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sheptooha, Polish w2v-BERT 2.0&lt;/td&gt;
&lt;td&gt;42.6%&lt;/td&gt;
&lt;td&gt;38.5%&lt;/td&gt;
&lt;td&gt;48.3%&lt;/td&gt;
&lt;td&gt;47.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Three things surprised me.&lt;/p&gt;
&lt;p&gt;Noise removal made every model worse. DeepFilterNet's output is much easier for a person to listen to, and it added 10 to 17 points of errors compared with the same model without it, and still 2 to 11 with the cap. It stayed in the tool as a toggle for my ears only.&lt;/p&gt;
&lt;p&gt;The Polish-only model came last. Sheptooha beats Whisper by a wide margin on its author's benchmark. On my recording it left out far-off speech: 142 of the 530 words were missing.&lt;/p&gt;
&lt;p&gt;Combining the models didn't help either. Word-by-word voting across four systems, tuned on three passages and tested on the fourth, scored 13.0% against 11.1% for large-v3 alone. Adding the previous chunk's text to Whisper's prompt, which is supposed to give it context, scored 14.7%.&lt;/p&gt;
&lt;p&gt;What worked was plain. I cut the speech into chunks of at most 28 seconds, split at the quietest moment, so Whisper never decodes long silence; that's where it invents "thanks for watching". Each chunk gets a prompt with the names and terms likely to be said, and the audio gets the light filter: a highpass, mild denoising and dynamic normalization.&lt;/p&gt;
&lt;h2&gt;The losing models as a second opinion&lt;/h2&gt;
&lt;p&gt;The models that lost were still useful. When large-v3 writes a word that fewer than two of the four other systems heard within 1.2 seconds, the word goes in italics. That marks 10% of the words, 39% of the marked words are wrong, and it catches 61% of the errors. Whisper's own confidence, the usual way to do this, caught 32%.&lt;/p&gt;
&lt;p&gt;No rule was good enough to replace words automatically. Even the strictest combination marked words that were right more than half the time, so the transcript only shows doubt. Nothing is filled in from context: every word comes from a model or from me.&lt;/p&gt;
&lt;p&gt;Timing was a separate problem. Against Parakeet, 80% of Whisper's word times were within 0.6 seconds and 10% were more than a second off. Parakeet and Sheptooha, two independent timers, agreed within 0.14 seconds on 80% of words, so line times come from Parakeet.&lt;/p&gt;
&lt;h2&gt;Who said what&lt;/h2&gt;
&lt;p&gt;Unsupervised speaker clustering, told there were five people, put the two people closest to the phone into one cluster. What worked was my corrections again: every line I checked is a voice sample with a name on it. Each two-second window of the recording is compared with each person's average voice, and the closest one wins. On checked lines held out from the samples, CAM++ named the right person on 98% of 49 lines. With all 141 lines I checked in the end, CAM++, ERes2Net and ERes2NetV2 were between 96.5% and 97.2%, so the tool tests all three and picks.&lt;/p&gt;
&lt;p&gt;Two rules mattered more than the model. Someone who spoke once or twice appears only where I placed them; otherwise a rare voice that sounds like a common one takes over a minute of someone else's speech. And the caller appears only during the call.&lt;/p&gt;
&lt;h2&gt;The page&lt;/h2&gt;
&lt;figure class="article-figure"&gt;
  &lt;img src="https://pawelrojek.dev/images/writing/transcript-review-page.webp" width="800" height="317" alt="The review page: a tab per passage, a player, and lines with a time, a colored speaker name and editable text; one line has no speaker yet and a hint that the machine was unsure about one word" loading="lazy"&gt;
  &lt;figcaption&gt;The review page on a made-up recording. Two lines have a speaker, one was split where the second person starts, and the models disagreed on one word.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The first version of the review page had a checkbox on every line and the other models' versions under each word, and it was unusable. The second works like a text editor: one passage at a time, one player, one line per person. Enter splits a line where the next person starts, Backspace joins two, Ctrl and a number sets who is talking, and the line being played lights up.&lt;/p&gt;
&lt;p&gt;Most of the later fixes were about time, because the highlight didn't follow the audio and passages cut off their first or last words. Line times now come from Parakeet, a line's end is capped at the next line's start, the highlight sits on the line that started last, and playback runs from a second before the passage to three seconds after it.&lt;/p&gt;
&lt;p&gt;The four test passages took me 30 to 40 minutes, including learning the page. I then checked eleven more passages, about eight minutes of audio, in roughly an hour. The final transcript has 163 lines checked by ear and marked ✓, 359 of the 2,055 remaining machine words in italics, and 21 lines with a weak speaker match.&lt;/p&gt;
&lt;h2&gt;What went wrong&lt;/h2&gt;
&lt;p&gt;Before publishing, I ran it end to end on a recording made with the Mac's speech synthesizer, where the right text is known. The first word after a checked passage was missing. Writing the transcript, the tool removed machine words in a time window around each checked passage, and because Whisper's times drift, the window also took words nobody had checked. In my real transcript that had happened at 3 of 30 passage edges, one to three words each time. It now removes exactly the words the page showed me.&lt;/p&gt;
&lt;p&gt;The answer key also leans toward the winner: my corrections started from the large-v3 text, so its mistakes were the ones I saw first. And all of this is one recording in Polish, which is why the tool measures again on every new one.&lt;/p&gt;
&lt;h2&gt;Using it&lt;/h2&gt;
&lt;p&gt;It's a Claude Code plugin in &lt;a href="https://github.com/plrojek/agent-skills"&gt;plrojek/agent-skills&lt;/a&gt;, under MIT: run &lt;code&gt;/plugin marketplace add plrojek/agent-skills&lt;/code&gt;, then &lt;code&gt;/plugin install transcript-review@plrojek&lt;/code&gt;. It needs a Mac with Apple Silicon, uv, ffmpeg and whisper.cpp, and downloads about 5 GB of models on the first run. It asks who was there and which moments matter, runs the models and opens the page; after you correct the test passages, it tells you which model is best on your recording, not mine.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>An MCP server that never learns where you are</title>
    <link href="https://pawelrojek.dev/writing/sanalert-mcp-server" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/sanalert-mcp-server</id>
    <published>2026-10-21T09:00:00Z</published>
    <updated>2026-11-21T09:00:00Z</updated>
    <summary>SanAlert gives an unofficial threat level from the air for places in Poland. Its server for AI assistants answers for one place without the place reaching us, and it won't let a model turn "no data" into "all quiet".</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://sanalert.pl"&gt;SanAlert&lt;/a&gt; shows an unofficial threat level from the air for places in Poland: drones and missiles tracked across the border, a level for the place you pick, and the official RCB and RSO messages in their original wording. It runs as a website, an Android and Wear OS app and a Home Assistant integration, with the iPhone app in review.&lt;/p&gt;
&lt;p&gt;The obvious question to put to an AI assistant is "is it calm in Przemyśl right now?". Since 6 October the API has had a remote MCP server for questions like that. It has six read-only tools for the whole country: the state summarized, official messages from the last 24 hours, night reports, source cards and the reliability record. None of them takes a place. A tool that takes a place on our server means our server learns where people are, and I left that open.&lt;/p&gt;
&lt;h2&gt;Working it out on the user's computer&lt;/h2&gt;
&lt;p&gt;The new server runs on the user's computer instead, next to Claude Code or Claude Desktop, and it has one tool: &lt;code&gt;sanalert_level&lt;/code&gt;. It takes one of the 44 towns from the website's list, or a latitude and longitude.&lt;/p&gt;
&lt;p&gt;It works the way the Home Assistant integration already does: it downloads the same public state document the website and the apps read, at most once every five seconds, plus the grid of Poland once per run. Then it finds the place's square on that grid and reads the level locally. No request it makes carries the place.&lt;/p&gt;
&lt;p&gt;It also refuses to geocode. A town that isn't on the list is an error that lists the towns and asks for coordinates, because looking a name up online would send the place to whoever runs the lookup. That's less convenient, and it's the point.&lt;/p&gt;
&lt;p&gt;One limit is outside the server's reach: the question and the answer still go to the assistant's provider, as anything you type into it does. The privacy page says that in the same paragraph that says the place stays on your computer.&lt;/p&gt;
&lt;h2&gt;What a model must not do with a warning&lt;/h2&gt;
&lt;p&gt;A model rewrites what it's given, and handed "Aktywność" with a line about an alarm across the border, it can easily come back with "nothing to worry about in Przemyśl". SanAlert has two rules for every surface: never narrow a warning, and no data is never quiet. The server has to hold both, even with a model in between.&lt;/p&gt;
&lt;p&gt;Every answer carries &lt;code&gt;say&lt;/code&gt;, the sentence the website shows under the level, in Polish, English or Ukrainian. The server's instructions tell the assistant to repeat the level and that sentence as they are, never to soften or narrow them, and never to call a place safe.&lt;/p&gt;
&lt;p&gt;When the state document is missing, can't be read or is older than 60 seconds, the level is &lt;code&gt;no_data&lt;/code&gt; with the reasons, never &lt;code&gt;quiet&lt;/code&gt;. A point outside Poland's grid is &lt;code&gt;out_of_range&lt;/code&gt;, so Paris doesn't come back calm.&lt;/p&gt;
&lt;p&gt;Every answer also carries the notice, the attribution and the link to NEPTUN, whose data the level partly comes from. Those are the conditions of using the data, and the server passes them on unchanged.&lt;/p&gt;
&lt;h2&gt;One set of rules&lt;/h2&gt;
&lt;p&gt;The level isn't computed by new code; the server uses a byte-for-byte copy of the Home Assistant integration's &lt;code&gt;core.py&lt;/code&gt;, and CI fails if the two ever differ. The notice and attribution texts are copies of the API's, and a test in the API fails if those drift. If the rules change, they change in one place.&lt;/p&gt;
&lt;h2&gt;The bug the review found&lt;/h2&gt;
&lt;p&gt;A Claude Code session wrote the server, under the same rules as the rest of SanAlert. Before I merged it, a separate review session read the diff and found a real bug.&lt;/p&gt;
&lt;p&gt;The age of the state document came from the computer's clock. With the clock two hours behind and our API down, the last "quiet" the server had seen would look fresh for two hours. Now the age is never less than the time the server has held the document, counted on both the monotonic and the wall clock, the larger winning. The website already worked that way. The Home Assistant integration, which shares the same core, had the same gap; its fix went out in version 1.1.1 on 21 October.&lt;/p&gt;
&lt;p&gt;On 20 October, run against the live API, it gave Przemyśl "Aktywność" because of an alarm across the border, with two official messages in force for the voivodeship. Lublin and Warsaw came back quiet, Paris &lt;code&gt;out_of_range&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Using it&lt;/h2&gt;
&lt;p&gt;The code is at &lt;a href="https://github.com/plrojek/sanalert-mcp"&gt;github.com/plrojek/sanalert-mcp&lt;/a&gt;, under MIT. In Claude Code the easiest route is the plugin, which adds both servers, the local one and the remote one for the whole country: run &lt;code&gt;/plugin marketplace add plrojek/agent-skills&lt;/code&gt;, then &lt;code&gt;/plugin install sanalert@plrojek&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It isn't an official warning system and doesn't replace sirens, Alert RCB or instructions from the authorities. The server says so in every answer too.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Garden plans that nobody checks</title>
    <link href="https://pawelrojek.dev/writing/garden-plans-nobody-checks" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/garden-plans-nobody-checks</id>
    <published>2026-10-20T09:00:00Z</published>
    <updated>2026-10-20T09:00:00Z</updated>
    <summary>A model designs the garden and code decides whether the plan goes out. No person reads it first.</summary>
    <content type="html">&lt;p&gt;It started with the garden for my own plot. The 3D viewer was working within the first few days - you scroll through the months and watch the hedges grow - and the planting plan for the whole plot took about five weeks.&lt;/p&gt;
&lt;p&gt;Then I wanted to see if someone else could get the same thing from a form - draw the plot, describe the house, say what you want, get a plan back. I decided early that no person would review the plans; tests would have to show whether the tool works on its own. I set what the product should do and what it must never do.&lt;/p&gt;
&lt;p&gt;The first test run looked fine. The model wrote the plan and, next to it, the checks for it. At 21 of 21 passing it still had sun-loving plants under a birch, which only showed up when the numbers behind the pass were read; it fixed its checks and its plan and finished at 23 of 23.&lt;/p&gt;
&lt;p&gt;So the checks became product code, written before any plan and the same for every customer. Run through that suite, the 23-of-23 plan got 11 passes, 3 warnings and 4 failures: sun plants in real shade, perennials planted alone or in pairs, an allium 30 cm from the middle of a hydrangea, and ornamental allium in a house with a dog.&lt;/p&gt;
&lt;h2&gt;Who does what&lt;/h2&gt;
&lt;p&gt;The model writes &lt;code&gt;plan.json&lt;/code&gt;: zones, where each tree and shrub goes, a recipe for each bed (which species, in what share) and a text for the customer that explains the choices. It can only use plants from a database of about 400 species, which it reads through a small query tool and never as a whole file.&lt;/p&gt;
&lt;figure class="article-figure"&gt;
  &lt;img src="https://pawelrojek.dev/images/writing/garden-planner-plot-e-plan.webp" width="520" height="660" alt="Top-down plan of an invented test plot: a house turned at an angle, a garage, a hedge along one side, a large walnut tree, beds and a lawn" loading="lazy"&gt;
  &lt;figcaption&gt;Test plot E from above. The model placed the trees and hedges and wrote the bed recipes; code laid out every plant in the beds.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Code does the rest. It lays out the beds from the recipes (tall plants at the back, drifts, groups of at least three), builds the scene for the viewer, counts plants and prices, and runs the checks; there are about thirty of them now. A tree with its crown over the house fails, so does a woody plant over a gas line, a poisonous plant in a garden with a child under seven, or a terrace the neighbor can still see from an upstairs window ten years after planting. The light check uses the same sun model as the viewer, so a plant is judged by the shade the customer will see.&lt;/p&gt;
&lt;p&gt;To prove each check works, the repo has 64 planted faults, each a plan or a small scene with exactly one thing wrong, and every one has to be caught by its check. They run after every change to the pipeline.&lt;/p&gt;
&lt;p&gt;If the customer didn't give us something, for example the soil or the children's ages, the check that needs it answers &lt;code&gt;not_checked&lt;/code&gt;. It doesn't guess, and the model is told not to make it up either.&lt;/p&gt;
&lt;h2&gt;The gate&lt;/h2&gt;
&lt;p&gt;Passing checks isn't enough to send a plan. After every model session a script, &lt;code&gt;deliver.py&lt;/code&gt;, reads the files and picks the next step:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first designer session leaves something failing: a fresh session gets the list of failures and one try to fix them;&lt;/li&gt;
&lt;li&gt;that fails too: the order is not delivered, and the customer gets a plain note on what couldn't be reconciled (the plan was a full refund, but payments were never built);&lt;/li&gt;
&lt;li&gt;the plan passes: a different session reads it the way a gardener would and writes comments;&lt;/li&gt;
&lt;li&gt;the comments get one revision round, and if that round breaks the plan, the version from before it goes out.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That makes at most four model sessions per order. Warnings never stop delivery, but the text has to mention every one of them.&lt;/p&gt;
&lt;p&gt;The second look is a model reading another model's plan. On its first plan it found that "338 m² of connected lawn" was all the grass on the plot joined through a one-meter neck, with a rowan standing in it; by its own count the lawn you can play on was about 120 m². It noticed that the privacy figure in the text was the ten-year one and the text didn't say so, and that two hydrangeas less than a meter from the path would flop onto it. The designer had also told the customer to buy sand for a meadow because "no moist-meadow mix exists", while the database had one, added after the text was written. None of the checks caught any of this.&lt;/p&gt;
&lt;p&gt;The text has its own check too. &lt;code&gt;rationale_check.py&lt;/code&gt; holds the figures and plant names in the text against the plan; run over the 15 texts we had, it failed 14, mostly because the checks had changed after those texts were written.&lt;/p&gt;
&lt;p&gt;Everything the customer types is screened at the intake (length, markup, invisible characters) and passed to the models as the customer's words. The prompts say it's never an instruction, and the sessions can only read and write inside the order's folder.&lt;/p&gt;
&lt;h2&gt;What it costs, and what's missing&lt;/h2&gt;
&lt;p&gt;On Opus 5.5 a first plan took 8 to 15 minutes and 2 to 4 dollars at API list prices, measured on four invented plots, and all four ended with no failed checks. A whole order through the gate, with the second look and a revision round, took about 27 minutes.&lt;/p&gt;
&lt;figure class="article-figure"&gt;
  &lt;img src="https://pawelrojek.dev/images/writing/garden-planner-plot-e.webp" width="1440" height="900" alt="The garden planner's 3D viewer showing test plot E: a house with a garage, a walnut tree, beds and a lawn, with month, hour and growth sliders" loading="lazy"&gt;
  &lt;figcaption&gt;The same plot in the 3D viewer after a full order: designer, second look, one revision. October, year five.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;I also went through it the way a customer would and filled in the order form for my own plot. The layout checks passed all three layouts that came back, and I still found plenty to fix: there was no preview of the house as I typed it in and no way to upload a plan, the layouts had too few trees for a plot that size, one layout's cost estimate ran from 10 to 52 thousand zł, and the evenly spread dots on the plans looked like far too many plants. The house editor and the plan upload are in the public code. The changes to costs and to the plan view stayed on a branch that was never merged, and more trees on big plots is still an open item.&lt;/p&gt;
&lt;p&gt;The light model treats every plot as flat, so sun on a slope is wrong. The species data hasn't been checked record by record, and 280 records still have no soil check. The designer aims the midpoint of its cost estimate at the budget, so in three of the four test plans the upper estimate went over it. And the second look is still a model; it found real problems, but I have no measure of what it misses.&lt;/p&gt;
&lt;p&gt;I don't have time to keep building it, so the code is on GitHub under MIT: &lt;a href="https://github.com/plrojek/garden-planner"&gt;plrojek/garden-planner&lt;/a&gt;. The viewer on its own is a Claude Code skill in &lt;a href="https://github.com/plrojek/agent-skills"&gt;plrojek/agent-skills&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Where my rules for coding agents came from</title>
    <link href="https://pawelrojek.dev/writing/rules-for-coding-agents" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/rules-for-coding-agents</id>
    <published>2026-10-19T09:00:00Z</published>
    <updated>2026-10-19T09:00:00Z</updated>
    <summary>CityChat has merged 974 pull requests since June, some of them written by agent sessions. The rules those sessions work under fit on one page, and most of them came from an incident.</summary>
    <content type="html">&lt;p&gt;Since early June the &lt;a href="https://pawelrojek.dev/citychat"&gt;CityChat&lt;/a&gt; repository has merged 974 pull requests. It's one repo for two native apps, a Go backend, the admin and business portals, the website and the data tools. I wrote CityChat's code myself, along with Claude, and a lot of my time goes into checking what the agent sessions produce. I choose the work. I test the apps myself on a phone and in the simulator, and a session has to tell me exactly what to test; no build goes to TestFlight or the stores without my OK, and before a store release the session has to list the known defects and what's still missing. Nothing reaches production until I say so.&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://sanalert.pl"&gt;SanAlert&lt;/a&gt;, another of our apps, nothing under &lt;code&gt;ios/&lt;/code&gt; merges until I've seen it working in the simulator myself. Several of the rules below are ones I set myself.&lt;/p&gt;
&lt;p&gt;For bigger pieces of work the split is simple. One session investigates against the live code and writes a plan note, with every bug pinned to a file and line. Another session, often on a cheaper model, gets one slice of that plan plus a page of hard rules - the plan and the rules are supposed to be everything it needs, and breaking any rule counts as a failed session.&lt;/p&gt;
&lt;h2&gt;Git&lt;/h2&gt;
&lt;p&gt;Never work on main; branch from &lt;code&gt;origin/main&lt;/code&gt; in a fresh worktree. I edit the same repo while agents run and my local main is often days behind, so a session that branches from my checkout builds on whatever state I left it in.&lt;/p&gt;
&lt;p&gt;Never use &lt;code&gt;git stash&lt;/code&gt; when agents work in parallel, because all worktrees of a repo share one stash stack. In September eight agents were fixing things in SanAlert at the same time. One of them stashed its work, another stashed its own changes to run a test, popped the stash and got the first one's files. It noticed and gave them back, but that was luck. Now agents test against a temporary commit or a separate worktree, and the rule is in every agent's prompt.&lt;/p&gt;
&lt;p&gt;Before anything is called ready, read what disappears and not only what was added: &lt;code&gt;git diff | grep '^-'&lt;/code&gt;, and every removed line has to match something that was asked for. I added that during the same SanAlert run, when the agents were about to touch remote branches, deploys, network policies and database migrations at once.&lt;/p&gt;
&lt;h2&gt;Proof&lt;/h2&gt;
&lt;p&gt;Paste the output of the command before saying something works. A session can say "verified" about tests it never ran, so the rules name the exact commands. For the backend it's &lt;code&gt;go build&lt;/code&gt;, &lt;code&gt;go vet&lt;/code&gt; and &lt;code&gt;go test&lt;/code&gt;. For Android it's &lt;code&gt;:app:assembleDebug :app:testDebugUnitTest&lt;/code&gt;, because &lt;code&gt;compileDebugKotlin&lt;/code&gt;, which agents like to reach for, skips the test sources and comes back green.&lt;/p&gt;
&lt;p&gt;An exit code of 0 doesn't prove much either. Copying a 195 MB database dump out of a Kubernetes pod with &lt;code&gt;kubectl exec ... cat&lt;/code&gt; came back 3.5 MB short once and 4.1 MB short the second time, both with exit code 0; the process in the pod ends before kubectl has drained the stream. The fix is a trailing &lt;code&gt;sleep 5&lt;/code&gt; inside the pod, plus a size and sha256 comparison with the file in the pod and a retry when they differ.&lt;/p&gt;
&lt;p&gt;If the code doesn't match the plan, stop and report. Plans are written against a commit, and by the time a cheaper session picks one up the code may have moved. A session that improvises fills the gap with a guess, and then I have to find the guess in review.&lt;/p&gt;
&lt;p&gt;Before a merge, an independent reviewer agent reads the diff and the evidence, and a stronger model takes a second look. I added that in October, after a production promote passed the session's checks and one noisy sponsored-place test then failed about 90% of the time, because of drift on the model's side.&lt;/p&gt;
&lt;h2&gt;Production&lt;/h2&gt;
&lt;p&gt;Deploy only when I say so, in the current conversation. Merging to main deploys to staging on its own and production is a separate promote; a permission written down in an earlier session's notes doesn't count.&lt;/p&gt;
&lt;p&gt;Never &lt;code&gt;helm upgrade --reuse-values&lt;/code&gt;, and never restart a deployment that runs a mutable image tag. Both can ship a version or a config nobody chose.&lt;/p&gt;
&lt;p&gt;Secrets never get printed, and never go into a file or a note. To use one in a smoke test, read it into a shell variable, don't echo it, and unset it afterwards.&lt;/p&gt;
&lt;p&gt;The chat's prompt has defenses against prompt injection, and anything untrusted that goes into it passes through a sanitizer first: place descriptions, the user's saved memory, text from the web. Those defenses have to survive every edit to that file.&lt;/p&gt;
&lt;p&gt;The last rule is about the token budget. In July I stopped a review workflow with 45 agents, where every finding was checked by other agents trying to refute it; a run like that uses one and a half to two and a half million tokens, and two had run that day. Now sessions verify inline unless I ask for a big review, and if they think one is worth it, they say what it would cost and let me decide.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Two days of choosing a chat model for Polish</title>
    <link href="https://pawelrojek.dev/writing/choosing-a-chat-model-for-polish" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/choosing-a-chat-model-for-polish</id>
    <published>2026-10-18T09:00:00Z</published>
    <updated>2026-11-21T09:00:00Z</updated>
    <summary>Google gave the model behind CityChat's chat an earliest shutdown date. Switching to the suggested replacement would have been one line of config; I measured first, and on the second day the answer changed.</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://pawelrojek.dev/citychat"&gt;CityChat&lt;/a&gt; is a city guide you talk to. It runs in 16 cities in Poland and Spain, and most conversations are in Polish. In early October the chat ran on &lt;code&gt;gemini-3.1-flash-lite&lt;/code&gt;, and Google's deprecations page listed 7 May 2027 as the earliest date it might be switched off, with 3.5 Flash-Lite named as the replacement. Changing the model is one environment variable; instead I spent two days measuring. I ran the tests, picked what to test after each round and made the final call.&lt;/p&gt;
&lt;h2&gt;What I measured&lt;/h2&gt;
&lt;p&gt;The harness was the golden suite I already had in CI: 35 tests (45 by the second day) against a small fixture of eight places and two events in a made-up town much like Przemyśl, with the production prompt.&lt;/p&gt;
&lt;p&gt;The tests check behavior. Every place an answer mentions has to be one the model was given, a broad evening question in Polish has to mix bars and restaurants, a sponsored place that doesn't fit the question has to be left out, and the model shouldn't ask "near you or in the whole city?" when the user already named the city. Each model ran the suite ten times and the flaky tests 40 to 50 times, streaming, from Poland, with the fallback switched off so every model stood on its own.&lt;/p&gt;
&lt;p&gt;Next to the pass rates I counted two more things. One was replies that cite a place id the model was never given. The other was Polish language errors: a second model read the replies as a blind copy editor, without knowing which model wrote them, and then every flag it raised was checked one by one.&lt;/p&gt;
&lt;p&gt;On the first day Google's replacement, 3.5 Flash-Lite, passed 96% of the suite (93% before I discounted failures that came from my own language check) against 98% for the model in production, and it was a little faster. On fresh Kraków content it made about 22 Polish errors per 80 replies against about 4, and it wrote "w piwnici", a case ending that doesn't exist, in 16 of 170 Polish replies. It also ignored a vegan user's saved preference in 15 of 40 runs. One line in the prompt fixed that (39 of 40); for the Polish there was no known fix.&lt;/p&gt;
&lt;p&gt;Google's other suggestion for new projects, 3.8 Flash, wrote the best Polish of anything I measured, about one error per 80 replies. It also took 2.6 seconds to the first word at the median, more than 10 seconds on 13% of calls, and on 3% it didn't answer within a minute, which is too slow for a chat on a phone.&lt;/p&gt;
&lt;p&gt;The fallback I had configured, 3.5 Flash, was worse than the primary on everything I measured: six times the price, and invented place ids in 9 of 420 replies. It was also at the same provider, so a problem at Google would hit both.&lt;/p&gt;
&lt;p&gt;So on day one the answer was to keep the current model and pick a successor later, with an A/B on staging.&lt;/p&gt;
&lt;h2&gt;The second day&lt;/h2&gt;
&lt;p&gt;The next morning I tried two models from other providers, OpenAI's GPT-6 Luna and Claude Haiku 5.5, which had come out the day before. Luna wrote clean Polish and was the cheapest, but in 18% of replies it asked "near you or in the whole city?" instead of answering. Haiku was the quickest to start and got the sponsored-place rule right every time, but it made about nine times as many Polish errors.&lt;/p&gt;
&lt;p&gt;Luna's problem looked like a prompt problem; the rule for when to ask that question had been tuned on Gemini, which almost never asks it. I rewrote the rule so the default is to answer, and the question comes only when the request is broad and gives no hint of where. Unwanted questions fell from 18% to 0.4%.&lt;/p&gt;
&lt;p&gt;Luna was still slower to the first word. OpenAI's Fast tier fixed that: 0.62 seconds at the median, the same as Gemini. Fast costs twice the standard price, and even so Luna was about 20% cheaper than Gemini at list price.&lt;/p&gt;
&lt;p&gt;One thing the sessions couldn't check was the project's region in OpenAI's dashboard, so I looked myself. The region of an existing project is fixed, and the dialog for a new one didn't offer the EU either; EU residency would need an approval through their sales team, and the Fast tier can't be combined with it anyway. The chat runs from a global project for now, as it did on Gemini's API before.&lt;/p&gt;
&lt;p&gt;The final run was about 750 calls per model, on the code that was in production that day:&lt;/p&gt;
&lt;div class="table-wrap"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Gemini 3.1 Flash-Lite&lt;/th&gt;
&lt;th&gt;GPT-6 Luna, Fast&lt;/th&gt;
&lt;th&gt;Claude Haiku 5.5, thinking on&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Checks passed&lt;/td&gt;
&lt;td&gt;96.5%&lt;/td&gt;
&lt;td&gt;99.4%&lt;/td&gt;
&lt;td&gt;99.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Polish errors per 60 replies, each one checked&lt;/td&gt;
&lt;td&gt;≈4&lt;/td&gt;
&lt;td&gt;≈8&lt;/td&gt;
&lt;td&gt;≈19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First word, median&lt;/td&gt;
&lt;td&gt;0.63 s&lt;/td&gt;
&lt;td&gt;0.61 s&lt;/td&gt;
&lt;td&gt;1.62 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List price per 1,000 calls&lt;/td&gt;
&lt;td&gt;$1.56&lt;/td&gt;
&lt;td&gt;$1.24&lt;/td&gt;
&lt;td&gt;$1.13&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Gemini's Polish was a bit cleaner, but Luna's mistakes were awkward phrasing and not broken words. Haiku needed thinking switched on to get its structure right - I asked for that second round - and then it took a second longer to start; with the Polish on top of that, it was out. I moved the chat to Luna that evening and kept Gemini as the fallback, so the fallback is now at a different provider.&lt;/p&gt;
&lt;p&gt;Before the switch I changed the design of that question as well. A broad question from someone whose location the app knows now gets an answer for the area around them straight away, with distances, and two chips at the end - "near me" and "anywhere in the city" - instead of a question first.&lt;/p&gt;
&lt;h2&gt;Where the measuring went wrong&lt;/h2&gt;
&lt;p&gt;My harness favored the model I already had. In a July A/B, 6 of the 8 failures of the challenger came from my own code: the function that decides whether a reply is in Polish used a word list built on the incumbent's replies. This time every failure that hinged on that function was re-scored with a stricter check, and still the language check marked two of Luna's correct replies as failures in the final run.&lt;/p&gt;
&lt;p&gt;The spend I tracked during the runs was also about three and a half times lower than what the billing page showed later. The same key served other test runs on those days, so I can't split it cleanly, but the estimate was wrong either way.&lt;/p&gt;
&lt;p&gt;Two days can't show drift from one week to the next, and Flash-Lite had drifted before: the same test failed 21 of 80 runs one day and 18 of 20 the next.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Fact-checking a database with research agents</title>
    <link href="https://pawelrojek.dev/writing/fact-checking-with-research-agents" rel="alternate" type="text/html"/>
    <id>https://pawelrojek.dev/writing/fact-checking-with-research-agents</id>
    <published>2026-10-17T09:00:00Z</published>
    <updated>2026-10-17T09:00:00Z</updated>
    <summary>Research agents are good at finding sources and bad at quoting them. What I check after them, learned on a run over about 14,900 places.</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://pawelrojek.dev/citychat"&gt;CityChat&lt;/a&gt;'s catalog holds places with descriptions, opening hours, menus and contacts, and all of it goes stale: restaurants close, hotels rebrand, museums switch to winter hours. To check it I sent every place to research agents (Claude models, coordinated by a Claude Code session) and let them read the web. It only worked because nothing an agent said went into the database without passing through code that checks it. Most of the setup applies to any job like this - a product catalog, a directory, a price list.&lt;/p&gt;
&lt;h2&gt;Give the agents a source policy&lt;/h2&gt;
&lt;p&gt;A goal like "check if this restaurant is still open" isn't enough. Write down which sources count: the venue's own site and its social page, official city and tourist portals, local news. And which don't: map listings and their mirrors, review sites, delivery apps and booking sites, which copy each other and go stale together. Hours are quoted from a page and never inferred, and dish names are copied as printed, never translated.&lt;/p&gt;
&lt;p&gt;Put those rules in the prompt itself. I first kept them in a protocol file that the prompt pointed to, and the agents skimmed it; a rule in the prompt gets followed more often, though still not always. Batches of 30 places with about eight agents running at once worked well, and every proposal had to come back with the address of the page it came from.&lt;/p&gt;
&lt;h2&gt;Check every claim in code&lt;/h2&gt;
&lt;p&gt;The trap that matters most: the web fetch tool an agent uses returns a model's summary of the page, not the page. So "the page says 9 to 17" can be the summary's guess. Every proposed opening time, dish and price is fetched again, raw, and has to appear in the source word for word, or it doesn't go in. This gate caught most of the invented hours.&lt;/p&gt;
&lt;p&gt;Structured data on websites needs the same care. Many site builders fill in "Mo–Su 09:00–17:00" by default and the owner never changes it. A restaurant page can carry its bar's data, and my own script that read it merged a day listed twice, morning and afternoon, into one range, so a café with split hours came through with only its afternoon. Treat structured data as a hint and read the visible text.&lt;/p&gt;
&lt;p&gt;The mistakes I saw again and again, worth a test each:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;days the page doesn't name, filled in anyway;&lt;/li&gt;
&lt;li&gt;a day with split hours flattened into one range, or dropped;&lt;/li&gt;
&lt;li&gt;hours taken from another branch of the same chain, from a guide site or from a search snippet;&lt;/li&gt;
&lt;li&gt;menus translated from the English version instead of quoted;&lt;/li&gt;
&lt;li&gt;too few searches: told to make three to five per place without a website, the agents averaged one or two.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Deleting needs more evidence than adding. A place goes as closed only on the venue's own announcement, the operator, an official portal or local news; a dead domain or a directory listing isn't enough, and anything uncertain stays. A building and the institution inside it, like a palace and the museum in it, stay as two places.&lt;/p&gt;
&lt;h2&gt;Write as if it will fail halfway&lt;/h2&gt;
&lt;p&gt;All writes go through one queue, one job at a time, so two jobs never edit the same record. The state of every record before the write goes into a ledger, and every write is read back. When a job fails, the queue stops and the rest waits. In my run the admin token expired overnight halfway through a city; the queue stopped cleanly and carried on from the ledger the next morning, and every city finished with no failed writes.&lt;/p&gt;
&lt;p&gt;Some facts come with a date. Hours written in October are autumn hours, and nothing refreshes them on its own, so the ones that change with the season get a reminder.&lt;/p&gt;
&lt;p&gt;Over five days about 14,900 places in 16 cities went through this. In the first city 433 places were researched and 340 changed: 278 new descriptions, opening hours set or corrected for 64 places and removed as wrong for 8, and 28 priced menus from the venues' own sites. One restaurant's menu turned out to be a kebab shop's list. Places without a website stayed thin; with nothing to read, many of them ended as "unverified".&lt;/p&gt;</content>
  </entry>
</feed>
