Skip to content
Source

Models, keys and triggers

You run the factory for an organization or a repository. You want a better model for the review, your own model key, a token budget for each run, and control over who starts each agent.

The factory settings are on the forge, not in git. A pull request cannot change them. An organization sets values for all of its repositories, and each repository can change any value for itself.

Where the settings are

Settings ofPageWho can change them
An organization/organizations/<org>/factory, the Software factory tabThe owners of the organization
A repository/<owner>/<repo>/agents/factory, from Agents, then Open factory settingsThe admins of the repository

The Software factory tab of the organization acme, next to General, People, Teams, Roles and Bans, with the Factory settings for every repository of acme.

Each value on the repository page shows where it comes from:

  • Default, or Inherited from and the name of the organization: you did not set it here.
  • Set on this repository: you set it here. Click Use the org value (or Use the default) to remove it.

The Security audit agent on the Factory settings page of acme/app. Each value has an Inherited from acme badge.

1. Pick who starts each agent

Each agent has Who starts it:

ChoiceThe agent runs for
OffNobody.
When an item has a labelIssues and pull requests that have the label that you type.
Authors with a role or higherAuthors with this role or a higher one: read, triage, write, maintain or admin.
EveryoneEvery author.

Use this agent turns the agent on or off for all authors. The Security audit, Architecture and PR impact are on by default. Every other agent is off by default.

Some rules are not settings. They hold whatever you pick:

  • For an author without write access, the fixer and the conflict fixer run only after a clean audit.
  • While investigate is on, the label factory:investigate starts it on an issue, whatever its trigger.
  • Who starts it does not change when Architecture runs. Only a push or a merge to the default branch starts it, or a person who clicks Generate now.

The two agents on by default that are not checks

These two agents only describe the code. They never hold back a pull request, and they push nothing.

AgentWhat it doesWhen it runsWhere you see it
ArchitectureWrites an overview, a card for each package and diagrams of the repositoryAfter a push or a merge to the default branch that changes the architectureThe Architecture tab of the repository. See Read the architecture of a repository.
PR impactSays if a pull request changes the architecture or the public API, and howWhen a pull request opens, and on each push to it. Who starts it appliesThe Impact tab of the pull request. See Read the Impact tab.

Before each run, code and Cloudflare's decision model clef-flash decide if the change needs one. A change to only docs, tests, generated files or assets starts no run.

2. Pick a model

Each agent has a Model provider and a Model. The default is Workers AI with the model @cf/zai-org/glm-5.3-flash, which the forge pays for.

Architecture and PR impact read a whole pull request or repository in one call. When the forge has an AI Gateway set up, their default is OpenAI's GPT-6 Luna (openai/gpt-6-luna on Workers AI) with high reasoning, which the forge also pays for. You can type another Workers AI model name the same way, for example another provider/model from the AI Gateway catalog. Settings that you saved before keep the model that you saved.

The providers are:

  • Workers AI (paid by the forge, no key)
  • Anthropic, OpenAI, OpenRouter, Grok, Mistral
  • Amazon Bedrock, Vercel AI Gateway, Lovable AI Gateway

Type the model name of the provider, for example claude-sonnet-4-5 for Anthropic. The forge calls the host of the provider. You cannot send a model call to another host.

3. Add a model key

Every provider but Workers AI needs a key.

  1. On the factory settings page, go to Provider keys.
  2. Pick the Provider, and paste the Key.
  3. Click Save key.

The Provider keys card: one Anthropic key, saved just now, with a Delete button, and the form to add a key. The page never shows a key.

A key stays on the forge:

  • Nobody can read a key back, not even an admin. The page shows only the provider and when you saved it.
  • The model runs on the forge. The agent's sandbox never gets the key.
  • A repository key wins over the organization key for the same provider.
  • An organization key is for every repository of the organization that has no key of its own.

If an agent uses a provider that has no key, its runs fail with "There is no ... key". The message names the provider and the repository.

4. Set a budget

Most tokens for one run stops an agent when it uses this many tokens. The run shows Failed, with the reason. Use a whole number from 1 to 2,000,000.

AgentDefault tokens for one run
Security audit200,000
Value check100,000
Fixes-the-issue check, review, investigate, Architecture300,000
PR impact200,000
Fixer, Auto PR, CI self-heal500,000
Conflict fixer200,000
Triage50,000
Spam30,000

The forge pays for 2,000,000 Workers AI tokens for each user or organization in a UTC month. After that, runs on Workers AI are skipped with "Workers AI monthly cap reached". Runs on your own key do not count.

5. Set the rules for all agents

The card Rules for all agents has the settings of the whole factory:

SettingDefaultRange
Auto-mergeOffOn or off. See Ready to merge.
Runs per author each day201 to 1,000. For authors without write access.
Review rounds31 to 10. How many times the fixer runs for one push.
Days to wait on needs-info71 to 365. See Issue agents.
Ban policy, A ban applies toBan only on hard proof, the repository onlySee Spam and bans.
Custom agents come fromThe vaultSee Custom agents.
Secrets for the package installNoneThe CI secrets that the install of .source/factory.ts can use, for a private package registry. See A private package registry.

Click Save rules.

Done

Each agent runs with the model, the budget and the trigger that you picked. Your model keys stay on the forge.

With the CLI

The src CLI has the same settings. Repository admins and organization owners can use it. Add --org <org> to act on an organization, not on the repository of the current folder.

src factory settings
src factory set-key anthropic < anthropic-key.txt
src factory keys
src factory configure --file change.json

set-key reads the key from standard input, so the key stays out of your shell history. To remove a key, run src factory delete-key anthropic.

change.json holds only the fields that you change. null removes a value, so the inherited value holds again. This change turns the review on, moves it to Anthropic and to the mode Fix to ready, and removes the repository's own Review rounds:

{
  "agents": {
    "review": {
      "enabled": true,
      "mode": "fix-to-ready",
      "model": { "provider": "anthropic", "model": "claude-sonnet-4-5" },
      "budget": { "maxTokens": 400000 }
    }
  },
  "reviewRounds": null
}

The fields and the routes are in Install and set up the CLI, Use the REST API and Connect over MCP.