Docs pages

Use hosted agents

A hosted agent is an agent that refs runs for you. You do not connect it from a terminal, and it is always available. You mention it on a pull request, it reads the code, and it answers with one comment. This document shows you how to ask a hosted agent, and how admins add, customize and remove them.

Before you begin

  • Be a member of the namespace that owns the repository.
  • To change agents, be an owner or admin of the namespace, or an admin of the repository.

Where agents come from

A repository can use agents from three levels:

Level Label Who changes it Where
Built in Built in refs Every repository. See Built-in agents.
Namespace Shared Namespace owners and admins Settings > Agents. Every repository in the namespace gets it.
Repository This repository Repository admins The Agents tab of the repository.

When two levels have an agent with the same handle, the repository agent replaces the shared agent, and a shared agent replaces the built-in agent. The Agents tab shows a replaced agent as Replaced here.

Built-in agents

Handle What it does
@reviewer Reviews the pull request and lists real problems, the most severe first.
@security Looks for security holes: missing checks, injection, and leaked secrets.
@tests Finds changed behavior that no test covers, and weak tests.
@perf Finds slow paths: queries in loops, extra round trips, and unbounded work.
@explain Explains what the change does, or answers a question about the code.
@docs Finds docs that the change makes wrong or leaves out.

To change what a built-in agent does in one repository, customize it. See Customize an agent for one repository.

Ask an agent

  1. In a pull request comment or review thread, click Mention agent and select the agent. refs inserts @handle. You can also type it yourself.
  2. Optional: add a question, for example @reviewer is the retry safe if the queue sends a message twice?
  3. Post the comment.

The agent reads the diff and the code at the head of the pull request. For TypeScript and JavaScript, it also uses the code map to find the code that calls each changed declaration. It answers with one short comment at the same place: at most five points. The comment shows the agent, the commit and the model. The pull request timeline shows the state of the run: working, answered, or not finished, with the reason. Hold the pointer on the agent's name to see its model, the state of the run and its current step. Click the name to see the steps on the Agents tab.

A hosted agent acts for the person who mentioned it. It can read the repository and post one comment. It cannot push, take a branch, approve, or mention other agents. Each mention starts a new run, and the agent does not remember earlier runs.

refs does not start an agent when the mention is in a code block or inline code, or when an agent writes the mention.

Run an agent from CI

To run an agent on each pull request, add an agent job to .refs/ci.yml:

jobs:
  review:
    agent: reviewer
    prompt: Check the change for missing error handling.

The agent answers on the pull request, and the job shows the result on the Runs tab. For each key, see Agent jobs.

See what agents do

The Activity section of the Agents tab lists the last 20 runs of the repository's agents. Each run shows the agent, the pull request, the person it acts for, and CI when a CI job started it.

While a run works, the page shows each step as it happens: the tools that the agent calls, and its thinking when the model shares it. To see the steps of a finished run, click Show thinking.

Add an agent

  1. Open the Agents tab of the repository. For an agent that every repository gets, go to Settings > Agents.
  2. Click Add agent.
  3. In Handle, type the name that people mention, for example security. A handle is 2–32 characters: lowercase letters, digits and -.
  4. In Description, write what the agent does in one line.
  5. In Instructions, write what the agent does when someone mentions it.
  6. In Model, keep Workers AI (default), or select a provider. See Choose the model.
  7. Click Save agent.

Customize an agent for one repository

  1. Open the Agents tab of the repository.
  2. Next to a shared or built-in agent, click Customize.
  3. Change the description, the instructions or the model.
  4. Click Save agent.

Your copy replaces the original in this repository only. To go back to the original, click Remove on your copy.

Choose the model

By default, an agent runs GLM-5.3 on Workers AI, and refs pays for it. To use a different model, give the agent its own API key:

  1. In Model, select Anthropic, OpenAI or OpenRouter.
  2. In Model ID, type the ID that the provider uses, for example claude-sonnet-5-5, gpt-5.5 or anthropic/claude-sonnet-5-5.
  3. In API key, paste the key.
  4. Click Save agent.

refs sends one short request to test the key and the model. If the provider refuses them, refs shows the reason and does not save the agent. refs stores the key encrypted. No one can read it back, admins included. The list shows only the last four characters.

Each run of the agent uses this key, no matter who mentions the agent. When you edit the agent later, leave API key empty to keep the saved key.

Remove an agent

On the Agents tab or on Settings > Agents, click Remove next to an agent of that level. You cannot remove a built-in agent. To change one, customize it.

What's next