8000 feat(sessions): continue runs interrupted by a restart in pi-durable by geminixiang · Pull Request #185 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

feat(sessions): continue runs interrupted by a restart in pi-durable - #185

Merged
geminixiang merged 1 commit into
mainfrom
feat/native-run-continuation
Oct 14, 2026
Merged

geminixiang merged 1 commit into
mainfrom
feat/native-run-continuation

Conversation

@geminixiang
@geminixiang geminixiang commented Oct 14, 2026 •
Copy link
Copy Markdown
Owner

Why

A deploy or crash during an agent run aborts it: the Slack progress message stays at its last step and nobody answers. Only tasks recovered, by aborting and starting a new run with a resume prompt, at most twice. Runs are getting longer (hours for the planned GitHub agent and long tasks), so this would drop work on most deploys. pi-durable already keeps interrupted work pending across a crash or close() and continues it with harness.resume(), as Pi's own hosts do; mikan turned that off.

What (ADR 0027)

  • MessagingInfo.continuesInterruptedRuns: Slack sets it, so shutdown neither waits for nor aborts Slack runs (deploys stop in about 1 s). Other platforms keep the 5-minute drain.
  • SessionStore.continueInterrupted(office): for an office written in the last 24 h, opens storage without aborting, keeps the interrupted runs of indexed sessions, aborts the rest, and calls harness.resume() only once every kept session is bound (continueInterruptedRun). Other submissions in that office wait (whenContinued); a session still unbound after 60 s is aborted instead of failing silently.
  • The Slack bot runs that scan before its socket connects, posts "Restarted for an update; continuing." and queues a continuedRunId(sessionKey) run, which MikanAgentSession.continueInterrupted() drives without submitting input or syncing chat history.
  • One line in the system prompt tells the model what an "interrupted" tool result means.
  • Removed: RESUMED_TASK_PROMPT, claimResume, interruptedSince, the resume cap and its message. ADR 0021 decisions 5–7 are marked superseded.
  • Opening an office no longer re-marks work whose abort is already requested (the repeated "Aborting 1 durable tasks" log line).

Evidence

pi-durable 1.2, real model, sleep 20; date +%s interrupted 2 s in, 5 trials each:

Stop Continuation Answered Tokens after reopen
kill / close native, nothing added 0/5, 0/5 475
kill / close native + one instruction line (this PR) 5/5, 5/5 1,063
kill / close abort + resume prompt (before) 5/5, 5/5 1,066

Local daemon on a test Slack workspace, sleep 90; date +%s, daemon stopped mid-command:

Case main This PR
Channel thread, SIGKILL Progress message stuck, no answer Notice, same turn continued, reran, answered
Channel thread, SIGTERM Waited for the run Exit in under 1 s, continued after restart, answered
Two threads in one channel — Both answered (mikan ran them one after the other)
Top-level DM, SIGKILL Aborted (POC baseline) Notice, continued, answered
Startup cost — 0.1–0.6 s for 11 channels

Known limits

  • A message queued behind a run but not yet started when the process stops is lost, as before.
  • Offices idle over 24 h and non-Slack platforms still abort interrupted work when next opened.
  • A run whose step crashes the daemon repeats after each restart, as in Pi; the process manager's backoff bounds it.

Verification

  • New tests fail without the change: continuation in the same turn, two interrupted sessions plus another session sending first, a prompt waiting for the office's continuations (fails without the guard), shutdown leaving a continuing platform's run, no history sync for a continued run, Slack task and DM continuation.
  • Gate: 2181 tests pass
  • CI
  • Slack E2E: 26 of 26 (session storage, run loop, Slack intake)

A Slack run or task cut off by a deploy or crash now continues its own
turn after the restart instead of being aborted. The Slack platform
declares continuesInterruptedRuns, so shutdown neither waits for nor
aborts its runs. Before the socket connects, the bot asks
SessionStore.continueInterrupted for each channel: an office written in
the last 24 hours opens without aborting, keeps the interrupted runs of
indexed sessions, aborts the rest, and calls harness.resume() only after
every kept session is bound; other submissions in the office wait, and
a session unbound after 60 s is aborted. The system prompt tells the
model what an interrupted tool result means. The task resume prompt and
its two-resume cap are removed (ADR 0027 supersedes ADR 0021 decisions
5-7).
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying mikan with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4689bec
Status: ✅  Deploy successful!
Preview URL: https://5798eaf1.mikan-1wv.pages.dev
Branch Preview URL: https://feat-native-run-continuation.mikan-1wv.pages.dev

View logs

@geminixiang
geminixiang merged commit dd0efb2 into main Oct 14, 2026
7 checks passed
@geminixiang
geminixiang deleted the feat/native-run-continuation branch October 14, 2026 07:56
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.

1 participant

0