Skip to content

Drop buffered inline comment when it is posted live (#1405)#1412

Open
archievi wants to merge 1 commit into
anthropics:mainfrom
archievi:fix/inline-comment-buffer-dedup-1405
Open

Drop buffered inline comment when it is posted live (#1405)#1412
archievi wants to merge 1 commit into
anthropics:mainfrom
archievi:fix/inline-comment-buffer-dedup-1405

Conversation

@archievi

Copy link
Copy Markdown

Summary

Fixes #1405: inline comments are posted twice when classify_inline_comments is enabled (the default).

When buffering is on, create_inline_comment buffers calls without confirmed=true and replies "Set confirmed=true to post immediately." The model frequently reacts by re-issuing the call with confirmed=true, which posts the comment live, but the original buffered entry stays in /tmp/inline-comments-buffer.jsonl. The post-buffered-inline-comments step then replays it, so every inline comment lands twice (~15-25s apart). For Vertex/Bedrock users (no ANTHROPIC_API_KEY) the whole buffer is replayed unconditionally, but the duplicate happens regardless of classification because the buffered entries are genuine comments.

Fix

This implements option 1 from the issue: reconcile the buffer on a live post. After a confirmed=true comment is created, any buffered entry matching the same path + line + startLine + body is removed, so the replay step can no longer post a duplicate.

The reconciliation is extracted into src/mcp/inline-comment-buffer.ts. The MCP server module starts a stdio server (and process.exits on missing env) at import time, so the logic is pulled into an import-safe module to keep it unit-testable.

Tests

test/inline-comment-buffer.test.ts (5 cases): removes the matching entry, removes repeated copies, leaves the buffer untouched when nothing matches, no-ops when the buffer file is absent, and preserves lines that cannot be parsed.

Verification (run locally)

  • bun test — full suite 734 pass / 0 fail (5 new tests included).
  • bun run typecheck (tsc --noEmit) — clean.
  • prettier --check — clean on all changed files.

Notes

This is the minimal root-cause fix for the re-call path. The issue also suggests dedup in the post-step (idempotency across retries / gh api posts) as defense-in-depth; happy to add that here or in a follow-up if preferred.

When classify_inline_comments is enabled, create_inline_comment buffers calls
without confirmed=true. The model frequently re-issues the call with confirmed=true
after reading the buffered reply, which posts the comment live but leaves the
original buffered entry behind. The post-session replay step then posts it again,
so every inline comment lands twice.

Reconcile the buffer on a live post: after a confirmed comment is created, remove
any buffered entry matching the same path, line, startLine and body so it cannot be
replayed. Extracts the reconciliation into src/mcp/inline-comment-buffer.ts (the MCP
server module starts a server on import) and adds unit tests.
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.

classify_inline_comments: buffered unconfirmed calls are replayed after the model re-posts with confirmed=true, duplicating every inline comment

1 participant