---
title: "Self-improving agent"
description: "Give an eve GitHub agent read access to its own production runs through the Vercel MCP, so every week it finds what slowed it down and opens a pull request on its own repository to fix it."
canonical_url: "https://github-tools.com/guides/self-improving-agent"
---
# Self-improving agent

> Give an eve GitHub agent read access to its own production runs through the Vercel MCP, so every week it finds what slowed it down and opens a pull request on its own repository to fix it.

A self-improving agent reads the record of its own past work, finds what failed or took too long, and changes its own setup to do better. Here, that change is a pull request on the agent's own repository. By default it opens as a draft and ships only when a person merges it, and you can [give the agent more freedom](#choose-how-much-the-agent-does-on-its-own) once you trust it. This guide adds that loop to the [`examples/eve`](https://github.com/vercel-labs/github-tools/tree/main/examples/eve) agent, which already answers people in Slack and on GitHub.

<self-improving-loop>



</self-improving-loop>

## How the loop works

The loop has four steps, and it runs once a week:

<table>
<thead>
  <tr>
    <th>
      Step
    </th>
    
    <th>
      Who does it
    </th>
    
    <th>
      What happens
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      1. Answer
    </td>
    
    <td>
      The agent
    </td>
    
    <td>
      It answers people in Slack and on GitHub, as it already does.
    </td>
  </tr>
  
  <tr>
    <td>
      2. Trace
    </td>
    
    <td>
      Vercel
    </td>
    
    <td>
      <a href="https://vercel.com/docs/agent-runs" rel="nofollow">
        Agent Runs
      </a>
      
       records each run: its turns, tool calls, timings and token usage.
    </td>
  </tr>
  
  <tr>
    <td>
      3. Review
    </td>
    
    <td>
      The agent, on a schedule
    </td>
    
    <td>
      Every Monday it reads last week's runs through the <a href="https://vercel.com/docs/agent-resources/vercel-mcp" rel="nofollow">
        Vercel MCP
      </a>
      
       and looks for what repeats: a failing tool, a slow pattern, a wasted call.
    </td>
  </tr>
  
  <tr>
    <td>
      4. Pull request
    </td>
    
    <td>
      The agent, then you
    </td>
    
    <td>
      For each finding, it opens a draft pull request on its own repository that changes its instructions or config. You review it like any other pull request, and merging it ships the change.
    </td>
  </tr>
</tbody>
</table>

This guide starts with the safe setup: the agent can open those pull requests without asking, and nothing else. It does so only during the scheduled review, only on its own repository, and only on `agent/` branches, and it can't merge. Your review is the step that decides what the agent becomes. How much of that review you keep is your choice: [Choose how much the agent does on its own](#choose-how-much-the-agent-does-on-its-own) goes from a report you read to an agent that merges its own changes.

## What you'll build

You'll add four files to the agent and change one:

```text
agent/
├── connections/vercel.ts        # new: reads the agent's own runs through the Vercel MCP
├── skills/self-review/SKILL.md  # new: how to review the runs and what to open
├── schedules/
│   ├── weekly-review.ts         # new: every Monday, the review
│   └── failure-watch.ts         # new: every day, a message only when a run failed
└── extensions/github.ts         # changed: lets the review open its pull requests
```

Every Monday, a thread in a Slack channel links the pull requests the review opened, one per finding, at most three. A pull request from the review looks like this:

> **Call getCiFailureContext first for CI questions**
> 
> In 7 of last week's 9 CI questions, `getWorkflowJobLogs` ran three times per run and took 21 of 48 seconds. `getCiFailureContext` returns the failed steps and the end of each failed job's log in one call. Runs: `wrun_8f2…`, `wrun_c41…`, `wrun_e07…`.
> 
> `agent/instructions.md`: + For a failed CI run, call `getCiFailureContext` first.

## Before you start

- **The examples/eve agent, deployed.** Follow its [README](https://github.com/vercel-labs/github-tools/tree/main/examples/eve#set-up) through the Slack channel and the deploy.
- **The agent's code in its own GitHub repository**, with the agent's GitHub App installed on it. The App needs Contents (write) and Pull requests (write) there, the [`pr-author` permissions](https://github-tools.com/auth#permissions-per-preset). With the Deploy button, Vercel creates that repository and connects it to the project, so merging a pull request also deploys it.
- **Agent Runs that record your runs.** Agent Runs is in [beta](https://vercel.com/docs/release-phases#beta) on all plans, billed at [Tracing rates](https://vercel.com/docs/tracing/configure-tracing#usage-and-pricing), and keeps runs for 30 days. It only records a run when the project samples traces. `npx eve deploy` sets that up for a project it creates. For any other project, such as one created with the Deploy button, add a 100% rule under **Settings → Tracing**, as [Agent Runs](https://vercel.com/docs/agent-runs#configure-tracing-for-existing-projects) describes. Then use the agent for a few days, so the review has runs to read. The project's **Observability → Agent Runs** page lists them. By default, a run in a direct message or a private channel records tool names but not their inputs and outputs. [Let the review read tool inputs and outputs](#let-the-review-read-tool-inputs-and-outputs) covers what that leaves out and how to change it.
- **A private Slack channel for the reports**, with the Slack app invited. A trace holds what people asked the agent, so keep the reports where only maintainers read them.

## 1. Create a Vercel connector

The weekly review runs on a schedule, with nobody signed in, so the agent can't use a person's Vercel login. A [Vercel Connect](https://vercel.com/docs/connect) connector gives it a token of its own. From the agent's directory, create one for the Vercel MCP:

```bash [Terminal]
vercel connect create vercel --connection-method mcp --name github-agent
```

`--connection-method mcp` picks the Vercel MCP. Without it, the CLI asks whether to connect the Vercel REST API or the MCP. If the CLI opens your browser, sign in with a Vercel account that has access to the agent's project, and grant access to the team that owns it. Signing in and granting team access are [two separate steps](https://vercel.com/docs/agent-resources/vercel-mcp/tools#sign-in-and-grant-team-access): without the team grant, the token works but every call to the agent's project returns `403`.

Then let the agent's project use the connector:

```bash [Terminal]
vercel connect attach vercel/github-agent --yes
```

`vercel/github-agent` is the connector's UID: the service, then the name. If you chose another name, `vercel connect list` shows the UID.

## 2. Set the environment variables

The connection, the extension and the schedules read five values from the environment:

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Value
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        AGENT_TEAM_ID
      </code>
    </td>
    
    <td>
      <code>
        orgId
      </code>
      
       in <code>
        .vercel/project.json
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AGENT_PROJECT_ID
      </code>
    </td>
    
    <td>
      <code>
        projectId
      </code>
      
       in <code>
        .vercel/project.json
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AGENT_REPOSITORY
      </code>
    </td>
    
    <td>
      The agent's own repository, such as <code>
        my-org/github-agent
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        REVIEW_SLACK_CHANNEL
      </code>
    </td>
    
    <td>
      The ID of the reports channel, such as <code>
        C0123ABC
      </code>
      
      . It's at the bottom of the channel's details in Slack.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        MAINTAINERS
      </code>
    </td>
    
    <td>
      The Slack member IDs of the people who may ask the agent about its runs, comma-separated, such as <code>
        U0456DEF,U0789GHI
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

`.vercel/project.json` is written when you link the project. To find a member ID, open the person's Slack profile and select **Copy member ID**.

eve identifies a Slack user as `slack:<team>:<user>`, where `<team>` is the workspace the Slack app is installed in. On Enterprise Grid, that isn't always the workspace in the Slack URL, so the connection below matches the member ID alone.

Add each variable to the project:

```bash [Terminal]
vercel env add AGENT_TEAM_ID production
```

Repeat for the other four, then run `vercel env pull` so `eve dev` reads them from `.env.local` too.

## 3. Add the connection

A connection gives the agent the tools of an MCP server. Its filename, `vercel`, becomes the prefix of every tool name, as in `vercel__list_agent_runs`:

```ts [agent/connections/vercel.ts]
import { connect } from '@vercel/connect/eve'
import { defineMcpClientConnection } from 'eve/connections'
import { isScheduleAuth } from 'eve/schedules'

const maintainers = new Set((process.env.MAINTAINERS ?? '').split(','))
const isMaintainer = (principalId: string) =>
  principalId.startsWith('slack:') && maintainers.has(principalId.split(':').at(-1)!)

export default defineMcpClientConnection({
  url: 'https://mcp.vercel.com',
  description: "This agent's own production activity on Vercel: Agent Runs with their traces, runtime errors and runtime logs. Read-only.",
  tools: {
    allow: ['list_agent_runs', 'get_agent_run', 'get_agent_run_trace', 'get_runtime_errors', 'get_runtime_logs'],
  },
  toolCall: {
    providedArguments: {
      teamId: () => process.env.AGENT_TEAM_ID!,
      projectId: () => process.env.AGENT_PROJECT_ID!,
    },
  },
  auth: ({ session }) => {
    const caller = session.auth.current
    if (isScheduleAuth(caller) || (caller !== null && isMaintainer(caller.principalId))) {
      return connect({ connector: 'vercel/github-agent', principalType: 'app' })
    }
    return {
      principalType: 'app',
      getToken: () => Promise.reject(new Error('Only scheduled runs and maintainers can read this agent\'s runs.')),
    }
  },
})
```

Three options keep this connection safe:

- **tools.allow** exposes five read-only tools. The Vercel MCP can also deploy, change environment variables and manage domains. None of that is reachable here.
- **providedArguments** fills in `teamId` and `projectId` on every call. The model never sees these two inputs, so it can only read this agent's project.
- **auth** hands out a token only to a scheduled run or to someone in `MAINTAINERS`. Anyone else who asks the agent about its runs in Slack gets an error, not your runtime logs.

`principalType: 'app'` means the token belongs to the agent, not to a person, which is what a scheduled run needs. If every call fails with `OAuth token request failed`, see [Troubleshooting](#troubleshooting).

## 4. Let the review open its pull requests

With `requireApproval: 'auto'`, opening a pull request always asks for approval. A scheduled review has nobody to ask, so the agent needs one exception: `editFiles`, the tool that creates a branch, commits the edits and opens a pull request in one call, may run without asking when all three of these hold:

```ts [agent/extensions/github.ts]
import githubExtension from '@github-tools/eve-extension'
import { isScheduleAuth } from 'eve/schedules'

const [owner, repo] = (process.env.AGENT_REPOSITORY ?? '').split('/')

export default githubExtension({
  connector: 'github/github-agent',
  actAs: 'caller',
  preset: 'auto',
  requireApproval: 'auto',
  overrides: {
    editFiles: {
      approval: ({ session, toolInput }) => {
        const scheduled = isScheduleAuth(session.auth.current)
        const ownRepository = toolInput?.owner === owner && toolInput?.repo === repo
        const agentBranch = typeof toolInput?.branch === 'string' && toolInput.branch.startsWith('agent/')
        return scheduled && ownRepository && agentBranch ? 'not-applicable' : 'user-approval'
      },
    },
  },
})
```

- **scheduled**: the turn runs as the agent itself, which only a schedule does. When a person asks for the same edit in Slack, it asks them first, as before.
- **ownRepository**: the edit targets `AGENT_REPOSITORY`. An edit to any other repository asks.
- **agentBranch**: the commit lands on an `agent/` branch, never on `main`.

`'not-applicable'` lets the call run, and `'user-approval'` asks for approval. Every other write, including `mergePullRequest`, keeps the `'auto'` behavior. In a scheduled run there is nobody to approve them, so they don't happen.

## 5. Write the review procedure

A [skill](https://eve.dev/docs/skills) holds the procedure. The model loads it only when a review runs, so it costs nothing on other turns:

```md [agent/skills/self-review/SKILL.md]
---
description: Review your own production runs for failed, slow and expensive work, and open pull requests on your own repository that fix what repeats. Load this when a scheduled review fires or a maintainer asks for one.
---

# Self review

## Read

1. List the last 7 days of runs with `vercel__list_agent_runs` (`period: '7d'`, `pageSize: 100`). List the 7 days before them with `from` and `to`, to compare.
2. Pick three groups of up to three runs: runs that failed or never answered, the slowest runs, and the runs that used the most tokens. To compare how long runs took, read their lifecycle events with `vercel__get_agent_run`.
3. Read each picked run with `vercel__get_agent_run_trace`. A trace can come in pages: while the response has a `later` cursor, fetch the next page. An empty trace doesn't mean the run did nothing. A trace without tool inputs and outputs still shows which tools ran and how often: skip the checks that need content, and say so in the report. Look for:
   - a tool call that failed and was retried with the same input
   - the same tool called several times in one turn, such as paging through a list or a log
   - a tool output much larger than the answer needed
   - a question to the person that your instructions already answer
4. Read `vercel__get_runtime_errors` for the same 7 days, and look inside a growing error with `vercel__get_runtime_logs`.

## Decide

A finding is a pattern seen in at least two runs, with a cause you can name and one change that addresses it. The change goes in a file you already have: `agent/instructions.md`, an option in `agent/extensions/github.ts`, or a new skill under `agent/skills/`. A pattern seen in one run is not a finding. Keep at most three findings, the strongest first.

## Open

Before opening anything, list your open pull requests on `agent/` branches. Skip a finding an open pull request already covers.

For each finding, call `editFiles` once, on your own repository:

- `branch`: `agent/` followed by a short name for the change, such as `agent/ci-failure-context`, with `baseBranch` set to the default branch
- `edits`: the smallest change that addresses the finding
- `pullRequest`: `draft: true`, a title that says what changes, and a body with the numbers, the run IDs, the cause, and what a reviewer should check

Quote run IDs and tool names, never what a person wrote. Never merge, and never open a pull request on another repository.

## Report

Reply with this week's run count, failures and token usage next to last week's, then one line per pull request with its link. When nothing repeats, reply in one line that the week was clean, and open nothing.
```

The skill names the exact limits the extension enforces, so the model doesn't waste a call on a pull request the approval policy would stop.

## 6. Schedule the weekly review

A [schedule](https://eve.dev/docs/schedules) starts the agent at a set time instead of waiting for a message. This one opens a new thread in the reports channel every Monday at 08:00 UTC, the time zone schedules use on Vercel:

```ts [agent/schedules/weekly-review.ts]
import { defineSchedule } from 'eve/schedules'
import slack from '../channels/slack'

export default defineSchedule({
  cron: '0 8 * * 1',
  run({ to, waitUntil, appAuth }) {
    waitUntil(
      to(slack, { channelId: process.env.REVIEW_SLACK_CHANNEL! }).send(
        `Load the self-review skill and review your production runs from the last 7 days. Your source is in ${process.env.AGENT_REPOSITORY}.`,
        { auth: appAuth },
      ),
    )
  },
})
```

`auth: appAuth` runs the session as the agent itself: the identity `isScheduleAuth` checks in the connection and in the extension. `waitUntil` keeps the schedule running until Slack has the message.

The report thread stays a conversation. Mention the agent in it to continue, since by default the agent only answers thread replies that mention it. A maintainer can ask why a pull request makes a change, or ask for a different one, and the traces the agent read are still in its context. An edit asked for in the thread is a person's request, so it asks that person for approval first.

## 7. Watch for failures every day

A weekly review is too late for a failure. A second schedule checks the last day every morning and posts only when it finds something. It needs eve's `no_reply` tool, which ends a turn without posting:

```bash [Terminal]
npx eve add tool/no_reply
```

```ts [agent/schedules/failure-watch.ts]
import { defineSchedule } from 'eve/schedules'
import slack from '../channels/slack'

export default defineSchedule({
  cron: '0 7 * * *',
  run({ to, waitUntil, appAuth }) {
    waitUntil(
      to(slack, { channelId: process.env.REVIEW_SLACK_CHANNEL! }).send(
        'Check your production runs and runtime errors from the last 24 hours. If no run failed and no runtime error is new, call no_reply. Otherwise post one line per failure, with the run ID and the likely cause. Open nothing.',
        { auth: appAuth },
      ),
    )
  },
})
```

This one needs no skill: it reads two lists and posts a few lines. Its message says to open nothing, so a failure gets a person's attention instead of a hasty pull request.

## Run it

The review reads production runs, and Slack sends replies in the report thread to the deployed agent, so test it in production. Deploy:

```bash [Terminal]
npx eve deploy
```

On Vercel, each eve schedule becomes a [Vercel Schedule](https://vercel.com/docs/schedules) named `eve.` plus the schedule's file name. List them, then fire the weekly review now instead of waiting for Monday:

```bash [Terminal]
vercel schedules list
```

```bash [Terminal]
vercel schedules invoke eve.weekly-review
```

The review opens its pull requests on `AGENT_REPOSITORY` and posts the report in the reports channel. `vercel schedules executions list eve.weekly-review` shows each run, and **Observability → Logs** shows its logs.

Review the pull requests on GitHub. When the project is connected to the repository, merging one deploys the agent with the change. Otherwise, run `npx eve deploy` again.

## Choose how much the agent does on its own

Draft pull requests are a starting point, not a limit. The same loop runs at four levels of freedom, and you move between them by changing the extension's `overrides` and one line of the skill:

<table>
<thead>
  <tr>
    <th>
      Level
    </th>
    
    <th>
      What the agent does alone
    </th>
    
    <th>
      What you do
    </th>
    
    <th>
      Change from this guide
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      1. Report
    </td>
    
    <td>
      Reads its runs and posts its findings
    </td>
    
    <td>
      Ask it to open the ones you want
    </td>
    
    <td>
      Remove <code>
        overrides
      </code>
      
      , and replace the skill's <strong>
        Open
      </strong>
      
       section with "End by asking which findings to open."
    </td>
  </tr>
  
  <tr>
    <td>
      2. Draft pull requests (this guide)
    </td>
    
    <td>
      Opens a draft per finding
    </td>
    
    <td>
      Mark it ready, review and merge
    </td>
    
    <td>
      None
    </td>
  </tr>
  
  <tr>
    <td>
      3. Auto-merge
    </td>
    
    <td>
      Opens a ready pull request and turns on auto-merge
    </td>
    
    <td>
      Nothing, unless a check fails or a review is required
    </td>
    
    <td>
      Set <code>
        draft: false
      </code>
      
       in the skill, and allow <code>
        enablePullRequestAutoMerge
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      4. Merge
    </td>
    
    <td>
      Opens and merges its own pull requests
    </td>
    
    <td>
      Read the report
    </td>
    
    <td>
      Allow <code>
        mergePullRequest
      </code>
      
       too
    </td>
  </tr>
</tbody>
</table>

Level 3 lets GitHub decide: [auto-merge](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository) merges the pull request once the branch's required checks and reviews pass. Turn on **Allow auto-merge** in the repository settings, and add the agent's tests as required checks, such as a CI job that runs its [evals](https://eve.dev/docs/evals). Keep a required review, and level 3 merges the moment you approve. Drop it, and the checks alone decide.

Both merge tools take the pull request, not its branch, so their approval policy checks the schedule and the repository:

```ts [agent/extensions/github.ts]
import githubExtension from '@github-tools/eve-extension'
import { isScheduleAuth } from 'eve/schedules'
import type { Approval } from 'eve/tools/approval'

const [owner, repo] = (process.env.AGENT_REPOSITORY ?? '').split('/')

const ownRepositoryOnSchedule: Approval = ({ session, toolInput }) =>
  isScheduleAuth(session.auth.current) && toolInput?.owner === owner && toolInput?.repo === repo
    ? 'not-applicable'
    : 'user-approval'

export default githubExtension({
  connector: 'github/github-agent',
  actAs: 'caller',
  preset: 'auto',
  requireApproval: 'auto',
  overrides: {
    editFiles: {
      approval: ({ session, toolInput }) => {
        const scheduled = isScheduleAuth(session.auth.current)
        const ownRepository = toolInput?.owner === owner && toolInput?.repo === repo
        const agentBranch = typeof toolInput?.branch === 'string' && toolInput.branch.startsWith('agent/')
        return scheduled && ownRepository && agentBranch ? 'not-applicable' : 'user-approval'
      },
    },
    enablePullRequestAutoMerge: { approval: ownRepositoryOnSchedule },
    // Level 4: mergePullRequest: { approval: ownRepositoryOnSchedule },
  },
})
```

Update the skill to match: at level 3, "After opening a pull request, call `enablePullRequestAutoMerge` on it". At level 4, "Merge a pull request with `mergePullRequest` once its checks pass". Branch protection still applies at every level: a merge the repository's rules block fails, whatever the approval policy says.

Each level up trades your review for your checks. Move up once the reports and pull requests at the level below have been right for a few weeks, and only as far as your tests can catch a bad change. A prompt that rewrites itself without anyone looking can drift in ways no single change shows, and at level 4 the weekly report is the only place you'd notice.

## Let the review read tool inputs and outputs

eve decides what a trace records from each session's [audience](https://eve.dev/docs/channels#audience). In production, a public session, such as a public Slack channel, records inputs and outputs. A private or unknown one, such as a direct message or a private channel, records metadata only: which tools ran, when, and for how long, without their inputs and outputs.

From metadata alone, the review still finds failed runs, slow runs and the same tool called many times in one turn. It can't tell whether a retry used the same input, whether an output was much larger than needed, or whether the agent asked a question its instructions answer.

To record inputs and outputs for every session, set the trace policy in `agent/instrumentation/otel.ts`:

```ts [agent/instrumentation/otel.ts]
import { otel } from 'eve/instrumentation/otel'

export default otel({
  tracePolicy: () => ({ emit: true, recordInputs: true, recordOutputs: true }),
})
```

Agent Runs then holds what people wrote in direct messages and private channels, and every project member with trace access can read it. Recording content also keeps the session's stored run data, which eve otherwise deletes when a private run ends. [OpenTelemetry](https://eve.dev/docs/observability/otel) describes the policy, and [Agent Runs](https://eve.dev/docs/observability/agent-runs#redact-content) shows how to redact content from Agent Runs only.

## Troubleshooting

### Every Vercel MCP call fails with `OAuth token request failed`

Vercel Connect couldn't issue the connector's app token. eve passes the model this generic message, so check the cause from the CLI:

- `vercel connect list` shows the connector attached to the project.
- When you created the connector, you signed in with an account that can access the agent's project and granted the team that owns it.

If both hold and Connect reports `invalid_client`, Vercel's token endpoint rejected the connector's app credentials. One tested workaround is a shared grant: every scheduled run and maintainer uses one Connect subject, which a person authorizes once. In the connection, add `createSubject` to the `connect()` call:

```ts [agent/connections/vercel.ts]
return connect({
  connector: 'vercel/github-agent',
  principalType: 'app',
  createSubject: () => ({ type: 'user', id: 'self-review', issuer: process.env.AGENT_PROJECT_ID }),
})
```

The token then acts with the Vercel access of the person who authorized the grant. Three constraints apply when you authorize it:

- The grant belongs to the environment of the OIDC token that started it, so a grant started with your local `VERCEL_OIDC_TOKEN` doesn't work in production. Start it from a production deployment.
- eve never runs a consent flow for an app connection, or in a schedule session, so the agent can't start it for you. Call `startAuthorization('vercel/github-agent', { subject })` from `@vercel/connect` in a production function, with the same subject, and open the URL it returns.
- `vercel connect token --subject app` doesn't work from the CLI, so you can't test an app token before you deploy.

### Every Vercel MCP call returns `403`

The grant doesn't include the team that owns the agent's project. Granting team access is a separate step from signing in. Approve team access for the grant through the Vercel MCP's `authorize_team_access` link, signed in to that team. On a team with SAML SSO, that link starts an SSO session request.

### The review says traces have no tool inputs or outputs

That's the default for private sessions. See [Let the review read tool inputs and outputs](#let-the-review-read-tool-inputs-and-outputs).

### A maintainer gets "Only scheduled runs and maintainers can read this agent's runs"

Their member ID isn't in `MAINTAINERS`, or the project wasn't redeployed after the variable changed. Environment variables apply to new deployments only.

## FAQ

<accordion>
<accordion-item label="Can the agent merge its own pull requests?">

Not with this guide's setup. The override covers `editFiles` only, so `mergePullRequest` keeps asking for approval, and a scheduled run has nobody to approve it. To let it merge, allow auto-merge or merging, as [Choose how much the agent does on its own](#choose-how-much-the-agent-does-on-its-own) describes.

</accordion-item>

<accordion-item label="Why draft pull requests?">

A draft can't be merged until someone marks it ready, so a proposal never lands by accident, and the pull request list shows at a glance which changes came from the review. That makes it the safe default while you learn what the review finds.

</accordion-item>

<accordion-item label="Can I keep the review away from what people wrote?">

Remove `get_agent_run_trace` from `tools.allow`. The review then reads only run metadata, such as status, trigger, model, lifecycle events and token usage. That still finds failed, slow and expensive runs, but not why they happened. To redact content from Agent Runs itself, see [Configure Agent Runs trace content](https://vercel.com/docs/agent-runs#configure-agent-runs-trace-content).

</accordion-item>

<accordion-item label="Does the review cover cost?">

Agent Runs reports tokens, not dollars. The project's spend per model is in the dashboard's [AI Gateway](https://vercel.com/docs/ai-gateway/observability-and-spend/observability) section, under **Requests → Projects**.

</accordion-item>

<accordion-item label="Why not a markdown schedule?">

A [markdown schedule](https://eve.dev/docs/schedules) has no channel, so it discards the reply. The `run` form used here posts to Slack, so you can read the report and continue the conversation in its thread.

</accordion-item>

<accordion-item label="Is there a larger example?">

[Evi](https://github.com/evloghq/evlog/tree/main/apps/evi), the maintainer agent of evlog, runs this loop with more checks: a weekly [self review](https://github.com/evloghq/evlog/blob/main/apps/evi/agent/skills/self-review/SKILL.md) of its repository and its own runs that opens ready pull requests for mechanical fixes, and a weekly cost and model review. Its [`agent/connections/vercel.ts`](https://github.com/evloghq/evlog/blob/main/apps/evi/agent/connections/vercel.ts) is the connection this guide simplifies.

</accordion-item>
</accordion>


## Sitemap

See the full [sitemap](https://github-tools.com/sitemap.md) for all pages.
