Skip closed threads in onComment to stop ghost sessions - #43
Merged
Conversation
onComment dispatched a full agent session on every human comment, gated
only by repo-match. So maintainer housekeeping — closing an issue with a
note, commenting on a merged PR — spawned a session that then idled while
holding a Vercel sandbox (real provisioned-memory cost; the source of the
23 ghost sessions cleaned up recently).
Add a fail-open gate: one GET /issues/{n} lookup (the comment payload
carries neither state nor labels), suppress dispatch when the thread is
closed. Any lookup error allows dispatch, so a transient failure never
silently drops a real request. Open threads still dispatch, so the agent
keeps its freedom to act on any live comment. Export onComment for tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
onCommentdispatches a full agent session on every human comment (only gate: repo-match). So maintainer housekeeping — closing an issue with a note, commenting on a merged PR — spawns a session that then idles while holding a Vercel sandbox. This is the source of the ghost-session accumulation (23 cancelled recently) and a real chunk of the sandbox provisioned-memory bill.Fix
Add a fail-open gate: one
GET /repos/{o}/{r}/issues/{n}lookup (the comment webhook carries neither issue state nor labels), suppress dispatch when the thread isclosed. On any lookup error, allow dispatch — a transient failure must never silently drop a real request. Open threads still dispatch, so the agent keeps full freedom to act on any live comment.Scope
agent/channels/github.ts:conversationIsClosed()helper + gate inonComment; exportonCommentfor tests.tests/channels/github.test.ts: +4 cases (open→dispatch, closed→null + short-circuit, error→fail-open, wrong-repo→null).Test
npm run typecheckcleannpm test→ 61/61 passPart of the sandbox overhead-cost hardening (permissions untouched — agent capabilities unchanged).