Skip to content

fix: create sticky comment in agent mode when use_sticky_comment is true#1168

Open
qozle wants to merge 1 commit intoanthropics:mainfrom
qozle:fix/sticky-comment-agent-mode
Open

fix: create sticky comment in agent mode when use_sticky_comment is true#1168
qozle wants to merge 1 commit intoanthropics:mainfrom
qozle:fix/sticky-comment-agent-mode

Conversation

@qozle
Copy link
Copy Markdown
Contributor

@qozle qozle commented Apr 5, 2026

Problem

use_sticky_comment: true silently does nothing in agent mode. The MCP comment server starts without CLAUDE_COMMENT_ID, so every update_claude_comment tool call fails with "CLAUDE_COMMENT_ID environment variable is required". No comment ever appears on the PR. Fixes #1108.

Root cause

src/modes/agent/index.ts hardcodes claudeCommentId: undefined (line 105) and never calls createInitialComment(). Tag mode calls it and passes the ID — agent mode skips it entirely.

Fix

When use_sticky_comment: true and the context is an entity event (PR or issue), call createInitialComment() before prepareMcpConfig and pass the returned ID. The same function tag mode uses — handles sticky comment reuse, event type routing, and fallback logic.

Non-entity events (workflow_dispatch, schedule, push) correctly skip comment creation via the isEntityContext() guard, since there's no PR or issue to attach a comment to.

The cleanup phase in run.ts already updates the comment when commentId is set, so no changes are needed there.

Testing

  • 3 new tests: sticky comment created for entity context, skipped when disabled, skipped for non-entity events
  • bun test: 656 pass, 0 fail

Agent mode hardcoded `claudeCommentId: undefined`, so the MCP comment
server started without `CLAUDE_COMMENT_ID`. Every `update_claude_comment`
call failed with "CLAUDE_COMMENT_ID environment variable is required",
silently discarding the sticky comment feature.

When `use_sticky_comment: true` and the context is an entity event
(PR or issue), call `createInitialComment()` — the same function tag
mode uses — and pass the resulting ID to the MCP server config. The
cleanup phase in run.ts already handles comment updates when commentId
is set, so no changes needed there.

Non-entity events (workflow_dispatch, schedule, push) correctly skip
comment creation since there is no PR or issue to attach to.

Fixes anthropics#1108.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

use_sticky_comment has no effect in agent mode — MCP server starts without CLAUDE_COMMENT_ID

2 participants