Reinforcement Loop: Code access & draft PRs

Bayes, Monte Carlo’s AI teammate, runs the Reinforcement Loop. It observes your AI agents in production, diagnoses issues, proposes fixes, and confirms they held. Connecting an agent’s code lets Bayes point to the exact code behind an issue, and propose the fix.

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. Bayes only reads the repos you give it access to. It never pushes code, opens pull requests on its own, or changes your repo. The only write action is creating PRs from fixes, which is optional and always initiated by a user on your team.

  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)

When Bayes proposes a fix, a user on your team can open it as a draft pull request. Nothing is opened automatically.

Configure the steps below if you'd like to open proposed fixes as draft pull requests. 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
contextBayes’ proposed 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, Bayes’ findings for the agent include a fix and reference files in the repo.
  • 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?