Software Factory

Stuck runs and why a run failed

How the Software Factory warns when a role gets stuck, what counts as stuck, and how to read why a run went wrong.

Updated 2026-10-31

The platform watches every @plan, @build and @check turn while it runs. It doesn't ask the agent how it's doing: it looks at the tools it uses and applies fixed rules.

What counts as stuck

RuleWhen
long_commanda command has been running for 8 min or more (25 min when it drives the work box through the SDK: full test suite, prepare)
repeatthe same command 4 times with the same result
repeat_errorthe same command fails 3 times
ping_ponggoing back and forth between two actions (6 in a row)
apt_installinstalling system packages by hand inside a box

Legitimate waits don't count: sleep, gh run watch, an until … sleep or waiting for CI.

What happens when it gets stuck

  1. The run's thread gets a ⏳ saying which role and which command.
  2. The role is told what to check. It gets it as soon as the command returns, which is when it decides whether to wait for it again.
  3. From the second stuck pattern in the same run, whoever asked gets a push.

The same pattern isn't reported twice within 30 minutes. The platform never kills a command or stops the turn on its own.

Waiting costs nothing

If @check is only waiting for its preview (no free box, or it is still building), the run pauses: the card says "Waiting for preview" and no turns are spent. As soon as the preview is ready, @check reviews once on its own.

Dependabot: CI decides the small ones

  • Patch and minor skip @check: they merge on their own as soon as CI is green (with the room's automerge on). If CI goes red, you get a note in the thread. If the repo runs no CI within 30 minutes, @check reviews it as before.
  • Major is reviewed by @check against how the repo actually uses it. If it only bumps development dependencies (types, linters, tests) or GitHub Actions, no preview is required: CI is the proof. If it touches what runs in production, the preview is still required.

Spend cap per run

Every run has a dollar cap (all roles together): $15 for runs and sprints and $5 for Dependabot, unless someone changed them. When it is reached the run stops: the role's next step is saved, the card says "Hit its spend cap" and the requester gets a notice. From there:

  • Raise cap: the next step (+$5 up to $20, then double) or any amount you choose. The run resumes where it stopped.
  • Cancel run: nothing more is spent. The PR is not closed automatically.

In the app, the run detail shows spend against the cap ("$3.20 of $5"), and the Factory "…" menu changes the space cap for runs and sprints (owner only; Dependabot never goes above it). Via API: GET|POST /api/v2/workspaces/{slug}/factory/budget and …/runs/{id}/act with {"action": "budget", "usd": 10}.

Why it failed

When a run closes, escalates or is cancelled without being healthy (stuck patterns, @build over 30 min, @check→@build loops, red CI), the thread gets a 🩺 with three lines: what happened, the critical step and what to change next time. A healthy run gets nothing. Time with the plan to approve, escalated, or with the PR to merge is a person's turn: it's reported apart ("waiting for a person") and never counts as slowness. If @check escalated because test variables or credentials are missing, the category is environment and the action says what to save in Credentials.

The full analysis, from the terminal:

bash
ghosty factory runs why 13 --workspace mercadito-verde# #13 missing_service · impact high · deepseek-v4-flash# @build spent 69 of 72 working minutes and installed PostgreSQL with apt…# Critical step#   17:53 @build  node t5.mjs "apt-get install -y postgresql"# Next time#   role_rules In ## @build and ## @check of .ghosty/factory.md: run seed-db <db> before the tests…

Categories are fixed: approved_unmet_criterion (a criterion of the approved plan, like "in the preview", wasn't met and was approved or merged anyway; it comes before any stuck pattern and also makes a merged run unhealthy), environment, missing_service, dependencies, unresolved_build_or_tests, fixed_strategy, missing_verification, premature_stop, ambiguous_spec, ci. Actions say where the change goes: role_rules (a rule in ), repo_setup (something in the repo), skill or prompt.

In the thread, Arqui reads the same analysis with «@arqui what happened with #13?» and proposes the guardrails as «Ask» cards. With approved_unmet_criterion it does this on its own when the run closes, once. If the deploy fails after the merge, the analysis is redone.

To see times and stuck patterns step by step: ghosty factory runs show 13 --timing. See .