Migration

Switching is one line of the Gemfile. Renaming to Agentry can wait until Agentry 5, and a coding agent can do it for you.

From browser

Change one line of the Gemfile, nothing else:

- gem "browser"
+ gem "agentry", require: "browser"

Agentry 4 still answers to the names browser used: require "browser", require "browser/aliases" or require: "browser/browser" (and browser/testing, browser/rails) keep the meaning they had, define Browser as another name for Agentry, and the browser helper of Rails controllers and views still answers. Other browser/* files, such as browser/middleware, are gone: require one of those instead. Keep require: "browser/browser" if the app had it. A bare gem "agentry" leaves out the Browser constant, which then raises NameError. They are deprecated, so move to the new names when you can. Agentry is forked from browser 6.2.0 (dd88933), and every pull request diffs its answers against that version on the 20,328 user agents of the corpus.

What changes on its own

  • More bots, from the day you switch. 600 user agents of the corpus that browser took for humans are bots for Agentry: AI crawlers and assistants (meta-externalagent, Perplexity-User, Claude-User), ad and SEO crawlers, monitors, feed readers, scanners. Analytics that leave bots out count fewer visitors from that day, and anything gated by bot? (a session, a captcha, a cache) treats them as bots. Note the date of the switch next to your traffic charts. Coverage per category.
  • Names for bots. 792 user agents that browser named Generic Bot get the name of their bot. No name browser gave changes.
  • Client Hints in Rails. The Rails helper and the middleware also read the Client Hints Chromium sends with every request. They only move an answer when they contradict the user agent: Chrome for Android asking for the desktop site becomes an Android tablet instead of a Linux desktop. Without the hints (Agentry.new(user_agent, accept_language:), Safari, Firefox), nothing moves. See Client Hints.
  • Nothing else. No bot stops being one, and no browser, platform or device answer moves for a user agent alone. Test drivers (HeadlessChrome, Playwright, Puppeteer, Selenium) stay out of bot?, so the system tests of an app see what they saw.
  • A cache, on by default. Each process keeps the detection of its last 1,000 distinct user agents, about 1 MB. It empties itself when a matcher list or the bot list changes, so code that edits them keeps working.

What you can add

  • Agentry.cache_size = 5_000 to keep more user agents, 0 to turn the cache off. See Options.
  • agentry.bot.category, bot.ai? and bot.user_triggered?, to tell an AI crawler from a search engine, a scanner or an assistant fetching a page for a person. See Categories.
  • agentry.bot.verified?(request.remote_ip), to tell a real Googlebot (or Bing, OpenAI, Apple, Perplexity, DuckDuckGo crawler) from one that only claims to be. See Verified crawlers.
  • agentry.cloudflare, to read the verified bot flag, category, bot score and country Cloudflare knows, through a Transform Rule. See Cloudflare.
  • An Accept-CH: Sec-CH-UA-Platform-Version response header, so that agentry.platform.windows11? and the macOS and Android versions come from Chromium’s Client Hints. See Client Hints.

Moving to the Agentry names

browser, deprecated in Agentry 4Agentry
gem "browser", require "browser"gem "agentry", require "agentry"
require: "browser/browser" (without Rails)require: "agentry/agentry"
require "browser/aliases", "browser/testing", "browser/rails"require "agentry/aliases", "agentry/testing", "agentry/rails"
Browser.new(…), Browser::Bot, Browser::Middleware…Agentry.new(…), Agentry::Bot, Agentry::Middleware…
the browser helper, browser in a middleware blockagentry
@browser, in controllers, views, tests and middleware blocks (no warning)@agentry
config.browserconfig.agentry

Each old name warns once per process, only where Ruby shows deprecations. Run the test suite with them shown to list what is left:

RUBYOPT=-W:deprecated bin/rails test
git grep -nP '\b(module|class)\s+Browser\b|\bBrowser\b(::|\.|\[|\)|,|\s*$)|require.*["\x27]browser|@browser\b|:browser\b|[(,=]\s*browser\b|\bbrowser:|\bbrowser(\.|&\.|\[)|config\.browser'

The grep also finds a local variable named browser: it can keep its name, only the helper call becomes agentry. Names that merely contain the word (SamsungBrowser, :browser_automation) are not old names. Three changes no warning shows: @browser becomes @agentry, in the same change as the browser calls around it (the browser helper fills and reads @browser, agentry only @agentry), class names read Agentry::Chrome even where code calls Browser (check class.name comparisons and marshalled objects), and the Railtie initializer is named "agentry", so before: "browser" or after: "browser" no longer orders anything. Agentry 4 ships the same browser/* files as the browser gem, so it cannot share a bundle with it, for example through a dependency that still needs browser; Agentry 5 drops those files.

From Agentry 3

Only the names change; every answer is the one Agentry 3 gave. One thing breaks: require "agentry" no longer defines Browser. An app with a bare gem "agentry" line that calls Browser either renames those calls to Agentry (see the table), or keeps them a while longer with gem "agentry", require: "browser". An app that requires browser, browser/browser, browser/aliases, browser/testing or browser/rails sees only the deprecation warnings; the other browser/* files Agentry 3 shipped (browser/middleware, browser/version…) are gone. As when coming from browser, class names read Agentry::Chrome, and the Railtie initializer is named "agentry".

With a coding agent

The renaming is mechanical, which suits a coding agent such as Claude Code, Codex or Cursor. Paste this prompt in the app’s repository, then review the diff it leaves:

Migrate this app from the browser gem (or Agentry 3) to Agentry 4 without changing its behavior.
Rules: https://levups.github.io/agentry/migration.html#names

1. In the Gemfile, replace gem "browser" with gem "agentry" (keep any require: option, renamed as below), then run bundle install.
2. Rename the old names to the new ones:
   - require "browser" -> require "agentry"; "browser/browser" -> "agentry/agentry";
     "browser/aliases", "browser/testing", "browser/rails" -> "agentry/aliases", "agentry/testing", "agentry/rails".
   - The Browser constant -> Agentry: Browser.new, Browser::Bot, Browser::Middleware, Browser.cache_size...
   - In Rails controllers, views, helpers and Agentry::Middleware blocks, calls to the browser helper -> agentry.
   - config.browser -> config.agentry.
   - The @browser instance variable the gem filled -> @agentry, in controllers, views, tests
     (instance_variable_set(:@browser, ...), assigns(:browser)) and Agentry::Middleware blocks.
   - Stubs of the browser helper in tests (stubs(:browser), receive(:browser)) -> stubs of agentry.
3. Leave alone: local variables, instance variables or methods the app itself names browser, such as a test
   driver (only what the gem's helper filled or returned changes),
   names that merely contain the word (SamsungBrowser, :browser_automation, "Samsung Browser"),
   fixtures, recorded data, translations and comments that talk about web browsers.
4. Run the test suite with RUBYOPT=-W:deprecated. Fix each "[agentry] ... deprecated" warning it prints, and run it again
   until none is left and the suite is as green as before.
5. Grep for leftovers: git grep -nP '\b(module|class)\s+Browser\b|\bBrowser\b(::|\.|\[|\)|,|\s*$)|require.*["\x27]browser|@browser\b|:browser\b|[(,=]\s*browser\b|\bbrowser:|\bbrowser(\.|&\.|\[)|config\.browser' and check each hit by hand,
   including class.name comparisons ("Browser::Chrome" is now "Agentry::Chrome") and after: "browser" initializers.
6. Do not change any answer the app relies on, add features or refactor. Show me the diff and the list of files you changed.

Going back

Remove the calls to what browser does not have (cache_size=, the headers: argument, bot.category, bot.ai?, bot.user_triggered?, bot.verified?, cloudflare), or they raise NoMethodError. Bring back the browser names of the table, then put gem "browser" back in place of gem "agentry". The bots of the weekly sync go back to being humans, so the analytics shift reverses on that day.

Agentry 5

Agentry 5 removes every old name of the table: the browser/* require paths, the Browser constant, the browser helper, browser in a middleware block, @browser and config.browser. An app whose test suite prints no [agentry] deprecation under RUBYOPT=-W:deprecated, and that no longer uses @browser, upgrades without a change.