Skip to content

feat: auto-continue failed idle runs#165

Open
i-am-thor[bot] wants to merge 1 commit into
mainfrom
feat/runner-idle-auto-resume
Open

feat: auto-continue failed idle runs#165
i-am-thor[bot] wants to merge 1 commit into
mainfrom
feat/runner-idle-auto-resume

Conversation

@i-am-thor
Copy link
Copy Markdown
Contributor

@i-am-thor i-am-thor Bot commented May 28, 2026

Summary

  • intercept the known zero-output state at before runner marks the trigger done
  • send once into the same OpenCode session and keep the current run alive
  • re-arm auto-resume after a later assistant on a new message id with nonzero tokens, with tests for one-shot suppression and zero-then-nonzero update ordering

Testing

  • pnpm test packages/runner/src/trigger.test.ts
  • pnpm --filter @thor/runner typecheck

AI-generated — verify before acting. View Thor context

Co-authored-by: Son Dao <son.dao@katalon.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an auto-recovery path in the runner's /trigger stream loop: when an assistant message.updated finishes with finish: "error" and zero tokens (no displayed output), and the session then idles, the runner sends a single "Continue" prompt into the same OpenCode session instead of terminating the trigger. The retry is one-shot per failed message id, and is re-armed only when a different assistant message id later updates with nonzero tokens.

Changes:

  • Track latest assistant message.updated (id/finish/tokenTotal) plus a set of message ids that produced real text output.
  • On parent session.idle, if the latest assistant message looks failed and unrecovered, send Continue once via client.session.promptAsync and keep the stream loop alive; on prompt error, fall through to the existing terminal path.
  • Extend test harness (messageUpdatedEvent accepts id/finish, promptEvents receives prompt text) and add three new tests covering one-shot continue, duplicate suppression, and re-arm-after-success.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/runner/src/index.ts Adds auto-resume bookkeeping, idle-time Continue send, and assistantMessageUpdateSummary() helper.
packages/runner/src/trigger.test.ts Extends messageUpdatedEvent/harness and adds tests for the new auto-continue behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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