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

GitHubPRCreator

Create a pull request from a forked repository back to the original repository—designed for AI agents that write code fixes and submit them for review.

Key Features​

  • Creates cross-repository pull requests from a fork to the upstream repository.
  • Parses the target repository and issue number from a GitHub issue URL, automatically linking the PR to the issue.
  • Verifies that the fork exists under the authenticated user's account before submitting.
  • Supports draft pull requests via the draft parameter.
  • Allows maintainers to modify the PR by setting maintainer_can_modify to true automatically.
  • Also available as GitHubPRCreatorTool 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 GitHubPRCreator 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​

GitHubPRCreator receives an issue_url, a title, a branch (branch in your fork containing the changes), a base (target branch in the upstream repo), and an optional body and draft flag. It outputs a result string with the PR number or an error message. Connect it at the end of an agent pipeline after GitHubFileEditor and GitHubRepoForker have prepared the fork and branch.

Source Code​

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

Usage Examples​

Basic Configuration​

GitHubPRCreator:
type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true

Using the Component in a Pipeline​

This example shows the final step of a code-fix agent pipeline that forks a repo, makes a change, and opens a pull request.

# haystack-pipeline

components:
repo_forker:
type: haystack_integrations.components.connectors.github.repo_forker.GitHubRepoForker
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
auto_sync: true
create_branch: true

file_editor:
type: haystack_integrations.components.connectors.github.file_editor.GitHubFileEditor
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
branch: main

pr_creator:
type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true

connections:
- sender: repo_forker.repo
receiver: file_editor.repo
- sender: repo_forker.issue_branch
receiver: file_editor.branch

inputs:
query:
- repo_forker.url
- pr_creator.issue_url

outputs:
result: pr_creator.result

max_runs_per_component: 100

metadata: {}

Parameters​

Inputs​

ParameterTypeDefaultDescription
issue_urlstrFull GitHub issue URL (for example, https://github.com/owner/repo/issues/123). Used to identify the target repository and to link the PR.
titlestrTitle of the pull request.
branchstrBranch in your fork that contains the changes.
basestrBranch in the original repository to merge into (for example, main).
bodystr""Additional description for the pull request.
draftboolFalseIf True, creates a draft pull request.

Outputs​

ParameterTypeDescription
resultstrConfirmation message with the PR number (for example, Pull request #42 created successfully and linked to issue #123) or an error message.

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. Must belong to the fork owner.
raise_on_failureboolTrueIf True, raises an exception on API errors. If False, returns an error string in result.