eve
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
npm install @github-tools/eve-extension eve ai
yarn add @github-tools/eve-extension eve ai
bun 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',
})
You are a GitHub assistant. Inspect pull requests and issues, and say what you changed.
import githubExtension from '@github-tools/eve-extension'
export default githubExtension({
preset: 'code-review',
})
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:
| Value | What 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 function | An 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:
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:
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
npm install @vercel/connect
yarn add @vercel/connect
bun add @vercel/connect
Then pass the connector name instead of a token:
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:
Ada
signed in, can merge
Ada's GitHub token
user token
acme/web#128
merged by ada, with the acme-agent badge
actAs | A signed-in user drives the turn | Someone comments on GitHub | Nobody does: a schedule, localDev(), a bot |
|---|---|---|---|
'app' (default) | The App | The App | The App |
'user' | The user's own token | Waits for a sign-in GitHub can't show | Fails with principal_required |
'caller' | The user's own token | The App, within the commenter's role | The App |
This agent reads as the App, writes as the user when there is one, and always merges as the user:
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_FORBIDDENbefore it reaches GitHub, and the message names the role they have and the one the call needs. resolveReviewThreadnames 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
connectconfig 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,
createRepositoryandforkRepository.
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, andeditFileswhen 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,mergePullRequestandenablePullRequestAutoMergeadd the App's bot account tocoAuthors, so the commit message ends withCo-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}.
| Token | Value |
|---|---|
{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.
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:
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:
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:
respondTo | Who the agent answers | GitHub role |
|---|---|---|
'anyone' (default) | Anyone who can comment | None needed |
'triagers' | Triagers, writers, maintainers and admins | Triage and above |
'writers' | Writers, maintainers and admins | Write and above |
'maintainers' | Maintainers and admins | Maintain and above |
'admins' | Admins | Admin |
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:
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
| Field | Type | What it does |
|---|---|---|
token | string | () => Promise<string> | GitHub token or token provider. Defaults to GITHUB_TOKEN when connector isn't set |
connector | string | () => 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 |
attribution | boolean | { 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 |
connect | object | (ctx, call) => object | Connect token params for App tokens, such as installationId, repositories or scopes. Can't be combined with actAs: 'user' |
preset | preset name, array, or 'auto' | Which tools the model sees. See Presets |
include | tool names | Added to the preset, or the whole set without one |
exclude | tool names | Removed after preset and include |
context | { owner?, repo?, pullNumber?, issueNumber?, ref? } | Defaults for tool inputs. See Context |
requireApproval | boolean | '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 |
dryRun | boolean | Shadow mode: reads run, no write reaches GitHub, and nobody is asked to approve one. See Shadow mode |
evaluation | object | Tunes 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
ai 7, which eve itself needs.'auto' always asks in a subagent, and for a service caller too, because their latest message wasn't written by a person.agent/tools/ with the same name, such as github__createIssue.ts, replaces the extension's.defineDynamic function that eve runs before every model call, so tools, schemas and approval policies are rebuilt from the config each time, including after a Workflow replay.failed and gives the model the error as the call's result. Hooks, instrumentation and noFailedCalls() in an eval see the failure. Errors the SDK recognizes carry a code, a cause and a fix from the error catalog, and call.settled has the code in error.code.rateLimit for your hooks and channels, and the extension strips it from what the model sees.closeIssue on a closed issue, createBranch at the same SHA and createOrUpdateFile with unchanged content and sha, but not for createIssue, addIssueComment or mergePullRequest, and approval doesn't deduplicate them.code-review, over maintainer or repo-explorer.connect only configures App tokens.401 for a user's token, eve asks that user to sign in again. A turn started by a schedule never opens a sign-in, so a call that needs one fails with sign_in_unavailable.github_tools.CONNECT_INSTALLATION_REQUIRED, naming that account.actAs default may change to 'caller' in a future major version.