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

GitHubRepoForker

Fork a GitHub repository from an issue URL and optionally create an issue-specific branch—the first step in AI agent workflows that fix GitHub issues by modifying code.

Key Features​

  • Parses the repository owner, name, and issue number directly from the GitHub issue URL.
  • Creates a new fork or syncs an existing one with the upstream repository.
  • Optionally waits for the fork to become available before continuing, with configurable timeout and polling interval.
  • Optionally creates a fix-<issue-number> branch in the fork automatically.
  • Resolves a GITHUB_TOKEN secret at runtime, keeping credentials out of the pipeline YAML.
  • Also available as GitHubRepoForkerTool 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 GitHubRepoForker component onto the canvas from the Component Library.
  3. Click on the component to open the configuration panel.
  4. Set auto_sync to True to keep existing forks up to date with the upstream.
  5. Set create_branch to True to generate a fix-<issue-number> branch automatically.

Connections​

GitHubRepoForker receives a single url (the full GitHub issue URL). It outputs repo (the fork path in owner/repo format) and issue_branch (the name of the created branch, if any). Connect these outputs to GitHubFileEditor or GitHubPRCreator to build a complete issue-resolution pipeline.

Source Code​

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

Usage Examples​

Basic Configuration​

GitHubRepoForker:
type: haystack_integrations.components.connectors.github.repo_forker.GitHubRepoForker
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true
auto_sync: true
create_branch: true
wait_for_completion: false
max_wait_seconds: 300
poll_interval: 2

Using the Component in a Pipeline​

This example shows a code-fix agent pipeline that forks a repo from a GitHub issue URL, edits a file in the fork, 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

pr_creator:
type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: 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​

ParameterTypeDescription
urlstrFull GitHub issue URL (for example, https://github.com/owner/repo/issues/123).

Outputs​

ParameterTypeDescription
repostrFork path in owner/repo format.
issue_branchOptional[str]Name of the created branch (for example, fix-123) if create_branch is True, otherwise None.

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 errors. If False, returns empty strings.
wait_for_completionboolFalseIf True, polls until the fork is fully available before returning.
max_wait_secondsint300Maximum number of seconds to wait when wait_for_completion is True.
poll_intervalint2Seconds between status checks when waiting for fork completion.
auto_syncboolTrueIf True, syncs an existing fork with the upstream repository instead of creating a new one.
create_branchboolTrueIf True, creates a fix-<issue-number> branch in the fork.