Docs
GitHub

eve

Give an eve agent the GitHub tools, instructions on how to use them, and an approval policy from one file.

Beginner14 min read

Overview

@github-tools/eve-extension is an eve extension that gives an eve agent the GitHub tools, a system instruction on how to use them, and an approval policy for every write tool, from one file under agent/extensions/.

Pick it when you build an eve agent. eve keeps approvals on the server, pauses the session until someone answers, asks users to sign in when a call needs their own GitHub access, and resumes after a crash, so you don't wire any of that yourself.

Install

pnpm add @github-tools/eve-extension eve ai

The whole agent is three files:

import { defineAgent } from 'eve'

export default defineAgent({
  model: 'anthropic/claude-opus-5.5',
})

Without a connector, the tools read GITHUB_TOKEN. Run npx eve dev and ask about a pull request. The agent reads with the code-review tools and stops before every write until someone approves it. examples/eve is the same agent with a Vercel Connect connector and 'auto' modes.

Choose the tools

The mount file's name becomes the tool prefix: agent/extensions/github.ts exposes github__listPullRequests, github__createIssue and so on. Config keys such as include and requireApproval take the bare names.

preset sets which tools the model sees. include adds to the preset, so { preset: 'code-review', include: ['createIssue'] } keeps the review tools and adds one write. Without a preset, include is the whole set. exclude removes tools from the result, after preset and include: { preset: 'maintainer', exclude: ['deleteGist'] }.

Let the model pick the tools

With preset: 'auto', the decision model picks the tools the session's first request needs, and eve lists those and the core read tools. Every other tool is deferred: it's out of the tool list, but the model can still find it with eve__search.

The pick is stored with ctx.memo, so it stays fixed for the session and across processes. Set evaluation.scope: 'turn' to pick again for each request, or evaluation.selection: 'presets' to route to at most two presets instead.

Approval

Every write tool asks by default. An approval pauses the session durably until someone answers. The prompt names the action and target, such as Merge pull request on vercel-labs/github-tools#176?, and after a write the channel shows Created issue on vercel-labs/github-tools#212. owner, repo and the number fall back to context when the call leaves them out.

With 'auto', the prompt also ends with the decision model's verdict, such as Add labels on vercel-labs/github-tools#12? Hard to undo (risk 2 of 2), 100% likely you asked for it. A call it lets through has clearedBy: { policy: 'approval' } on its call.started event, so you can tell automatic approvals from calls that needed none. eve doesn't keep the verdict of an automatic approval.

requireApproval takes one value for all write tools, or one per tool:

ValueWhat happens
true or 'always'Asks on every call
false or 'never'Never asks
'once'Asks the first time in a session, then runs without asking
'auto'The decision model approves routine writes the user asked for
a functionAn eve approval policy over toolInput and the session. Return true to ask
{ request, response }An eve approval object, when you also decide who may answer

This agent asks once per session before commenting, and asks before a merge only outside vercel-labs:

agent/extensions/github.ts
export default githubExtension({
  preset: 'code-review',
  requireApproval: {
    addPullRequestComment: 'once',
    mergePullRequest: ({ toolInput }) => toolInput?.owner !== 'vercel-labs',
  },
})

Add your own approval policy

An approval policy in agent.ts runs next to the extension's, and eve keeps the stricter result. It can add a gate but never remove one. Match the GitHub tools by prefix, as in toolName.startsWith('github__').

Limit where calls act

guardrails limit the repositories and branches any call can reach, whoever approves it. A write outside them is denied with the reason, such as "vercel/next.js is outside the repositories these tools may act on", before anyone is asked:

agent/extensions/github.ts
export default githubExtension({
  preset: 'pr-author',
  guardrails: { repositories: ['vercel-labs/*'], branches: ['agent/*'] },
})

They cover the extension's tools only. eve's git extension runs gh through git__gh without an approval prompt, so limit it with its own github.authorize check.

Set dryRun: true to try an agent on real repositories first: reads run, no write reaches GitHub, and the channel label reads "Would create issue on owner/repo". See Shadow mode.

Use Vercel Connect

A connector replaces the long-lived token: each call mints a short-lived token scoped to the selected tools. With preset: 'auto', each token covers only the tool being called. Install @vercel/connect:

pnpm add @vercel/connect

Then pass the connector name instead of a token:

agent/extensions/github.ts
export default githubExtension({
  connector: 'github/my-connector',
  preset: 'code-review',
})

Auth covers creating the connector, and the permissions each preset needs. The token asks for the scopes of every selected tool, so the GitHub App needs all of them. code-review, ci-ops and maintainer include createCommitStatus, which needs Commit statuses (read and write). If your App doesn't have it, exclude: ['createCommitStatus'] removes the tool and its scope together.

Per-user tokens

By default every call uses the GitHub App's installation token, so anyone who can talk to the agent can do what the App can. actAs picks whose access a call uses:

actAs
Turn from
A

Ada

signed in, can merge

Ada's GitHub token

user token

acme/web#128

merged by ada, with the acme-agent badge

Merged
actAs picks whose token runs the call. GitHub checks that person or the App, and records them as the one who merged.
actAsA signed-in user drives the turnSomeone comments on GitHubNobody does: a schedule, localDev(), a bot
'app' (default)The AppThe AppThe App
'user'The user's own tokenWaits for a sign-in GitHub can't showFails with principal_required
'caller'The user's own tokenThe App, within the commenter's roleThe App

This agent reads as the App, writes as the user when there is one, and always merges as the user:

agent/extensions/github.ts
export default githubExtension({
  connector: 'github/my-connector',
  actAs: { read: 'app', write: 'caller' },
  overrides: { mergePullRequest: { actAs: 'user' } },
})

GitHub runs a user-token call only when both the user and the App have access, so a reader who asks for a merge gets GitHub's 403. GitHub shows the action as the user, with the App's badge.

A user who hasn't authorized the App gets an eve sign-in prompt, and the call resumes after they authorize. Someone who can sign in never falls back to the App token. eve stores each user's token separately and never hands it to another user.

Someone who comments on GitHub can't sign in: every comment there is public, so eve's GitHub channel has nowhere to show the prompt. GitHub has already identified them, so with 'caller' their calls run with the App's token, limited to their own role:

  • Before each call, the extension reads the commenter's role on the repository the call targets. A read needs Read and a write needs Write, so someone who can write to one repository can't have the agent read another one they can't see.
  • A refused call fails with CALLER_FORBIDDEN before it reaches GitHub, and the message names the role they have and the one the call needs.
  • resolveReviewThread names no repository, so the extension looks up the one the thread is in and needs Write there.
  • A search runs only when the App's token reaches the thread's repository and no other, so it can't return results from a repository the commenter can't see. Each token is requested for that repository, and the extension asks GitHub what the token reaches before it searches. A connect config that pins an installation or several repositories widens the token, and the search is then refused.
  • Every other tool without a repository is refused, since no role on a repository covers it: gists, notifications, createRepository and forkRepository.

The check is stricter than GitHub for the writes a reader can make themselves, such as a comment or a new issue. GitHub shows the action as the App.

Who can approve

Only the person who asked for a call can approve it, so a colleague in a shared Slack thread can't approve your merge. Set approvers: 'anyone' to let any signed-in user approve and anyone deny. For 'user' and 'caller' tools, the approved call then runs with the approver's token, after they sign in. For 'app' tools, the approval only gates the call. On GitHub, a 'caller' call someone else approved runs as the App within the approver's role, with no sign-in.

For a custom rule, pass { request, response } for that tool in requireApproval, with an eve response policy. It replaces both defaults, and the sign-in checks still apply to the people it allows.

Credit the App

When a call runs with a person's token, GitHub records that person as its author. So the extension credits the App on what it wrote for them:

  • createPullRequest, and editFiles when it opens a pull request, end the pull request body with a line naming the App, the person, and where they asked from: Generated by [Evi](https://github.com/apps/evlogai) for @HugoRCD from a [Slack thread](https://app.slack.com/client/…).
  • createOrUpdateFile, editFiles, mergePullRequest and enablePullRequestAutoMerge add the App's bot account to coAuthors, so the commit message ends with Co-authored-by: <app>[bot] <id+<app>[bot]@users.noreply.github.com>. GitHub links that address to the bot account.

When you squash-merge a person's pull request, GitHub adds each commit author other than the pull request's author as Co-authored-by. Commits the App wrote, for example through eve's git extension, therefore credit it on the squash commit without this option.

The App is read from the person's token, once per process, so the connector must be backed by a GitHub App. Calls that run as the App add nothing, since GitHub already shows the App as their author. Set attribution: false to turn both credits off, or coAuthor: false to keep only the footer.

footer also takes a template of your own. The extension fills its tokens from each call, and the line still goes after a --- rule at the end of the body. The default is Generated by {app} for {requester} from {origin}.

TokenValue
{app}The App as a link, [<display name>](https://github.com/apps/<slug>)
{app.name}The App's display name. A private App, which GitHub hides from user tokens, shows its slug
{requester}The person whose token runs the call, as @<login>. Costs one GET /user call per pull request
{channel}The channel's name: Slack, Linear, GitHub, Microsoft Teams, Discord, Telegram, the API, or the channel's file name
{origin}Where the request came from: a [Slack thread](…) linking the thread, Linear issue EVL-815, or else the channel's name

Slack and Linear are recognized from the channel's metadata, not its file name. The Slack link is built from the thread's workspace, channel and timestamp, so it needs no Slack API call. Linear doesn't tell the extension the workspace's URL, so its issue is named, not linked.

agent/extensions/github.ts
export default githubExtension({
  connector: 'github/my-connector',
  actAs: 'caller',
  attribution: { footer: 'Opened by {app.name} in {channel} for {requester}.' },
})

An unknown token fails when the extension mounts. For anything a template can't say, pass a function that gets the App (slug, name, login, id) and returns the line.

Work across several installations

An App installed on several accounts needs no config. Each App token is minted for the installation that owns the call's owner/repo, after context defaults. Tools without a repository, such as searchCode and the gist tools, use the connector's default installation.

To pin one installation, set installationId, authorizationDetails or repositories in connect. For another rule, pass a resolver:

agent/extensions/github.ts
export default githubExtension({
  connector: 'github/my-connector',
  connect: (ctx, call) => ({
    installationId: call.owner === 'hugorcd' ? 'inst_personal' : undefined,
  }),
})

Run on eve's GitHub channel

When the agent runs on eve's GitHub channel, the extension fills context from the thread: the repository, and the issue or pull request number. The model can leave them out of tool calls, approval prompts and labels name the thread, guardrails check the filled-in target, and the system prompt says which thread the agent is in. Fields you set in context take precedence, and turns from other channels are unchanged.

Choose who the agent answers

By default, anyone who mentions the bot starts a turn, including on a public repository. githubChannel from @github-tools/eve-extension/channels is eve's githubChannel with one more option, respondTo:

agent/channels/github.ts
import { connectGitHubCredentials } from '@vercel/connect/eve'
import { githubChannel } from '@github-tools/eve-extension/channels'

export default githubChannel({
  credentials: connectGitHubCredentials('github/my-agent'),
  respondTo: 'writers',
})

The values are named after GitHub's repository roles, and each one means that role and everyone above it:

respondToWho the agent answersGitHub role
'anyone' (default)Anyone who can commentNone needed
'triagers'Triagers, writers, maintainers and adminsTriage and above
'writers'Writers, maintainers and adminsWrite and above
'maintainers'Maintainers and adminsMaintain and above
'admins'AdminsAdmin

The channel reads the commenter's role on the thread's repository before a comment starts or continues a turn. A comment from anyone below respondTo does nothing: no reaction, no session and no model call, so a stranger can't spend your model budget. A custom role counts as the base permission GitHub reports for it.

Every other option is eve's and passes through. With your own onComment, the role is checked for the comments it dispatches. respondTo applies to comments only: onIssue, onPullRequest and the CI hooks decide for themselves.

respondTo decides who can talk to the agent, and actAs: 'caller' what a turn can do for them, on every repository it touches. An agent on the GitHub channel needs both. Approval, 'auto' and guardrails still apply to whatever a turn does.

Scheduled runs

A markdown schedule has no channel, so a tool that needs approval fails the session instead of waiting. Let the writes a schedule makes run without asking only in scheduled sessions, and keep asking in interactive ones:

agent/extensions/github.ts
import githubExtension from '@github-tools/eve-extension'

const unlessScheduled = ({ session }: { session: { schedule?: unknown } }) => session.schedule === undefined

export default githubExtension({
  preset: 'issue-triage',
  guardrails: { repositories: ['acme/*'] },
  requireApproval: {
    addLabels: unlessScheduled,
    addIssueComment: unlessScheduled,
  },
})

Pair it with guardrails, and try the schedule with dryRun: true first.

Config

FieldTypeWhat it does
tokenstring | () => Promise<string>GitHub token or token provider. Defaults to GITHUB_TOKEN when connector isn't set
connectorstring | () => string | Promise<string>Vercel Connect connector name, or a resolver that picks one per call. Wins over token
actAs'app' | 'user' | 'caller' | { read, write }Whose GitHub access a call uses with a connector. Default 'app'. See Per-user tokens
approvers'requester' | 'anyone'Who may answer an approval. Default 'requester'. See Who can approve
attributionboolean | { footer?: boolean | template | (app) => string, coAuthor? }Credit the App on pull requests and commits that run with a person's token. Default true, with the footer Generated by {app} for {requester} from {origin}.. See Credit the App
connectobject | (ctx, call) => objectConnect token params for App tokens, such as installationId, repositories or scopes. Can't be combined with actAs: 'user'
presetpreset name, array, or 'auto'Which tools the model sees. See Presets
includetool namesAdded to the preset, or the whole set without one
excludetool namesRemoved after preset and include
context{ owner?, repo?, pullNumber?, issueNumber?, ref? }Defaults for tool inputs. See Context
requireApprovalboolean | 'auto' | { [writeTool]: value }Approval for write tools. See Approval
guardrails{ repositories?, branches?, secrets? }Where any call may act, whoever approves it. A blocked write is denied with the reason instead of asking. See Guardrails
dryRunbooleanShadow mode: reads run, no write reaches GitHub, and nobody is asked to approve one. See Shadow mode
evaluationobjectTunes both 'auto' modes: model, maxRisk, minIntent, selection, scope, minToolProbability, maxTools, minPresetProbability, maxPresets, providerOptions
overrides{ [tool]: { description?, approval?, actAs?, toModelOutput?, outputSchema? } }Per-tool changes. approval takes the same values as requireApproval
author, committer, coAuthors{ name, email }Commit identity for tools that commit. See Commits

eve checks the config against the extension's schema, so a misspelled tool name in requireApproval, or actAs: 'user' without a connector, fails instead of being ignored.

FAQ