Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

feat(workflows): journal runs and support resume

2 months ago

a7b3e51
Authored
mweinbach7/26/2026, 4:19:45 PM
Each run appends one entry per agent() call under
`<projectCoworkDir>/workflows/runs/<runId>/journal.jsonl`. Passing
`resumeFromRunId` replays every call the prior run already made, so fixing a
late stage does not re-pay for the early ones.

The digest is content-addressed — prompt, options and an args hash — and
deliberately excludes two things:

- the script source hash, because including it would make any edit invalidate
  the whole journal, defeating the purpose;
- the call index, because `pipeline()` has no barrier between stages, so the
  order calls reach the host shifts with agent timings. An index-keyed cache
  would match nothing on a rerun whose timings differed, which is precisely the
  control flow workflows exist for.

Content-addressing is also the stricter rule: a later call that genuinely
depended on an earlier one carries that output in its prompt, so editing the
earlier call changes the later digest and it correctly re-runs. Results are held
in a multiset so a script issuing the same call twice consumes two entries
rather than replaying one of them twice.

Entries are buffered and flushed once: journal writes go through the same gate
that throws during cancellation teardown, and a cancelled run should not fail
inside its own cleanup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk98XjGKJrKp5ynbiNFMFu

Parent4905423

1 file changed
  • src/workflows/journal.ts+180−0