Skip to main content
In this tutorial, an agent fixes a bug from a GitHub issue, adds a test, and opens a pull request. The session is graded, so it only completes once a grader confirms the pull request exists, the tests pass, and the fix is covered by a test. It takes about 20 minutes. The TypeScript samples assume the rl client from Client setup. The examples use the repository acme/web and its issue 412; replace them with yours.

Before you begin

  • You need the Developer or Admin role in the organization. See Organizations and roles.
  • You 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 have a test command that runs in a clean checkout, such as npm test.

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. The SDKs don’t wrap integration operations; 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. Open the connection’s actions menu and click Check to confirm it can issue a token.
Continue when state is active.

Step 2: Create an environment that can reach GitHub

New environments block all outbound traffic. A GitHub grant supplies credentials, not network access, so the environment must allow GitHub’s hosts. This example also allows the npm registry so the agent can install dependencies and run the tests.
  1. In the sidebar, click Environments, then click Create environment.
  2. Enter a Name, such as github-fixes.
  3. Set Internet access to Enabled.
  4. Click Create environment.
The console offers all or nothing. To allow only specific hosts, use the API.
If your tests need other hosts, such as a Python package index, add an allow rule for each. See Environments.

Step 3: Create the agent with GitHub access

Give the agent Read and write access (write) to only the repository it needs. That preset can push commits and open pull requests. The agent gets authenticated git and gh commands in its sandbox through a short-lived token. The token isn’t put in the prompt, but commands in the sandbox can read it, so grant only the repositories the task needs.
  1. In the sidebar, click Agents, then click Create agent and choose Blank.
  2. Enter a Name, choose a model, and paste the system prompt from the TypeScript 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. Set Access level to Read and write.
  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 a graded session

The outcome states what done means. The grader checks the work in the same sandbox with the same tools, so write criteria it can verify, such as a pull request it can open with gh pr view and tests it can run. max_iterations caps how many times the grader can send the work back.
  1. In the sidebar, click Sessions, then click Launch session.
  2. Choose the Issue fixer agent and the github-fixes environment.
  3. Under Task, select Grade this session against a rubric, and paste the rubric from the TypeScript tab into Rubric.
  4. In Opening message, enter Fix https://github.com/acme/web/issues/412 and open a pull request.
  5. Click Launch session.
The API answers 202 Accepted. With no message, the outcome’s description opens the session.
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 grade

Watch the session in the console, or poll the outcome until its status is terminal.
  1. In the sidebar, click Sessions, then open the session.
  2. Follow the transcript as the agent clones, tests, and pushes. The grader’s verdicts appear as each attempt is graded.
  3. When the session completes, the last message gives the pull request URL.
A satisfied outcome looks like this:

What success means

  • The outcome’s terminal_result is satisfied, the session’s execution_state is completed, and its stop_reason is outcome_satisfied.
  • A pull request is open in acme/web and every rubric criterion passed.
  • Other terminal results need a look: max_iterations_reached means the grader still found a failing criterion after 3 attempts, and failed means the rubric couldn’t be graded. See Outcomes.

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, outcome, and environment limits.

Next steps

GitHub

Permission presets, vault grants, and GitHub MCP tools.

Outcomes

Write rubrics that grade reliably.

Research team tutorial

Split a larger task across a team.

Environments

Network policy, setup scripts, and compute.