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.
- Open your connected AI agent and go to the Reinforcement Loop tab.
- Click Settings.
- Add one or more code locations:
| Field | Value |
|---|---|
| Repository | A repo the GitHub App can access |
| Branch | Optional. Defaults to the repo's default branch. |
| Path prefix | Optional. 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:
- Add a workflow to your repo that accepts the inputs below, makes the change, and opens a draft pull request.
- In Monte Carlo, go to Settings → Integrations, click Add, and select GitHub Action Trigger. Install the app on your GitHub organization.
- On the GitHub Action Trigger integration page, under Draft PR workflows, click Add and enter:
| Field | Value |
|---|---|
| Agent | The agent whose fixes open draft PRs |
| Repository | The repo containing the workflow |
| Workflow file | The workflow's file name (e.g. mc-draft-pr.yml) |
| Ref | Branch or tag whose copy of the workflow runs |
Your workflow receives these inputs:
| Workflow input | Value |
|---|---|
title | Issue title |
context | Bayes’ proposed fix and supporting details |
monte_carlo_id | Links the run and pull request to the issue |
monte_carlo_url | Link to the issue in Monte Carlo |
source | reinforcement_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
| Symptom | Fix |
|---|---|
| "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 |
Updated 17 days ago
