Skip to main content
In this tutorial, an agent fixes a bug from a GitHub issue, adds a test, and opens a pull request. You then check the pull request and review it like any other. It takes about 20 minutes. The examples use the repository acme/web and its issue 412; replace them with yours.
You need the Developer or Admin role in the organization; see Organizations and roles. You also need permission to install a GitHub App on the GitHub account that owns the repository, or an existing GitHub connection in Recursion. The repository should run its tests on pull requests, for example in GitHub Actions, so you can see them pass on the agent’s pull request.

Step 1: Connect GitHub

Connecting is an interactive authorization in GitHub, so do it in the console. It creates a connection for your organization but gives no agent access yet. Use the console or cURL.
  1. In the sidebar, click Integrations, then click Add integration.
  2. Choose GitHub, then click Continue.
  3. On GitHub, choose the account and select the repositories the connection may reach, including acme/web.
  4. Back in Recursion, choose the account if asked. The connection appears under Integration connections.
  5. Enable issue_read, get_file_contents, create_branch, push_files, and create_pull_request in the connection’s tool selection. New connections start with read-only tools selected.
  6. Open the connection’s actions menu and click Test connection to confirm it can issue a token.
Continue when state is active.

Step 2: Create an environment

The agent works on GitHub through its GitHub tools, which run outside the sandbox, so the environment needs no GitHub network rules. New environments block all outbound traffic, which is fine for this task.
  1. In the sidebar, click Environments, then click Create environment.
  2. Enter a Name, such as github-fixes.
  3. Click Create environment.
See Environments.

Step 3: Create the agent with GitHub access

Give the agent the GitHub tools it needs and access to only the repository it needs. The selected tools determine its short-lived token permissions. GitHub’s MCP tools run outside the sandbox; git and gh in the sandbox are not authenticated for GitHub.
  1. In the sidebar, click Agents, then click Create agent and choose Blank.
  2. Enter a Name, choose a model, and paste the system value from the cURL tab into System prompt. Click Create agent.
  3. On the agent’s Configuration tab, under Integrations, click Add integration access and select the GitHub connection.
  4. Select issue_read, get_file_contents, create_branch, push_files, and create_pull_request under Tools.
  5. Clear All authorized repositories, then select acme/web.
  6. Click Use this access, then click Save new version.
You can grant GitHub through a vault instead, which is useful when several agents share one grant. See GitHub and Vaults.

Step 4: Start the session

The opening message names the issue. The system prompt already says how to work: find the cause, commit the fix and a test on a new branch, and open a pull request.
  1. In the sidebar, click Sessions, then click Launch session.
  2. Choose the Issue fixer agent and the github-fixes environment.
  3. In Opening message, enter Fix https://github.com/acme/web/issues/412 and open a pull request.
  4. Click Launch session.
The API answers 202 Accepted.
The Idempotency-Key makes the start safe to retry: sending the same key again returns the same session instead of starting a second one.

Step 5: Wait for the session to finish

Watch the session in the console, or poll it until the agent’s turn ends.
  1. In the sidebar, click Sessions, then open the session.
  2. Follow the transcript as the agent reads the issue and code, commits, and opens the pull request.
  3. When the agent is done, its last message gives the pull request URL.
A finished session looks like this. Some fields are left out here.

What success means

  • The session’s stop_reason is end_turn, and the agent’s last message gives the pull request URL.
  • A pull request is open in acme/web from a branch other than main, its description starts with “Fixes” and the issue URL, and it adds a test for the bug.
  • A finished session doesn’t prove the work is right. Check the pull request and its checks before you merge. See What success means for other session states.

Step 6: Review the pull request

Open the URL from the agent’s last message, or list the repository’s open pull requests through the connection.
Review and merge it the way you would any contributor’s pull request.

What can go wrong

Limits

  • A grant can list up to 500 repositories.
  • An agent can hold up to 25 integration connections.
  • See Limits for session and environment limits.

Next steps

GitHub

Permission presets, vault grants, and how GitHub tools work.

Automations

Start this agent when an issue is labeled.

Research team tutorial

Split a larger task across a team.

Environments

Network policy, setup scripts, and compute.