fix: create sticky comment in agent mode when use_sticky_comment is true#1168
Open
qozle wants to merge 1 commit intoanthropics:mainfrom
Open
fix: create sticky comment in agent mode when use_sticky_comment is true#1168qozle wants to merge 1 commit intoanthropics:mainfrom
qozle wants to merge 1 commit intoanthropics:mainfrom
Conversation
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>
ashwin-ant
approved these changes
Apr 5, 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
use_sticky_comment: truesilently does nothing in agent mode. The MCP comment server starts withoutCLAUDE_COMMENT_ID, so everyupdate_claude_commenttool 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.tshardcodesclaudeCommentId: undefined(line 105) and never callscreateInitialComment(). Tag mode calls it and passes the ID — agent mode skips it entirely.Fix
When
use_sticky_comment: trueand the context is an entity event (PR or issue), callcreateInitialComment()beforeprepareMcpConfigand 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 theisEntityContext()guard, since there's no PR or issue to attach a comment to.The cleanup phase in
run.tsalready updates the comment whencommentIdis set, so no changes are needed there.Testing
bun test: 656 pass, 0 fail