Skip to main content
After a run, improveWorkflow from @obversa/builtin-workflows reads the run’s record and proposes one change to the workflow file that ran. A seat from another model family checks the change. Then a person says yes or no, and nothing changes without a yes. Each run proposes one change, so the next run’s record shows what that change did.

Shape

What it reads

Run the workflow with recordTo and source. The record keeps every event of the run, and its run:start event keeps the path and SHA-256 of the workflow file:
examples/improve-a-workflow.ts (excerpt)
Give improveWorkflow that record, the same workflow file, a seat that proposes and a seat that reviews:
examples/improve-a-workflow.ts (excerpt)
The first step checks the file before any model runs. When the file’s SHA-256 differs from the one in the record, the run fails, and the message names both hashes. A record with no source, or a record that names another file, fails the same way. The two seats must report different model families, or improveWorkflow throws before the run starts. The proposing seat reads the workflow file and the whole record, with each event after its line number. The record holds what a change needs as evidence:
  • Each attempt of a step, with its tokens, its cost and how long it took.
  • Each check, with its command and its exit code.
  • Each round, with the files and lines it changed and the findings it answered.
  • Each judge decision, with its reason, and the goal check’s verdicts.

What it may change

The proposal is one unified diff to the workflow file, with a short reason that cites lines of the record: which events, which rounds, what they cost. The proposing seat looks for these:
  • A step that fails its first round on the same kind of finding. The change is to its prompt or its brief.
  • A reviewer whose findings the judge always skips. The change is to its instructions.
  • A cap or an effort that costs more than it returns.
  • A check that runs late and sends work back after an expensive step. The change runs it earlier.
The run checks the proposal before the review. The diff must change the workflow file and no other, and it must apply to the file as it is. Each cited line must exist in the record. A proposal that fails these checks fails the run.

What it may not change

The change must not remove or weaken a review, a check, a goal check, a judge, an approval or a guard. The reviewing seat reads the diff, the reason, each cited line of the record and the whole record. It checks the change against that rule and checks that the record supports the reason. When it sends the proposal back, the run fails and nobody is asked.

How approval works

The run asks one question through its callbacks client: “Apply this change to” the file. The question carries the diff, the reason and the evidence, each cited line with the event it points at. Until a person answers, the run pauses. Run it again with the same client and the same record, with resume, and it carries on from the answer:
examples/improve-a-workflow.ts (excerpt)
On a yes, the run checks that the file still has the SHA-256 in the record, applies the diff and writes the file. On a no, the run does not write the file. Either way, the last step’s outcome keeps the decision, the record path, the diff, the reason, and the file’s SHA-256 before and after. The hash after a no is the one the file has when the answer comes. A no also keeps the person’s note. The run ends pass in both cases. When the file changed while the question waited, a yes applies nothing and the run fails. The question is an ordinary approval. With onCallback: 'wait', the run waits for the answer instead of pausing, and a person can answer on the run’s page. The answer can also come from a surface or a host, and the stored client keeps the question across a restart.

What the run did

The release notes workflow in examples/improve-a-workflow/release-notes.ts runs first. Its check sends the first draft back, because the writer’s brief never asks for upgrade steps. Both seats and the person answer from the example file, so it runs offline. Run it with npx tsx improve-a-workflow.ts:
Output
The proposal cites line 12 of the record, the event where the check sent the draft back. The run paused at the question and passed after the yes. After the yes, the brief in the workflow file asks for the upgrade steps, so the next run’s record can show whether the check still sends the draft back.
examples/improve-a-workflow.ts

Automatic mode

An automatic mode is not built. In that mode, evals would score each change, and a change that scores better would apply without a person. Every change needs a person’s yes.

Next steps