Back to writing
November 26, 2026ยท10 min readTaras YaremaCo-founder, Desplega LabsGitHubBlogLinkedInX + the swarm

SQLite to PostgreSQL in 6 Days: A Timeline

The log of 6 days: a swarm writes a PostgreSQL storage engine in one weekend, we copy 24 million rows 3 times, switch production at 01:44, and get the first error at 01:46.

PostgreSQLSQLitedatabase migrationAI agentstestingopen source

We started Agent Swarm on SQLite on purpose. One file is simple to run and easy to deploy. We knew that we would need PostgreSQL if we scaled. Then the scale came. Our own file grew to 87 GB, one long statement could stall the API, and the next steps on our list need a database that several processes can share. KISS paid. SQLite took us this far, and it stays the default.

This post is the log of those 6 days. Times are Barcelona time. The mark on each entry says who did the step: Dani or Taras, Dani's swarm, our swarm, a coding session, or CI.

Production
SQLite
Human
Dani's swarm
Our swarm
Coding session
CI

Thu 12 NovPostgreSQL goes on the list

  1. that dayCoding session

    No in-process SQLite driver on Bun is non-blocking

    We measured the in-process SQLite drivers that run on Bun. Each of them blocks the event loop while a statement runs. The plan from that research was a worker thread for SQLite. We deferred PostgreSQL.

Fri 20 NovA call and 2 prompts

  1. Dani and Taras

    A call sets the rules

    Dani runs Agent Swarm at his company and had the same limit. He and Taras agreed on 4 things on a call:

    • Both engines stay supported. DATABASE_URL selects PostgreSQL, and an install that does not set it behaves as before.
    • Raw SQL stays, behind a thin storage interface. No ORM.
    • No phased plan. A swarm gets one goal. Every E2E test must pass on both engines.
    • The target date is before Christmas.

    From the transcript of the call, with the filler words removed:

    A goal, to say: okay, you have all these E2Es. Just switch the connection to Postgres, and ensure that the E2Es pass with both SQLite and Postgres. And that's it. Maybe that's the easiest way to do it.

    Tarason the call10:35

    But I'm pretty sure that every SQLite query has a Postgres equivalent.

    Danion the call10:40

    95%, yes. The other 5% no.

    Tarason the call10:40

    If this is something that we could put under the Christmas tree, I would be super happy.

    Danion the call10:58

    It's doable. It's just a matter of figuring out the good prompt to do that, and then do the last 10%, which is the worst part, which is just ensure that it's okay, okay, okay, and just merge it and that's it.

    Tarason the call10:58
  2. Dani

    A research prompt

    Dani asked for a research phase first, then a decision.

    Written with Fable locally ๐Ÿ˜„

    let me know what you'd steer and I'll kick it off afterwards

    Daniin Slack13:17
  3. Taras

    A brainstorm and a goal prompt

    Taras answered with the same model and another style: a brainstorm and a goal prompt. The goal prompt has an objective, 18 numbered decisions, and conditions that say when to stop.

    lets join both? hajaj was on meeting so could not send before

    Tarasin Slack16:30

    it seems you already want to jump into the implementation with a "goal", while mine is trying to be a preliminary research phase before saying "goal: implement direction X, stop when conditions met" ๐Ÿ˜„

    Daniin Slack16:34

    jaja you can run that and correct wht i did, mine was a brainstorm with some bg research

    a bit more yolo jajaj

    Tarasin Slack16:53

    The yolo version won. The brainstorm and the goal prompt became the input of the engine build. The research ran first.

  4. Dani's swarm

    The discovery

    Dani gave his research prompt to his swarm. The first researcher agent stopped on a usage limit after 21 minutes, and the lead gave the work to a second one. The report came at 18:07 and cost 71 USD.

    The report checked the 1,495 static SQL statements in the code against PostgreSQL. Of those, 1,221 planned with only the placeholders changed. That is 81.7%, and 90.1% after 2 mechanical changes. The 95% of the morning call was a fair guess.

  5. Dani

    The engine prompt goes to the lead

    Dani gave the 2 files to the lead of his swarm. 3 minutes later a worker agent, Picateclas, started. Its first commit came at 00:07. From here the swarm wrote the code.

Sat 21 NovA swarm works the weekend

  1. Dani's swarm

    A stronger contract, on SQLite first

    The worker did not start with PostgreSQL. It took a baseline and finished a driver spike at 00:27. Then it added 26 parity scenarios to the storage contract suite, on SQLite. With them, the suite would catch a difference between the engines later.

  2. Dani's swarm

    Stopped by a limit, resumed by the lead

    A session stopped on a spend limit at 03:30. Another stopped on a usage limit at 10:12, after 5 hours and 6 minutes of work. Both times the lead of the swarm resumed the work 2 minutes later.

  3. Dani's swarm

    The API starts on PostgreSQL

    The worker finished the storage packages on SQLite at 11:26. At 12:56 the PostgreSQL engine was ready, and the API started on it for the first time.

    / 118 tasks, 7 agents

    A swarm at work over one weekend

    The discovery on Friday afternoon, the engine build from Friday 23:56 to Sunday 02:02, then the review rounds until the merge.

    Loading interactive chart
    The gaps on Saturday evening are waits for a human.
  4. Dani

    14 hours in

    Our swarm has been at the migration for 14 hours ๐Ÿ˜‚

    Daniin Slack14:22

    LOL

    and how is it going?

    Tarasin Slack14:34
  5. Dani's swarm

    No SQL left outside the storage layer

    At the start the server code held 2,193 SQL call sites in 246 files. Milestone 4 moved every one of them into the storage packages.

    / the storage boundary

    2,193 SQL call sites, down to zero

    Each bar is one run of the check that lists SQL outside the storage packages.

    Loading interactive chart
    SQL call sites outside the storage layerin 246 files
    2,193
    transaction sitesin 127 files
    291
    tables418 indexes, 65 triggers
    158
    writes that were not safe to run twicefound and fixed in 20 files
    44
    The swarm made this inventory at the start of the build.
  6. Dani's swarm

    The status, in its own words

    Dani asked his swarm for its status and pasted the answer:

    2 lines of that status mattered later. A transaction on PostgreSQL can run again after a serialization failure, so the hook undoes the state in memory when a transaction rolls back. And the 2.5 seconds of memory search became the slow search of the first night on production.

    niceee

    what was the input?

    Tarasin Slack15:51

    Your two files in the end ๐Ÿ˜…

    Daniin Slack15:52

    XD

    cost so far?

    Tarasin Slack15:52

    410$

    Did you add some sort of native goal support to the swarm harness, or is it coincidental that it's running on its own towards the "goal"?

    Daniin Slack15:53

    not really jaja can you ask it why, it could be bacuse the playbooks of docs.agent-swarm.dev are passed as optional skill to get "patterns" to use in the swqarm, so maybe it figured it out via that

    Tarasin Slack15:54
  7. Dani's swarm

    The swarm stops and asks

    The worker stopped, and the lead opened an approval request with 2 questions. It did this 4 times that evening. In total it waited 250 minutes for a human.

    Approval requests4 answered ยท Sat 21 Nov
    1. Dani's swarm, the leadCreated 15:561 of 4

      Postgres engine: decision needed

      AnsweredbyDani18:18
      1. JSON storage: jsonb changes the key order, and 2 scenarios compare JSON text byte for byte. Which column type?Answer: Keep jsonb and compare parsed values.
      2. Write retries are far above the 5% target at the poll claim. What next?Answer: READ COMMITTED with FOR UPDATE SKIP LOCKED at the poll claim, then measure again.
    2. Dani's swarm, the leadCreated 18:422 of 4

      Write conflicts at task finish and task creation

      AnsweredbyDani20:08
      1. Task finish still has a write conflict in 71.7% of transactions. Apply the poll claim fix there too?Answer: Apply the fix to task finish.
      2. Task creation with an idempotency key conflicts in 90%. Keep it?Answer: Keep keyed task creation strict, at SERIALIZABLE.
    3. Dani's swarm, the leadCreated 20:253 of 4

      4 races above the 5% target

      AnsweredbyDani20:38
      1. Accept 3 single-row races (about 90% each) as exceptions to the 5% target?Answer: Accept them as exceptions.
      2. Accept agent registration (59.3%) too?Answer: Accept it too. No code change.
    4. Dani's swarm, the leadCreated 23:134 of 4

      Task creation retries and one failed webhook scenario

      AnsweredbyDani23:21
      1. Task creation without an idempotency key retries in 58.3% of transactions. Fix it or accept it?Answer: Fix it with the task finish method.
      2. One webhook scenario failed one time in a full PostgreSQL run. Investigate, or record it and continue?Answer: Continue the investigation.
    A redraw of the approval screen of the dashboard. We shortened the titles and the text.
  8. Dani and Taras

    A second opinion

    Dani sent the first request to Taras before he answered it:

    Any strong opinions?

    Daniin Slack17:44

    i would go w jsonb always

    Tarasin Slackthat evening
  9. Dani

    jsonb stays, and the poll claim gets a lock

    The first answer went to the worker at 18:18. 22 minutes later it had the result.

    / write retries

    3 hot paths that kept retrying

    At SERIALIZABLE, most transactions on these paths lost a race and ran again. With READ COMMITTED and explicit row locks, all 3 measured 0%.

    Loading interactive chart
    Measured in the seeded bench of the branch. No transaction ran out of retries.

    3 hot write paths left SERIALIZABLE this way. 4 single-row races stayed near 90% on purpose, as accepted exceptions. Everything else runs at SERIALIZABLE, with a retry on each serialization failure.

  10. Dani's swarm

    A copy command

    Milestone 6 was a command that copies a SQLite database into PostgreSQL. Its test copied 140 tables and 15,310 rows, with every checksum equal. 3 days later the same command copied 24 million rows.

  11. Dani's swarm

    The contract suite passes on PostgreSQL

    The last fix of the evening brought the retries of task creation from 68.6% to zero. With it, the contract suite passed on PostgreSQL.

Sun 22 NovThe PR

  1. Dani's swarm

    Both engines pass the full suite

    The E2E suite boots the real API and checks its answers. In strict mode it passed on both engines, with 242 scenarios on each.

  2. Dani's swarm

    A PR in the fork

    The worker opened the PR in Dani's fork first. A reviewer agent on another model, gpt-6.1-sol, reviewed it 3 times before 04:06: 4 findings, then 1 blocker, then none. The first green run of the merge gate came at 02:27.

  3. Dani

    PR #3562 opens

    / PR #3562

    Postgres as a second storage engine

    Opened by Dani on Sunday 22 November at 13:27, 37 hours after the engine prompt. Merged on Monday at 17:07. desplega-ai/agent-swarm#3562

    commits
    417
    files changed
    781
    lines added
    +94,917
    lines removed
    โˆ’24,626

    / 94,917 lines added

    Where the lines went

    The 3 storage packages hold 57,214 of the added lines.

    Loading interactive chart
    Most of the removed lines are code that moved from `src` into the storage packages.
  4. that dayCoding session

    Verification starts

    We did not review 94,917 lines one by one. A coding session checked the PR on 10 temporary servers, in 5 rounds before the merge. It ran what the repository already had: the unit suite, the contract suite and the E2E suite. Each ran on both engines. The E2E suite made the merge possible. It gave the swarm a definition of "done" that we could run again.

    By the switch we had 7 layers of checks:

    1. 01Storage contract testsOne suite, 2 engines. This was the spec that the swarm built against.Found: The base for everything else
    2. 02E2E suite in the merge gateBoots the real API on SQLite and on PostgreSQL, 6 shards each.Found: A bulk write with one commit for each row
    3. 03Deterministic simulationWorkloads with injected faults, the same seed gives the same run.Found: A 15 minute hang on dead connections
    4. 04Trial swarm with a stress packA full swarm on PostgreSQL for days, with forced rollbacks.Found: Seeded schedules that kept their SQLite text
    5. 05Rehearsals on production dataFirst an isolated restore, then the real target.Found: 9,423 rows that PostgreSQL refuses, a 64 MB shared memory limit
    6. 06Statement replay1,450 ported statements, run against the trial swarm.Found: 11 failures: JSON parameters, one unquoted column
    7. 07Nightly commit budgetFails when one request makes more commits than its budget.Found: Nothing yet. It guards the fix above

Mon 23 NovMerge, then production data

  1. that dayCoding session

    First rehearsal on a restore of production

    We restored a backup of production on an isolated server and booted the API twice, on main and on the branch. A sweep of 157 read endpoints gave the same status on both.

  2. Taras

    PR #3562 merges

    The merge of PR #3562 came under 4 days after Dani's first prompt. It took 30 review rounds: 3 by the swarm's own reviewer in the fork, 12 from Taras's account and 15 by our review bot. The merge gate ran 123 times, and 48 of those runs failed.

  3. Dani and Taras

    The first plan for the data

    On a second call we described the data move in one line: stop the swarm on a Saturday, dump SQLite, restore into PostgreSQL, change the environment, start. From the transcript, with the filler words removed:

    It's 10 minutes after deploy, all green. Now the interesting part really is the migration to Postgres.

    Tarason the call17:33

    The data migration itself, I would say it's deterministic almost. I would assume the SQL statements don't even require a rewrite, because it's just a bunch of inserts.

    This is a very simple playbook: dump and restore.

    Danion the call17:36

    I will do the copy anyways, just to have it.

    Tarason the call17:38

    The next 2 days showed that the copy was most of the work.

  4. that dayCoding session

    A trial swarm starts on PostgreSQL

    A full stack started on its own server. It has a lead, a pool of workers, and a stress pack of scripts, workflows and schedules. The pack forces about 9% of the transactions to roll back. The trial swarm still runs.

Tue 24 NovThe copy tool runs on production rows

  1. Coding session

    A 15 minute hang, found by simulation

    The deterministic simulation runs the API against a database with injected faults, and the same seed gives the same run. It found a hang. When every connection died without a close, the health check still passed and every request hung for about 15 minutes. Since #3587 the API exits after 10 seconds, and its supervisor starts it again.

  2. Coding session

    db-copy names every refused row

    agent-swarm db-copy copies a SQLite file into an empty PostgreSQL database in one transaction. Then it compares a row count and a checksum for every table. If anything differs, the target stays empty.

    Production data did not pass. Since #3602 one run lists every value that PostgreSQL refuses, with its table, column and row.

  3. Coding session

    db-copy --repair

    SQLite had accepted 9,423 values that PostgreSQL refuses: a NUL byte in a text, an emoji cut in half, a row whose parent row is gone. Since #3619, --repair fixes those kinds during the copy and lists each fix. It does not change the SQLite file.

    With it, the first full copy passed. It moved 23.2 million rows in 75 minutes, and every count and checksum was equal. The 87 GB file became 38 GB in PostgreSQL.

  4. that dayOur swarm

    The swarm ports its own SQL

    The copy moves rows. It does not move SQL that is stored as text. Our swarm held 92 scripts that query the database and 58 dashboard widgets. It also held schedule prompts with example queries, and extensions that read a task before they judge a message. All of it was SQLite SQL.

    We sent the lead a task with the dialect rules. It split the scripts into batches for its workers, and ported 78 of the 92 that day. One line of a worker's report named the risk that the replay removed a day later:

    Batch C: 18 ported (staged, not live), 2 not necessary, 6 skipped. [...] PG texts are syntax-parsed only, not run, so types are unproven.

    Agent SwarmTester Lead11:48

Wed 25 NovRehearsal, then go

  1. CI

    The merge gate gets faster

    The E2E suite ran on both engines for every merge, and that had made the gate slow. Its slowest job took 867 seconds. One message changed the design:

    in postgres could we start maybe a single instance and just do a seeded database (after migrations) and do a copy of the database? common pattern

    TarasTue evening, to the coding agent

    Since #3648 each test boot clones a migrated template database, and the suite runs in 6 shards. The slowest job takes 333 seconds.

  2. Coding session

    One request, one transaction

    One scenario of that suite took 30 to 39 seconds on PostgreSQL. The cause was a bulk write that made one commit for each row. #3655 put the request in one transaction and brought it to 1.1 seconds. Since #3664 a nightly budget fails when a request makes more commits than its limit.

  3. Coding session

    Rehearsal into the real target

    The second full copy went into the production database server, while the swarm ran on the same machine. It took 98 minutes, and we dropped the result. The work to prepare that server had already shown a limit that the isolated server did not have. The database container had 64 MB of shared memory.

    / 3 full copies

    The same copy, 3 times

    Each run copied the whole production database and compared a row count and a checksum for every table.

    Loading interactive chart
    The second run shared its server with the live swarm.
  4. Taras

    One rule for the session

    do not do any migrations without checking w me

    Taras14:25, to the coding agent
  5. Our swarm

    1,450 statements replayed

    We exported every statement that the swarm had ported and ran each one against the trial swarm. 1,439 passed. 10 of the 11 failures had one cause. The statement sent a JSON list as a text parameter into a jsonb cast. The swarm fixed all 11 that afternoon, and #3683 removed the cause in the engine.

  6. Taras

    Go

    Taras approved the plan for the night. Wait for the running tasks. Stop the swarm. Copy. Switch only if the copy exits with 0, every count and checksum is equal, and there are no warnings. On any other result, the swarm stays down until he starts it on SQLite.

  7. Coding session

    The swarm stops

    Swarm is stopped and the checks say ready. Starting the copy now (approved).

    Claude Code, Claude Fable 5.223:58

Thu 26 NovThe switch, and the first morning

/ 23:55 to 02:00, Barcelona time

StopCopy, 92 minVerify, dump, switchServingLock errors
  1. 23:55The swarm stops
  2. 23:58The copy starts
  3. 01:3124,051,347 rows, every count and checksum equal
  4. 01:44Production runs on PostgreSQL
  5. 01:465 statements fail with out of shared memory
  6. 01:57Lock table raised, database restarted in 4 seconds
Planned downtime was 2 hours. The real number was 1 hour 49 minutes, then 11 minutes of lock errors.
  1. Taras

    2 questions from a phone

    % progress?

    Taras00:48, from his phone

    About 58% done by time, at 00:49 BCN (50 minutes in). The copy runs ahead of the night test.

    Claude Code, Claude Fable 5.200:48

    ane now?

    Taras01:27

    About 93% done at 01:28 BCN (89 minutes in). The copy is in its last phases.

    Claude Code, Claude Fable 5.201:27

    i was watching breaking bad in the couch XD

    Tarasa day later, about that hour
  2. Coding session

    The copy passes

    Copy verification passed: exit 0, 140 tables, 24,051,347 rows, every count and checksum equal, 0 warnings. Taking the first dump now.

    Claude Code, Claude Fable 5.201:33
  3. Coding session

    Production runs on PostgreSQL

    The API is up on PostgreSQL since 01:44 BCN (Postgres engine ready, reader role ready, health 200). Running the after-switch checks.

    Claude Code, Claude Fable 5.201:44

    The first task for the lead on the new engine was a smoke test. This was its whole answer:

    dialect=postgres, n=25, memory-search results=10 (equals the default limit of 10)

    Agent SwarmLead01:49
  4. Coding session

    out of shared memory

    2 minutes later, 5 statements failed:

    ERROR:  out of shared memory
    HINT:  You might need to increase max_pred_locks_per_transaction.
    

    The API runs every transaction at SERIALIZABLE, and PostgreSQL records what each one read in a lock table of fixed size. One memory search ran for 43 seconds. The database kept the locks of every transaction that committed in that time, and the default table was too small.

  5. Taras

    go pred

    The swarm runs on PostgreSQL since 01:44 BCN, and the copy passed every condition you set. One decision is open for you: the predicate lock setting.

    Claude Code, Claude Fable 5.201:52

    go pred

    Taras01:57

    The change is live: PostgreSQL restarted in 4 seconds with max_pred_locks_per_transaction=2048, and the API came back by itself.

    Claude Code, Claude Fable 5.201:58

    The API found that its database lock was gone and exited. Its supervisor started it 6 seconds later. That path ran in production for the first time here.

  6. Taras

    Taras goes to sleep

    ok ill go to sleep so monitor during the night until i come back

    Taras02:02

    He did not. 8 minutes later he asked a second coding session for this post.

  7. Coding session

    A script that the port missed

    The PostgreSQL error log showed the same statements every 15 minutes:

    ERROR:  column m.chunkindex does not exist at character 81
    STATEMENT:  ... SELECT count(*) AS rows_total, sum((m.chunkIndex IS NULL OR m.chunkIndex = 0)) AS logical, ...
    

    A metrics script still sent SQLite SQL. Its workflow had failed on every run since the switch, and the page that it feeds showed old numbers with no error. We ported the script, and the 02:30 run passed.

  8. Coding session

    2 gates that fail open

    The same log showed 2 extensions with SQLite queries. Each one reads the task from the database before it judges a message. On an error it returns, and the message passes. Neither gate had judged a message since 01:44, and no alert said so. The lead got a task with the port rules. The worker that took it found more:

    6 scheduled global scripts break on PG. The port list missed them because workflows run them, so they leave no run rows.

    Agent SwarmJackknife02:55

    both gates on pg now, comms-adherence-gate v10 and taras-voice-gate v10, v9 kept for rollback. diff is just sql + version and all 6 queries return rows. voice gate judged this reply live and blocked it twice lol [...]

    Agent SwarmLead03:00
  9. Coding session

    The night report

    A watch ran all night and sampled the database every 5 seconds. This is its report at 06:15:

    • No more lock errors. The predicate lock table peaked at 28,077 targets, and the default holds about 5,000. The new setting was necessary.
    • The swarm worked. It completed 129 tasks and 2,457 script runs before 06:00.
    • The nightly release deployed at 04:00, and the API started on PostgreSQL with no problem. The first scheduled backup ran at 05:30 and wrote 16 GB in 18 minutes.
    • 2 statements were slow. Memory text search took up to 81 seconds. Task search took up to 57 seconds, and 20 to 25 seconds for a term with no match.

    Dani's swarm had flagged memory search as a risk on Saturday. Both searches passed every test, because the tests use small data.

  10. Taras

    Taras wakes up

    His first act of the day was to put a PR into the merge queue. 5 minutes later:

    ok added some to mq

    could you merge via mq the perf ones please? as there are migrations so order is important

    Taras09:32, to the coding agent
  11. Coding session

    The search fixes go live

    4 PRs came out of the night. They merged in the morning and deployed at 10:16.

    • #3689 adds the server settings to the runbook.
    • #3690 makes statements on hot paths cheaper.
    • #3692 stores a full-text document for each memory.
    • #3697 does the same for each task.

    / the first morning

    Search, before and after the fix

    PostgreSQL parsed the text of every row for each search. The fix stores a search document for each row.

    Loading interactive chart
    Seconds for one request on production. The value before the deploy is the worst that we measured.
  12. Our swarm

    The rest of the stored SQL

    The error log of the night named what the port had missed: 5 workflows, 4 pages and 1 script. One of the pages had an open browser tab that polled it, with 69 failed queries in 15 minutes. The lead got the list as one task.

What changed, in numbers

The median request got slower, because the database is now a network hop away. The tail got faster, and at 5 times our request rate the 99th percentile fell from 363 ms to 51 ms.

/ one load test, 8 agents

Request latency, by engine

Milliseconds for one request in one load test on a copy of production, at our request rate and at 5 times that rate. Lower is better.

Loading interactive chart
The fix is #3596. Before it, a token wrote its last use on every request, and those writes collided.

Search was worse on the first night and is now faster than it was on SQLite.

/ memory search

Search got worse, then better than before

Seconds for one request on production. Each bar is the slowest value we measured.

Loading interactive chart
The fix is #3692, a stored search document for each memory.

The data got smaller in the move.

/ on disk

The same rows, less than half the size

Size on disk before the copy, after it, and after the search fix added its documents.

Loading interactive chart
MeasureSQLitePostgreSQL, first measurePostgreSQL, after the fix
Database sizesearch documents added87 GB38 GB41 GB
Request latency, medianat our request rate4.7 ms17.4 ms14.7 ms
Request latency, 95th percentileat our request rate207 ms143 ms197 ms
Request latency, 99th percentileat our request rate356 ms282 ms279 ms
95th percentile at 5 times the ratefix: #3596175 ms53 ms32 ms
99th percentile at 5 times the ratefix: #3596363 ms249 ms51 ms
Write transactions rolled backfix: #3596, all retriednone4.1%0.35%
Memory list with a queryfix: #36921 to 3.5 s9 to 15 s0.7 s
Memory searchfix: #3692about 1 s3 to 4 s0.6 s
Task search, term with no matchfix: #3697not measured20 to 25 s0.1 s

Latency and rollback rows come from one load test on a copy of production, with 8 agents. The search rows are single requests on production.

What we would repeat, and what we would change

  1. Write the E2E suite before the engine. A swarm wrote the engine against that suite in a weekend, and the same suite let us merge it.
  2. Make the list of SQL that is stored as text on day 1: scripts, widgets, prompts, extensions. We made it on day 5 and still missed more than 10 items.
  3. Give the copy tool a repair mode from the start. A database with a long history holds rows that a strict engine refuses.
  4. Rehearse into the real target, not only into a clean server. The shared memory limit showed only there.
  5. Raise max_pred_locks_per_transaction before the switch if you run at SERIALIZABLE.
  6. Read the database error log in the first hour. None of our leftovers raised an alert.
  7. Test search on data of production size. Both slow searches passed every test on small data.
from the first prompt to productionthe target was before Christmas
6 days
PRs1 for the engine, 22 around it
23
of downtime2 hours planned
1 h 49 min
  • Dani's swarmWrote the PostgreSQL engine against the test suites1 PR ยท 417 commits ยท 118 tasks
  • Coding sessionsClaude Code in T3 Code: verification, the copy tool, CI, rehearsals, the switch, the search fixes22 PRs ยท 3 full copies
  • Our swarmPorted its own scripts, workflows and prompts78 scripts on day 1 ยท 11 fixes
  • CIThe E2E suite on both engines, and a nightly commit budget6 shards for each engine
  • Humans2 calls, the JSON type, the isolation level, the go for the switchDani, Taras

The 22 are the PRs merged from 24 to 26 November that touch the engine, the copy or their tests.

What it cost

tokens in total1,647M Dani's swarm, 1,459M sessions, 318M ours
3.42B
for the modelslist prices and recorded cost, not an invoice
1,640 USD
for 16 test serversthe list is below
29 EUR
  • Dani's swarm, the workerPicateclas on Claude Opus 5.5: the engine, the fixes after each review41 tasks ยท 1,502M ยท 512 USD
  • Dani's swarm, 6 more agentsThe lead, 2 researchers, a reviewer on gpt-6.1-sol, 2 more workers77 tasks ยท 146M ยท 110 USD
  • Sessions, Claude Fable 5.2Most sessions: verification, the copy, rehearsals, the switch2,546 turns ยท 1,015M ยท 721 USD
  • Sessions, Claude Opus 5.5Implementation in worktrees, in the background2,158 turns ยท 438M ยท 170 USD
  • Sessions, Claude Sonnet 5.5Small subagent tasks73 turns ยท 5M ยท 3 USD
  • Our swarm5 task trees: scripts, prompts, extensions, workflows and pages51 tasks ยท 318M ยท 123 USD

Session tokens come from the session logs, at API list prices from models.dev. Claude Fable 5.2 uses the Fable 5.1 rates. We ran the sessions on a Claude subscription. Each swarm row is the cost that the swarm recorded. No row is an invoice.

/ tokens for each hour

Token usage over the 6 days

One point for each hour, Barcelona time.

Loading interactive chart
Cache reads included. The tallest peak is our swarm on Tuesday morning, when it ported its scripts in parallel.

/ running total

Cost over the 6 days

Dani's swarm spent 622 USD until the merge. Our sessions had spent 90 USD by then. The rest paid for the verification and the move of production.

Loading interactive chart
Dani's swarm records its cost at the end of each session, so its line moves in steps.

We also started 16 servers on Hetzner Cloud. 11 of them ran before the merge, to check the PR on clean machines. 13 lived for less than 3 hours, and one for 2 minutes. All 16 together cost about 29 EUR.

#ServerSizeStartedLifeCost
01First check of the PR: SQLite suitecpx42: 8 vCPU, 16 GBSun 22, 21:1818 min0.11 EUR
02First check: PostgreSQL suitecpx42: 8 vCPU, 16 GBSun 22, 21:1818 min0.11 EUR
03First check: release buildcpx52: 12 vCPU, 24 GBSun 22, 21:1917 min0.16 EUR
04Second check: SQLite suitecpx42: 8 vCPU, 16 GBMon 23, 01:0222 min0.11 EUR
05Second check: PostgreSQL suitecpx42: 8 vCPU, 16 GBMon 23, 01:0222 min0.11 EUR
06Second check: release buildcpx52: 12 vCPU, 24 GBMon 23, 01:0310 min0.16 EUR
07Night workload on the release buildcpx52: 12 vCPU, 24 GBMon 23, 01:539 h 41 min1.61 EUR
08Third check: test suitescpx42: 8 vCPU, 16 GBMon 23, 01:5340 min0.11 EUR
09Fourth checknot recordedMon 23, 11:4433 minnot known
10Final check of the PRccx43: 16 dedicated vCPU, 64 GBMon 23, 12:4035 min0.44 EUR
11Boot test on a restore of productionccx43: 16 dedicated vCPU, 64 GBMon 23, 14:521 h 9 min0.88 EUR
12The trial swarm on PostgreSQLcpx42: 8 vCPU, 16 GBMon 23, 18:08days7.35 EUR
13Copy rehearsals on production dataccx53: 32 dedicated vCPU, 128 GBMon 23, 19:2020 h 16 min17.95 EUR
14Test of the memory search fixcpx41: 8 vCPU, 16 GBMon 23, 22:231 h 40 min0.10 EUR
15Test of the token write fixcpx41: 8 vCPU, 16 GBMon 23, 22:322 h 38 min0.16 EUR
16Build check of the simulation packnot recordedTue 24, 09:552 minnot known
16 servers29.36 EUR

Cost is the hourly list price for each started hour. The trial swarm still runs, so its cost counts to Thursday 12:00.

Move your own swarm

The guide has the inventory queries, the SQL translation table, the rehearsal, the window and the rollback.

In your swarm

Send this to your lead. It makes the list of SQL that the copy does not move, before you plan a date.

Plan our move from SQLite to PostgreSQL. Do not change anything yet.

1. Read https://docs.agent-swarm.dev/docs/migrations/sqlite-to-postgres.
2. Run the inventory queries of Step 1. List every script, dashboard widget, schedule prompt, workflow and extension that holds SQL.
3. For each item, say if it is seeded or ours. Do not edit a seeded item. For each of our items, write the PostgreSQL text.
4. Tell me which server settings of Step 3 our database does not have yet.
5. Reply with the list, the count for each kind, and what you could not check.

/ references

Sources and further reading

/ keep reading

/ Install

Two ways in.

01 ยท THE EASY WAY

Ask your coding agent

It reads the skill, asks about your setup, then installs the swarm.

Read https://agent-swarm.dev/skill.md and help me install and operate Agent Swarm on our infra. Ask about my setup before running anything.

02 ยท THE FAST WAY

Run the installer

One command. Needs Docker.

$ curl -fsSL https://agent-swarm.dev/install.sh | bash