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 withrecordTo 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)
improveWorkflow that record, the same workflow file, a seat that
proposes and a seat that reviews:
examples/improve-a-workflow.ts (excerpt)
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.
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, withresume, and it carries on from the answer:
examples/improve-a-workflow.ts (excerpt)
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 inexamples/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
Full file
Full file
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
- Ask a person: the approval step the question uses.
- Read a record: the record a proposal cites.
- Built-in Workflows:
improveWorkflowand its configuration.