Skip to content

Threads: mark events processed on delivery, let the thread complete - #50

Merged
mcwhittemore merged 2 commits into
mainfrom
issue-49-deliver-no-done
Oct 8, 2026
Merged

mcwhittemore merged 2 commits into
mainfrom
issue-49-deliver-no-done

Conversation

@mcwhittemore

Copy link
Copy Markdown
Collaborator

Part of #48. Sessions no longer mark events done. The dispatcher marks them processed when it hands them over, and end is the only signal that a thread is finished.

What changed

  • Delivery marks processed (packages/cli/src/threads/dispatcher.ts). lockAll is now claimAll: it locks each event so no other consumer takes it too, then marks it processed with that lock token straight away. If another consumer locked it first, it's skipped, as before.
  • No lock renewal. renewLocks is gone, along with the remembered lock tokens it relied on. A running session's new events still stay pending until its run exits, then go in together.
  • Prompt (packages/cli/prompts/thread.md). Every "mark it done" instruction is removed. A delivery lists event ids and types, and the session reads payloads with loopway events get <inbox> <event> --data. link and end haven't changed. The delivery header is now New events for this thread: (it no longer says "already locked for you").
  • threads.json. Session.events now lists every event delivered to the session, not the ones it still holds.
  • README. The Threads section is updated to match. --ttl help text now describes the short claim lock.

Defaults picked

  • I kept --ttl. It now only sets how long the claim lock lasts, and that lock is released a moment later when the event is marked processed. The flag could be removed in a follow-up, but I left the CLI surface alone for this experiment.
  • Lock, then process (two calls). processed without a token returns 200 for an event someone else already processed, so calling it alone could deliver the same event twice. Locking first keeps the claim exclusive.
  • Deliveries still list ids rather than inlining payloads, as the issue says.

Tests

  • The "keeps a session's events locked" test is replaced by one that checks delivered events end up processed (none left locked) and stay on Session.events.
  • The other threads tests no longer call events done.
  • npm run typecheck and npm test pass (web 34, cli 28).

Deploy steps

None. Events left locked by a dispatcher running the old code will become pending again when their locks expire, and the next tick will deliver them.

Closes #49

🤖 Generated with Claude Code

…m done

The dispatcher now locks each event and marks it processed as it hands it to a
session, and no longer renews locks. Delivered events are context for the
thread; the session's `end` tool is what finishes it. The thread prompt drops
the "mark it done" steps, and Session.events records what was delivered.

Closes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loopway Ready Ready Preview Oct 8, 2026 2:53pm UTC

Request Review

@mcwhittemore

Copy link
Copy Markdown
Collaborator Author

resolve conflicts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcwhittemore

Copy link
Copy Markdown
Collaborator Author

Merged main and resolved the conflicts in dispatcher.ts and program.ts. Both were Prettier reformatting overlapping with this PR's changes. I kept this PR's logic and re-ran Prettier. Format check, lint, typecheck and tests all pass.

@mcwhittemore
mcwhittemore merged commit 521416d into main Oct 8, 2026
3 checks passed
@mcwhittemore
mcwhittemore deleted the issue-49-deliver-no-done branch October 8, 2026 14:54

This branch was previously deployed

1 inactive deployment
Preview — 8123d1b4 Deployed Oct 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Threads: deliver messages, let the thread complete (no per-message done)

1 participant