What the agent does
go-redis v9 lives at a new module path, github.com/redis/go-redis/v9, so no dependency bot proposes it as an update to github.com/go-redis/redis/v8. Someone has to change the imports, and the question is what else changes with them. The agent answers that for the code in front of it. In a service like flashbots/rpc-endpoint, go.mod requires github.com/go-redis/redis/v8 v8.11.5 and a single file imports it, server/redisstate.go. That file creates the client with redis.NewClient(&redis.Options{Addr: redisUrl}), calls Get, Set, Del, Expire, LPush, LRange and LTrim, and compares errors with redis.Nil in eight places. It sets no pool options, registers no hooks and uses no pipelines, which are the areas where v9 changed names and interfaces.
Before editing, the agent runs go test ./server/ to get a baseline. Then it changes the import and runs go get github.com/redis/go-redis/v9@latest, and here the first real decision appears. The newest v9 release declares a minimum Go version above the go 1.22.0 line and toolchain go1.23.6 in this go.mod. With default settings the go command would fetch a newer toolchain and raise those lines, and a one-line import change becomes a Go upgrade for everything that builds the module. The agent does not let that happen silently. It finds the newest v9 release that keeps the existing go directive, uses that, and reports both options with what each would change in go.mod.
With the chosen release, go build ./... succeeds with no further edits and the tests pass. The agent still reads the test timing, because v9 behaves differently at the edges. TestRedisStateSetup constructs the state against localhost:18279, where nothing listens, and expects an error. On v8 that returns at once. On v9 the pool retries the dial five times first, logging redis: connection pool: failed to dial after 5 attempts, and the test takes about two seconds. The same retry applies in production to a startup check against a Redis that is down, so the agent calls it out for whoever owns the health checks and timeouts.
It also covers what compiles but deserves a look. v9 starts each connection with a HELLO handshake to negotiate RESP3; the tests here run against an old in-memory miniredis and still pass, and the agent notes that a proxy or managed service that rejects HELLO can be handled by setting Protocol: 2 in the options. The err == redis.Nil comparisons keep working, and the agent offers errors.Is(err, redis.Nil) as an optional follow-up without mixing it into this change.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Migrate this Go module from github.com/go-redis/redis/v8 to github.com/redis/go-redis/v9. First run the existing tests and record the result and the time each package takes. List every file that imports go-redis or one of its extra packages (redisotel, redisprometheus, rediscensus, redis_rate, redsync adapters and similar) and what each uses: client constructors and options, commands, pipelines and transactions, pub/sub, hooks, scripts, and error comparisons. Change the import paths. When choosing the v9 version, check its go directive against this module's go and toolchain lines: if the newest release would raise them, do not accept that silently; find the newest v9 release that builds with the current directive, use it, and report both choices. Fix what no longer compiles and list each kind of change: renamed options (IdleTimeout to ConnMaxIdleTime, MaxConnAge to ConnMaxLifetime, IdleCheckFrequency removed), the new hook interface (DialHook, ProcessHook, ProcessPipelineHook), removed methods, and changed command signatures. Move extra packages to their v9 module paths and make sure no v8 import remains in go.mod or go.sum. Run go build, go vet and the tests, compare results and per-test timing with the baseline, and explain any test that became slower or changed behaviour, especially around connection failures and retries. Report whether the code depends on RESP2 behaviour and whether Protocol: 2 should be set. Do not change application logic. Open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that, for rpc-endpoint, changes one import line in server/redisstate.go plus go.mod and go.sum. Small diffs like this get approved without reading, so the description does the work: the inventory of what the code uses from the library, the statement that none of the renamed options or hook interfaces are involved, and the build, vet and test results beside the baseline.
Two notes are set apart for a decision. The first is the version choice, with the chosen release, the newest release, and the Go version the newest one would require. The second is the dial retry, with the test that revealed it and the before and after timing. If the service has a startup probe with a short timeout, this is the paragraph that prevents a surprise.
A reviewer confirms go.sum no longer lists the v8 module, checks that the go and toolchain lines are unchanged if that was the intent, and decides whether to take the newer release together with a Go upgrade in a separate pull request.
Run it on every Go repository that imports go-redis v8
Because the module path changed, this upgrade never arrives on its own, and in a company with many services it has to be pushed. GET /o/{org}/github lists the repositories your GitHub App installations can reach. Filter that list to the ones whose go.mod names github.com/go-redis/redis/v8, and send POST /o/{org}/sessions once per repository with the body above. Add a request_id that is a UUID v5 of the repository's full name, so a second pass over the list returns the runs that already exist.
Give the API key a webhook_url and each finished run reports there with run.completed or run.failed. Services that share an internal Redis helper package should go after that package is migrated, since their own diff will then be only a version bump.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
On paper this migration is a find and replace, and for much code it nearly is. What a find and replace cannot tell you is which v9 release your toolchain can build, or that a connection failure now takes seconds to surface where it took none. Both come from running the commands: go get against the real module graph, and the test suite with timing read against a baseline. The agent does that in its own sandbox and the output of each command stays in the session transcript.
The sandbox matters for the version question in particular. A laptop with a recent Go installed, or with automatic toolchain downloads on, accepts the newest release without complaint and rewrites go.mod on the way. The discrepancy then shows up in CI or in a container build pinned to an older Go. A run that checks the module's own go directive first reports the conflict before anyone merges it.
Frequently asked questions
Why doesn't Dependabot or Renovate offer go-redis v9?
In Go, a new major version is a different module path, and v9 also moved from the go-redis organisation to redis. To a dependency bot, github.com/redis/go-redis/v9 is an unrelated module, not an update to github.com/go-redis/redis/v8. The imports have to be changed by hand or by an agent.
Is changing the import path enough?
For code that only creates a client and runs commands, often yes. Code that sets pool options such as IdleTimeout or MaxConnAge, implements hooks, or imports extra packages such as redisotel needs edits, because those names and interfaces changed. The compiler finds all of these; behaviour changes it cannot find are the reason to rerun tests.
Do I have to upgrade Go to use go-redis v9?
It depends on which v9 release you take. Each release declares a minimum Go version in its own go.mod, and recent ones require a newer Go than early ones. If your module must stay on its current Go, choose the newest release whose requirement you meet and plan the rest with your next Go upgrade.
Does redis.Nil still work?
Yes. A missing key still returns redis.Nil, and err == redis.Nil still compiles and matches. errors.Is(err, redis.Nil) is the more robust form if any layer wraps errors, and it can be adopted later without affecting this migration.
What is RESP3 and can it break my setup?
RESP3 is the newer Redis wire protocol, and v9 asks for it when it connects. Redis 6 and later accept it. If something between your service and Redis does not, such as an older proxy, set Protocol: 2 in redis.Options to keep the previous protocol.
More jobs like this: Upgrade dependencies weekly
- Replace mattn/go-sqlite3 With modernc.org/sqlite for a cgo-Free Go Build (go-sqlite3)
- Migrate From gopkg.in/yaml.v2 to yaml.v3 in a Go Project (go-yaml)
- Migrate From github.com/golang/protobuf to google.golang.org/protobuf (golang/protobuf)
- Replace Deprecated golint With revive, go vet and staticcheck in a Go Project (golint)
- Migrate a Custom Environment From OpenAI Gym to Gymnasium (OpenAI Gym)
- Migrate From the Deprecated @hapi/joi Package to joi (@hapi/joi)