Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

GitHubIssueCommenter

Post comments to GitHub issues from a pipeline using the GitHub API—useful for AI agents that respond to or triage issues automatically.

Key Features​

  • Posts a comment to any GitHub issue given its URL.
  • Parses the repository owner, name, and issue number directly from the issue URL.
  • Retries failed API requests automatically, with a configurable number of attempts.
  • Resolves a GITHUB_TOKEN secret at runtime, keeping credentials out of the pipeline YAML.
  • Returns a boolean indicating whether the comment was posted successfully.
  • Also available as GitHubIssueCommenterTool for use with Haystack agents.

Configuration​

  1. Store your GitHub personal access token as a secret named GITHUB_TOKEN. For instructions, see Create Secrets.
  2. Drag the GitHubIssueCommenter component onto the canvas from the Component Library.
  3. Click on the component to open the configuration panel.
  4. The token is read automatically from the GITHUB_TOKEN environment variable.

Connections​

GitHubIssueCommenter receives a url (the full GitHub issue URL) and a comment (the text to post). It outputs a success boolean. You can connect an upstream prompt builder or LLM output to the comment input and use the success output to branch the pipeline.

Source Code​

To check this component's source code, open issue_commenter.py in the Haystack Core Integrations repository.

Usage Examples​

Basic Configuration​

GitHubIssueCommenter:
type: haystack_integrations.components.connectors.github.issue_commenter.GitHubIssueCommenter
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true
retry_attempts: 2

Using the Component in a Pipeline​

This example shows a pipeline that reads a GitHub issue, generates a response with an LLM, and posts the reply as a comment.

# haystack-pipeline

components:
issue_viewer:
type: haystack_integrations.components.connectors.github.issue_viewer.GitHubIssueViewer
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: false

prompt_builder:
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
init_parameters:
template:
- role: user
content: "You are a helpful assistant. Read the issue and write a short, helpful comment:\n\n{{ documents[0].content }}"
required_variables:
- documents

llm:
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
init_parameters:
model: gpt-4o-mini

issue_commenter:
type: haystack_integrations.components.connectors.github.issue_commenter.GitHubIssueCommenter
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
retry_attempts: 2

connections:
- sender: issue_viewer.documents
receiver: prompt_builder.documents
- sender: prompt_builder.prompt
receiver: llm.messages
- sender: llm.replies
receiver: issue_commenter.comment

inputs:
query:
- issue_viewer.url
- issue_commenter.url

outputs:
success: issue_commenter.success

max_runs_per_component: 100

metadata: {}

Parameters​

Inputs​

ParameterTypeDescription
urlstrFull GitHub issue URL (for example, https://github.com/owner/repo/issues/123).
commentstrText of the comment to post.

Outputs​

ParameterTypeDescription
successboolTrue if the comment was posted successfully, False otherwise.

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
github_tokenSecretSecret.from_env_var("GITHUB_TOKEN")GitHub personal access token used for API authentication.
raise_on_failureboolTrueIf True, raises an exception on API errors. If False, returns False in success.
retry_attemptsint2Number of retry attempts for failed API requests.