Skip to content

Skip closed threads in onComment to stop ghost sessions - #43

Merged
paulieb89 merged 1 commit into
mainfrom
perf/oncomment-skip-closed-threads
Jul 16, 2026
Merged

Skip closed threads in onComment to stop ghost sessions#43
paulieb89 merged 1 commit into
mainfrom
perf/oncomment-skip-closed-threads

Conversation

@paulieb89

Copy link
Copy Markdown
Contributor

Problem

onComment dispatches 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 is closed. 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 in onComment; export onComment for tests.
  • tests/channels/github.test.ts: +4 cases (open→dispatch, closed→null + short-circuit, error→fail-open, wrong-repo→null).

Test

  • npm run typecheck clean
  • npm test → 61/61 pass

Part of the sandbox overhead-cost hardening (permissions untouched — agent capabilities unchanged).

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>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
evolve Ready Ready Preview, Comment Jul 16, 2026 3:59pm

Request Review

@paulieb89
paulieb89 merged commit 74fad71 into main Jul 16, 2026
3 checks passed
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