Reinforcement Loop: Code access & draft PRs

The Reinforcement Loop diagnoses issues in your AI agents. With access to an agent's source code, it can point to the code behind an issue and recommend fixes. Requires the GitHub integration.

Prerequisites

The Reinforcement Loop requires the Monte Carlo GitHub App. Set up the GitHub integration first.

Connecting your agent's code

The Reinforcement Loop doesn't read any code until you add a repository to an agent.

Read-only access. The Reinforcement Loop only reads the repos you give it access to. It never pushes code, opens pull requests, or changes your repo on its own. The only write action is creating PRs from fixes, which is optional and must be initiated by a user.

  1. Open your connected AI agent and go to the Reinforcement Loop tab.
  2. Click Settings.
  3. Add one or more code locations:
FieldValue
RepositoryA repo the GitHub App can access
BranchOptional. Defaults to the repo's default branch.
Path prefixOptional. Limits reads to one folder (e.g. agents/support_bot)

Creating PRs from fixes (optional)

Configure the steps below if you'd like to open recommended fixes as draft pull requests. A user on your team can then draft any proposed fix as a pull request.

This uses a second app, Monte Carlo Action Trigger, which can start a workflow in your repo but cannot read your code.

Permissions required:

  • Read and write access to actions
  • Read access to metadata

Setup:

  1. Add a workflow to your repo that accepts the inputs below, makes the change, and opens a draft pull request.
  2. In Monte Carlo, go to Settings → Integrations, click Add, and select GitHub Action Trigger. Install the app on your GitHub organization.
  3. On the GitHub Action Trigger integration page, under Draft PR workflows, click Add and enter:
FieldValue
AgentThe agent whose fixes open draft PRs
RepositoryThe repo containing the workflow
Workflow fileThe workflow's file name (e.g. mc-draft-pr.yml)
RefBranch or tag whose copy of the workflow runs

Your workflow receives these inputs:

Workflow inputValue
titleIssue title
contextRecommended fix and supporting details
monte_carlo_idLinks the run and pull request to the issue
monte_carlo_urlLink to the issue in Monte Carlo
sourcereinforcement_loop

Your workflow opens the pull request with your repository's GITHUB_TOKEN, so your branch protection rules and review requirements apply. Inputs appear in the Actions run log and never contain secrets. Creating a PR from a Reinforcement Loop requires permission to edit alerts.

Verifying

  • Code access: on the next diagnosis, issues for the agent reference files in the repo and include a proposed fix.
  • Pull requests from fixes: trigger a fix from an issue. The issue shows the run status, then links the draft PR.

Troubleshooting

SymptomFix
"The GitHub installation for … can't read the repo …"Give the GitHub App access to that repo
"The branch … isn't on …" or "The path … isn't on …"Fix the branch or path prefix
"Draft-PR workflow dispatch is not enabled for this account."Contact Monte Carlo

Did this page help you?