multi-step-workflow

A deterministic N-step research pipeline on pugmark. No tools, no model-driven branching, just task โ†’ plan โ†’ step 1 โ†’ step 2 โ†’ step 3 โ†’ answer โ†’ pause. Each call is one event on the append-only log, so the whole pipeline is crash-resumable from any step and forkable at any step.

It answers the question that comes up after the react-tool-agent hero: “what does pugmark look like when you don’t have a tool-using react loop, just a multi-step workflow?” Full source on GitHub.

Prerequisites

brew install firetiger-oss/tap/pugmark
pip install pugmark anthropic
export ANTHROPIC_API_KEY=sk-ant-...

Run

pugmark switch file:///tmp/pug-workflow    # point pugmark at this example's bucket
pugmark run --start -- python workflow.py
pugmark log -A   # โ†’ task, plan, step(1), step(2), step(3), answer, then pause

The handler seeds a demo task on the first invocation when the log is empty, then runs the full pipeline to completion.

Fork to try a different plan

Fork at the plan snapshot and push a different plan event to steer the workflow without redoing the prior research:

pugmark fork -s <session>:2
pugmark push <<<'{"kind":"plan","steps":["focus on async support","focus on type safety","focus on community size"]}'
pugmark run -- python workflow.py
pugmark log -A   # branching tree

The downstream step(1) / step(2) / step(3) / answer for the forked session use the new plan. The parent’s history is untouched.

What it shows

PatternWhere in the code
Walk the log via pugmark.read() and decode each entry as JSONfor obj in pugmark.read(): last_event = obj.decode_json()
fold(state, event) to update a small in-process state one event at a timeaccumulates task, plan, completed steps
Structural pattern matching with guards (if idx < NUM_STEPS)match last_event: in main()
One write per invocation, then return (pugmark’s run loop calls back)every terminal in the dispatch

The same shape as the react agent, but with a four-event protocol instead of a four-event conversation. No tools, no model SDK features beyond plain messages.create, just the substrate.