preloader
Onboarding a limited number of private deployments this quarter. Request access →
What we learned building our internal Calliope AI Software Factory

What we learned building our internal Calliope AI Software Factory

author image

We run an internal Calliope AI Software Factory: a system where AI agents take real software tasks, such as a bug report or a small feature, and try to deliver working code. We use it to test our own tools on our own work before we ask anyone else to trust them.

The hardest work so far has been keeping a task intact through interruptions. A container restarts, a network connection drops, or a person steps in with a new instruction. After any of those, you still need to know what the work was for, what it was allowed to do, how much it was allowed to spend, and how you will know it succeeded.

The component checks described below passed, but reliable unattended recovery remains unproven. The status section below separates those results.

Background: what an agent, a CLI, and a factory are

If you have not worked with coding agents, a few terms will carry the rest of this post.

An agent is a program that uses an AI model to work toward a goal. Instead of answering one question, it loops: the model decides on a step, the program carries it out (read a file, run a test, edit code), and the result goes back to the model for the next decision. That loop is the “model and tool loop” we mention later.

A CLI (command-line interface) lets you run software through commands in a terminal. A coding-agent CLI puts the model and tool loop behind that interface. Ours is the Calliope CLI. A person can run it by hand, or a larger system can run it on their behalf.

A software factory is that larger system. A person describes a goal, the factory assigns it to an agent, checks the result, and hands back finished work or an explanation of why it could not. A person is still involved, usually to approve, answer questions, or redirect. The factory’s job is to make that involvement small and well timed.

Factory work can last hours, run on machines that get replaced, cost real money, and change real code. The system has to preserve the work while its processes and connections change.

Where we started

Our first question was a plain comparison. Our command-line agent, the Calliope CLI, is one of several coding CLIs that can take a task and work on it. If two of them use comparable models, which one finishes more tasks correctly, and at what cost?

To answer that we needed real tasks and real interruptions, not toy examples. Real runs get cut off. An agent can be mid-task when its container is replaced, and a person may want to answer a question or change direction halfway through. Those events turned out to matter more than the comparison itself, so most of our engineering went there.

One agent, one task, start to finish

Our first workflows split software work into stages: plan, build, review, verify, deliver. Staging is useful. It gives you checkpoints, and it lets independent tasks run on a schedule.

It also has a cost. Each time work moves from one stage to the next, a new agent invocation has to rebuild the goal from a short summary. For example, suppose someone asks for “export reports as CSV, including archived projects.” By the time the review stage reads a summary of the build stage, “including archived projects” may have dropped out. Each stage can follow its immediate instructions while the overall feature misses the requirement.

So we are trying a second mode, a longer-lived /goal. The design lets one agent carry a complex task from building through verification. It has written acceptance criteria (the checks the finished work must pass) and a limited number of tries to fix its own mistakes. Questions, steering, pauses, and feedback from the verifier all stay attached to that one task.

We have not shown that this beats staged workflows. It is a hypothesis we are testing. Both modes stay available, and users can build their own flows.

A walkthrough: one task, one interruption

This hypothetical run shows the interruption and recovery behavior we are working toward. It is not a completed factory run or a benchmark result.

  1. A person asks for “add an export button to the reports page.” They set a budget and say the work is done when the existing tests pass and the new button appears in the page’s test.
  2. The factory starts a worker, a container holding a checkout of the code. The agent reads files, edits code, and runs tests. For metered model requests, the system reserves budget before each call and records known usage afterward.
  3. Midway through, the agent asks, “Should the export include archived reports?” The person is away. The run waits.
  4. While it waits, the infrastructure replaces the container. This is normal. Machines get rebalanced and updated.
  5. A new container starts. Now the system has to answer several questions at once. Which task is this? How much of the budget is gone? Was the question already asked? Is the old container really gone? Did any command run that we never saw finish?

If the system answers those wrongly, the failures are specific. Repeated budget resets let the run exceed what was approved. The question is asked twice, or the answer is lost. Two containers both edit the same files. A write made just before the old container died is repeated.

Each section below describes one of these questions and the contracts we are building to answer it.

Three things have to survive a restart together

When a run recovers after an interruption, three kinds of state have to come back as a set.

  • Task state includes the goal, acceptance criteria, conversation, attempts used, and questions waiting for an answer.
  • Execution authority identifies the account, model, tools, workspace permissions, and worker allowed to act.
  • Accounting retains the original budget, reservations, known usage, and unresolved amounts.

Getting only some of these back causes real damage:

  • Restore the conversation but start a fresh budget, and the run can overspend.
  • Keep the budget but lose the tool identities, and the agent can repeat a write it already made.
  • Restore everything while the old worker is still alive, and two workers are acting on one task.

This is the responsibility split we are building. Some names are internal, so each row says what the part does.

ComponentWhat it does
Internal factory and StudioAccept the goal, keep its acceptance criteria, coordinate workflow state, and show results.
TypeSafeSuggests a classification (what kind of task is this?) and a route (which account and model?) from options we configured.
Deterministic contractsOrdinary rules in code that decide what is allowed: who is eligible, what permissions apply, what the limits are.
Calliope CLIRuns the loop where the model thinks and calls tools. Tracks what it uses.
Astrolift NativeDecides where tasks run. Owns workspaces and worker identity, makes sure only one worker owns a task, and cleans up.
Original ledger hostA separate service that keeps the accounting records, so they do not disappear when a worker does.
VerifierChecks the work against the acceptance criteria and returns evidence or feedback.

A “reservation,” in the sense we use here, is a hold placed on part of the budget before a request is made, so that several requests running at once cannot together exceed the limit. When usage is reported, the hold is settled using that usage and the admitted rates. That amount is a usage-based estimate, not an invoice. If usage or the outcome is unknown, the hold stays in place.

A budget belongs to the run, not the process

Say a run has a ten dollar budget. If its container restarts, the run must still have that same ten dollars, minus what was spent, with any uncertain amounts still marked uncertain.

Accounting tied to a local home directory or checkout path creates this failure mode: a replacement process finds no records and appears to have spent nothing. A new checkout can also look like a different budget. Our tests exposed how separate checkouts could bypass the original project allowance.

The ledger host we built keeps the accounting outside the disposable worker. Its task endpoints provide scoped access to the same run and account. We are still connecting it to the factory execution paths. A new checkout changes where the work happens. It does not create a new budget.

We also separated two operations that are easy to blur together:

  • Initialize starts a new, authorized run with a new budget.
  • Look up retrieves an existing run and its history.

If a lookup finds missing or inconsistent data, it reports that. It must never fall back to initializing a fresh run, because that is exactly how a lost record turns into free spending. Limits work the same way. Deadlines, attempts used, and remaining capacity are carried through recovery. Starting a new process does not refill them.

The budget is like a bank account, and the worker is like a debit card that can be lost. Replacing a lost card must not open a new account with a new balance. The account lives at the bank. The card is only a way to reach it. Our original ledger host plays the bank’s role.

“I don’t know” is a valid answer

Distributed work has more outcomes than success and failure. A request can be refused before it starts. It can be accepted while the confirmation is lost on the way back. It can finish while the local receipt is lost. Or it can still be unresolved. Treating all of those as “failed” or all as “succeeded” is how systems get into trouble.

One bug made this concrete. A parent reservation committed successfully, and then a later step threw an error. Our error handling read that error as “the whole operation was refused” and released a project hold. But the parent charge was still pending, so the hold was released while money was still committed behind it.

The fix was to require positive proof that a request was never admitted. Having no local record is not proof, and neither is the fact that this particular call did not see a confirmation. The proof has to be scoped to that specific operation.

Two related problems showed up in the same area:

  • A matching request ID is not enough. To decide a confirmation belongs to a request, we compare the full recorded reservation or settlement. If the body changed but the ID stayed the same, that is a conflict, not a replay.
  • A thrown value may be a string, object, null, or undefined, rather than a JavaScript Error. Our uncertainty marker only recognized proper Error objects, so an opaque failure could be read as a confirmed refusal.

This applies well beyond model calls. Unknown usage is not the same as zero usage. A rate card estimate is not an invoice. A tool call with an unknown result is not a command that never ran. Whether it is safe to try again depends on keeping these apart.

Here is a small example of the difference. A run asks the ledger to reserve two dollars for a model request. The ledger records the reservation, and then the network drops before the reply gets back. From the run’s point of view, nothing happened. From the ledger’s point of view, two dollars are held. If the run retries and the ledger treats the retry as a new request, the budget is reduced twice. If the run gives up and assumes nothing was held, the ledger carries a hold nobody will ever release. The safe behavior is to ask the ledger what it has recorded for that exact request and act on its answer.

Recovering a task means proving the old worker is gone

A saved conversation is useful evidence, but it is not enough to resume work. Resuming needs a compatible position in the run, the original identities, the remaining limits, any side effects still pending, and permission for the replacement to continue.

You also need proof about the old worker. A process name, a stale heartbeat, an expired token, or a dropped connection does not show that a worker stopped. A worker can look dead from the outside and still be running and writing. The design ties ownership to the actual runtime resources. Fencing removes the old worker’s authority to act; confirming that its process has stopped is a separate check before replacement.

Workspaces matter too. If useful source code or state lives in a workspace that is about to be thrown away, cleanup has to follow a retention step. Delete it first, and you can destroy the material you needed to work out what the run had done.

We also learned to record history at creation time. During a retry, a workflow stage can swap its current run pointer. Looking at that pointer later may not tell you which run launched an older task. Our Native source change records the task, workflow, stage, attempt, environment, and project identities before external dispatch. Older tasks without that record stay unavailable under this contract, and a redelivered activity cannot invent an “original” record from current settings.

This is the recovery sequence we are working toward:

  1. Stop the old owner from taking further actions.
  2. Keep the acknowledged state and any workspace evidence.
  3. Prove the old worker has stopped.
  4. Admit exactly one replacement against the original task, session, ledger, and remaining limits.
  5. Reconcile recorded outcomes before continuing.

For commands whose outcome is unknown, recovery needs inspection or a hold. Re-running a data-changing command can apply the same change twice. An operation with a confirmed idempotency guarantee may be retried using that same identity.

Here is why “it looks dead” is not good enough. Suppose a container loses its network connection for two minutes. The system sees no heartbeat and concludes the worker is gone, so it starts a replacement. The connection comes back. The first worker was only cut off from the system, not stopped, and it was still working locally. Now two workers hold the same task. A safe handover requires invalidating the old worker’s authority and separately proving its process has stopped before admitting a replacement.

Questions, steering, and verification live inside the task

A person should be able to answer a question or redirect a goal without rewriting the assignment. That needs a durable control protocol underneath the chat window.

Some states look alike in a chat interface and are not:

  • A pause that was requested versus a pause that was acknowledged by the agent.
  • An answer the server received versus an answer committed to the agent’s conversation.

A spinner should not hide the difference. If it does, a person can believe the agent has stopped while it is still acting.

Parallel tools add a wrinkle. Suppose one hosted tool becomes uncertain while another tool is waiting for permission. The waiting tool must not go ahead afterward. A different, unrelated error in a callback must not hide the uncertainty and allow another model request. We added a shared fence so the original turn stops while work already underway can finish and report what it actually did.

Verification sits in the same loop. When the model says it is done, that is a proposal. The verifier checks the written criteria and returns evidence or bounded feedback. If the verifier rejects the work, the agent goes back to the same task with the same budget and the same criteria. It does not get extra money or easier rules for trying again.

Steering can also invalidate a completion proposal. If someone redirects the agent after it said “done,” an earlier verification no longer applies. So each piece of evidence names the checkpoint it checked, and an old result cannot vouch for a later state.

This makes the operator interface part of the protocol. It needs to show plainly what is running, what is waiting, what was acknowledged, what is held, and what was actually verified.

For example, a person might type “skip the archived reports” while the agent is partway through a long step. The system has to record that message, make sure the agent receives it at a safe point, confirm the agent absorbed it, and then show the person that it did. If the agent had already told the verifier “I’m done” a moment earlier, that verdict now describes work that no longer matches the instructions, so it has to be thrown out and checked again.

Suggestions are not permissions

A classifier can suggest an execution mode, such as the single-agent /goal mode or the staged workflow. A router can suggest an account and model. TypeSafe gives us a bounded way to ask for those suggestions: it picks from options we configured and cannot invent new ones.

The deterministic layer makes the final decision. It checks account eligibility, project access, route compatibility, whether a qualification has expired, concurrency, quota, and spending limits. A suggested route cannot grant access that the configured pool does not already have. A classifier can still make a poor choice among eligible routes. It cannot expand the permissions or limits enforced by those rules.

We also want workers shared across projects, which means keeping three identities separate:

  • the project that owns a worker,
  • the project whose workflow asked for the work, and
  • the project that pays for it.

Within one organization these can all be different.

Credentials stay behind secret references and supported authentication methods. Account labels and approved routing metadata can travel with a run. Raw credentials never go into prompts, exported workflows, or public result summaries. We are designing the product primitives for dedicated and shared workers. Our own operator identities remain configuration for our organization.

Comparing results fairly

We started with a comparison, so it has to be fair. Model, CLI, and workflow structure are separate variables. If a result changes all three at once, you cannot tell which one caused it.

A matched comparison needs:

  • the same task and acceptance criteria,
  • frozen starting material, so every run begins from the same code,
  • equivalent allowed capabilities,
  • a controlled model and account setup,
  • declared limits, and
  • the same independent verifier, run through the real paths users will use.

The denominator has to stay honest. A failed run counts as an attempt. A canceled run gets its own category. A result that needed an operator to step in is not the same as one that finished unattended. Dropping the failures is the easiest way to make any tool look good.

The evaluation measurements we need are:

  • verified completion,
  • unattended first-pass completion,
  • operator interventions,
  • quality against the acceptance criteria,
  • recovery behavior,
  • known and unknown usage, and
  • cost per verified result.

Timing should separate routing, model requests, tools, verification, queueing, control waits, and recovery. Missing measurements need to remain unknown until we capture them.

Infrastructure failures get their own diagnosis. Clock drift, expired credentials, storage errors, and broken transport can look like a weak model if every failure lands in one bucket.

Our priorities, in order: make it work, make it consistent, improve quality, make it resilient, make it cost effective, then make it fast. TURBO is an optional policy for speed, and it keeps the same permission and acceptance gates.

To see why the denominator matters, consider two tools that each get 20 tasks. Tool A finishes 12 on its own, and the person reruns 8 of the failures by hand until they pass, then counts all 20 as successes. Tool B finishes 14 on its own and leaves 6 failed. Counting only final passes, A looks better, 20 to 14. Counting unattended first-pass completions, B is ahead, 14 to 12. In this example, A used at least 28 attempts for its 20 eventual successes; B used 20 attempts. We need both the first-pass and eventual results, with retries and interventions included.

Tests that start from a counterexample

The most useful regression tests begin with a concrete failure. We restore the old behavior, reproduce the bug, apply the fix, and show that the same assertion now passes. Seeing the regression test fail on the old behavior shows that it catches the bug we intended to fix.

For accounting and ownership, checking that a request succeeded is not enough. We inspect the state left behind:

  • Is a reservation still charged?
  • Does a confirmation match the full operation?
  • Does historical identity survive a retry?
  • Did a denied action leave authority unchanged?

Real PostgreSQL transactions and Temporal (the workflow engine that runs these tasks) matter for these checks. A mocked database can follow our assumptions while missing the database’s actual locking or commit behavior. We also test lost responses, malformed metadata, and canceled workers.

Test infrastructure gets the same honesty. A fixture that cannot start its test server proves nothing about the product, either way. We keep the failure, fix the environment, and rerun the intended check without skipping assertions.

A large passing suite is evidence for the contracts it covers. Reliable autonomous delivery still needs a real task to finish through the actual internal factory path.

Reusable workflow pieces

Software delivery is our proving ground, but content, media, and other organizational work need the same things: a goal, declared inputs, scoped tools, artifacts, acceptance criteria, control, and accountable execution.

That is why we want the workflow gallery and editor to be primary product surfaces. Users should be able to build and save flows, reuse existing Astrolift tools and skills, and eventually move workflow definitions between factories. A portable definition should keep its contracts while credentials and organization-specific grants are rebound locally.

Shared interface components belong in the shared UI source and Storybook catalog. Each factory module should show the same control and evidence states while supplying its own tools and verification rules.

The default flow should give good results without asking anyone to design a chain first. Configuration lets experienced operators improve on it, but it does not excuse a weak default.

Where the work stands

Done:

  • In local qualification, the CLI ledger and hosted-task candidate passed 7,878 local tests with eight skips, plus type checking and the build.
  • The Native original-membership change passed 104 tests against real PostgreSQL and Temporal.
  • The changes are in the CLI hosted ledger PR and the Native workflow membership PR .
  • We got a real task result verified by Native, though delivery still needed an operator to reconcile it. That shows part of the path.

Not done:

  • We have not finished the matched CLI evaluation.
  • We have not shown reliable unattended recovery.
  • Restoring the same CLI turn and replacing a qualified worker are both unfinished.
  • We are still connecting the separate ledger host to the internal factory’s execution paths.

The next proof has to carry a meaningful task through an interruption and recovery, keep its original authority and budget, produce verifier evidence, and go into the same evaluation record as every other attempt.

What we would do earlier next time

We would define acceptance criteria, accounting rules, execution identities, and failure states before growing the workflow catalog. We would pick a real task early, instrument its whole path, and keep the failed attempts as evidence.

We would also design recovery alongside execution. Every effect needs an identity, every transition needs a defined acknowledgment, and every budget needs an owner and a durable history. The interface should show those states plainly enough that an operator can tell why work continues or holds.

The next milestone is an end-to-end result that still holds up after the worker is gone.

Glossary

Acceptance criteria. The written checks that finished work must pass. They are set before the work starts, so the agent cannot adjust the target after the fact.

Agent. A program that uses an AI model to pursue a goal by repeatedly choosing a step, running it, and looking at the result.

Allowance (budget). The amount a run is permitted to spend. It belongs to the run, not to any single process.

Astrolift Native. Our component that decides where tasks run and owns worker identity, workspaces, and cleanup.

CLI. A command-line interface for running software through terminal commands. Calliope CLI is our coding agent’s command-line interface.

Deterministic contract. A rule enforced in ordinary code, with no AI model involved. It gives the same answer for the same inputs.

Fencing. Removing an old worker’s authority to act. Replacement also requires proof that the old process has stopped.

Ledger. The record of what a run reserved and spent. Our ledger host keeps this outside disposable workers; factory integration is still underway.

Reservation. A hold on part of the budget before a request. Reported usage settles it at the admitted rates; unknown usage remains held.

Temporal. The workflow engine that runs and tracks these tasks over time.

TypeSafe. Our interface for asking a model to choose among a fixed set of configured options, such as a route or classification.

Verifier. The independent check that tests finished work against the acceptance criteria and returns evidence or feedback.

Worker. The process or container where an agent does its work. State needed after replacement must be kept in durable storage.

Related Articles