Skip to content

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

@cheapsteak

Description

@cheapsteak

Describe the bug

When use_sticky_comment: true is set but the action enters agent mode (because track_progress: false and a prompt is provided), the sticky comment feature silently breaks. No comment is ever created on the PR, even though the MCP comment server is included in the tool list.

The root cause is a code path gap in src/modes/agent/index.ts:

  1. detectMode() in src/modes/detector.ts returns "agent" when track_progress is false and prompt is set
  2. In src/modes/agent/index.ts line 105, claudeCommentId is hardcoded to undefined
  3. Even though shouldIncludeCommentServer evaluates to true in install-mcp-server.ts (because mcp__github_comment__update_claude_comment is in allowedTools), the MCP server starts without CLAUDE_COMMENT_ID in its environment
  4. Every call to update_claude_comment fails at line 42-44 of github-comment-server.ts with: "CLAUDE_COMMENT_ID environment variable is required"

Unlike tag mode, agent mode never calls createInitialComment() to create the comment and obtain its ID.

To Reproduce

  1. Configure a workflow with track_progress: false, use_sticky_comment: true, and a prompt on a pull_request event (e.g., with types: [labeled])
  2. Trigger the action by adding the label to a PR
  3. The action runs successfully (Claude executes the prompt and produces output)
  4. No sticky comment appears on the PR

Expected behavior

When use_sticky_comment: true, agent mode should create an initial comment (like tag mode does via createInitialComment()) and pass the resulting comment ID to the MCP server via CLAUDE_COMMENT_ID. The sticky comment should be updated throughout the run.

Workflow yml file

on:
  pull_request:
    types: [labeled]

jobs:
  review:
    if: github.event.label.name == 'claude-review'
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          use_sticky_comment: true
          prompt: |
            Review this pull request and post your findings as a comment.

Because track_progress defaults to false and prompt is set, this enters agent mode where the sticky comment is silently ignored.

API Provider

[x] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex

Additional context

  • Workaround: Setting track_progress: true forces tag mode where sticky comments work, but this isn't viable for all event types (e.g., labeled fails validateTrackProgressEvent).
  • Suggested fix: In agent/index.ts, when context.inputs.useStickyComment is true and the context is a PR or issue, call createInitialComment() and pass the resulting ID as claudeCommentId to prepareMcpConfig.
  • Possibly related: use_sticky_comment: review text captured in result but never posted as PR comment #1052 may be a downstream symptom of this same root cause — the review result is captured but never posted because the comment server silently fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmcpp2Non-showstopper bug or popular feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions