What the agent does
The agent starts in its own cloud sandbox with the repository cloned and reads everything that touches the token before it swaps the library. In an app like HackSoftware/Django-Styleguide-Example (Django 5.2.7, djangorestframework 3.16.1, drf-jwt 1.19.2 in requirements/base.txt), config/settings/jwt.py builds a JWT_AUTH dict: a JWT_GET_USER_SECRET_KEY pointing at auth_user_get_jwt_secret_key, a JWT_RESPONSE_PAYLOAD_HANDLER that returns {"token": token}, a JWT_EXPIRATION_DELTA of seven days from JWT_EXPIRATION_DELTA_SECONDS, JWT_ALLOW_REFRESH set to False, and a cookie named by JWT_AUTH_COOKIE (default jwt), secure, SameSite=Lax, with a Bearer header prefix. rest_framework_jwt sits in THIRD_PARTY_APPS in config/django/base.py.
The interesting part is what the per-user secret is for. styleguide_example/users/models.py gives BaseUser a jwt_key UUID, services.py in the authentication app signs each token with it, and auth_logout rotates it, so logging out invalidates every token that user holds. styleguide_example/authentication/apis.py has UserJwtLoginApi subclassing drf-jwt's ObtainJSONWebTokenView and turning its 201 into a 200, UserJwtLogoutApi calling auth_logout and deleting the cookie, and UserMeApi; styleguide_example/api/mixins.py lists JSONWebTokenAuthentication third in ApiAuthMixin.authentication_classes, after the two session-based classes. The tests in styleguide_example/authentication/tests/apis/test_user_login.py pin all of it: the login response carries token in the body and the same value in the cookie, /api/auth/me answers 200 with the cookie, 403 without, and 200 with a Bearer header, and logout makes the old token stop working.
SimpleJWT signs with one project key, so the agent keeps the logout semantics by other means rather than dropping them: a custom token class adds a jwt_key claim at login, and a JWTAuthentication subclass compares that claim with the user's current jwt_key and rejects a token whose key has been rotated. The login view becomes a TokenObtainPairView subclass whose serializer returns {"token": access} and sets the same cookie with the same options, and because JWT_ALLOW_REFRESH was False no refresh route is exposed and the refresh token is not returned. The authentication class also reads the cookie when no header is present, which drf-jwt did on its own. SIMPLE_JWT in config/settings/jwt.py replaces JWT_AUTH, keeping the lifetime, the Bearer header type and the cookie settings under new names, rest_framework_simplejwt replaces rest_framework_jwt in THIRD_PARTY_APPS and requirements/base.txt, and the tests move to the new setting names without changing what they assert.
Then it runs what .github/workflows/django.yml runs: ruff check ., mypy --config mypy.ini styleguide_example/ with the django-stubs and djangorestframework-stubs the project pins, and pytest with DJANGO_SETTINGS_MODULE=config.django.test from pytest.ini. The workflow needs a Postgres service, so the agent starts one in the sandbox and points DATABASE_URL at it the way docker-compose.yml does, installs requirements/local.txt, and loops on failures, typically a mypy complaint about the new serializer's return type or a cookie assertion, until all three are clean before it pushes.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Replace drf-jwt with djangorestframework-simplejwt in this Django REST Framework app without changing what API clients see. Read the JWT settings module, the authentication app's APIs and services, the API auth mixin, the user model and the authentication tests first, and write down every behaviour they pin: the response body shape, the cookie name and options, the header prefix, the token lifetime, whether refresh is allowed, and how logout invalidates existing tokens. Then swap the library: a token class that carries the user's jwt_key as a claim, an authentication class that rejects tokens whose claim no longer matches the user and that falls back to the cookie when there is no header, a login view returning the same body and setting the same cookie, no refresh endpoint if the old settings disallowed refresh, SIMPLE_JWT settings in place of JWT_AUTH, and the installed app and requirement updated. Update the tests to the new setting names only. Start Postgres in the sandbox, install the local requirements, and run ruff, mypy with the project's config and pytest until all pass. Open a pull request that lists each pinned behaviour and how it is preserved.",
"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
What comes back is a pull request on its own branch whose description is a table of behaviours, each with how it was preserved: {"token": …} in the body, the jwt cookie with its Secure and SameSite flags, the Bearer prefix, the seven-day lifetime, no refresh route, and logout invalidating tokens through the jwt_key claim. The diff touches requirements/base.txt, config/django/base.py, config/settings/jwt.py, the authentication app's apis.py and services.py, api/mixins.py and the test module.
The transcript carries the proof: the Postgres start, the dependency install, and each ruff, mypy and pytest run with its output, including the ones that failed before a fix. If the repository's workflow runs on pull requests, the same three commands run there against the Postgres service it declares.
Before merging, a reviewer checks that a token issued before the deploy is handled the way the team wants (it will be rejected, because the signing scheme changed, so clients log in once), that the cookie is still deleted on logout, that mypy passes without new type: ignore lines, and that no refresh endpoint is reachable.
Run it on every repository still on drf-jwt
From your own server, start one run per repository that still lists drf-jwt in its requirements: POST /o/{org}/sessions with this prompt and the repository in resources, one call each. GET /o/{org}/github lists every repository the Rush GitHub App installation reaches, so a script can grep each for the old package and start the ones that match. Each run gets its own sandbox and branch and opens its own pull request.
Set a webhook_url on the key and each run POSTs run.completed or run.failed with its session_url when the turn finishes, within about 30 seconds, so the pull request links collect on your side without polling. If a run stops at a mypy error it could not resolve, a follow-up POST …/sessions/{id}/messages with the team's answer wakes the same sandbox with the work so far on disk.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Swapping an auth library is the kind of change nobody wants to half-finish on a laptop: it needs Postgres up, the full test suite green, and the type checker satisfied, and every behaviour a client depends on has to be found before it is broken. In a Rush sandbox the agent starts the database, installs the pinned requirements and runs ruff, mypy and pytest as many times as it takes, on its own disk, with every attempt in the transcript.
The result is a pull request with its reasoning attached: the list of pinned behaviours the agent found before it changed a line, how each one is preserved, and the test output that shows it. Several repositories on the same old library can migrate at once, each in its own sandbox, up to the key's max_concurrent limit.
Frequently asked questions
Will my API clients have to change?
No. The login response still carries token in the body and sets the same cookie, the Authorization: Bearer header still works, and there is still no refresh endpoint. Clients do log in again once after the deploy, because tokens signed by the old library are no longer accepted.
How does logout keep invalidating tokens without per-user secrets?
The new token carries the user's jwt_key as a claim, and the authentication class rejects a token whose claim differs from the user's current jwt_key. auth_logout still rotates the key, so every token that user held stops working, exactly as before.
Does it add SimpleJWT's blacklist app and its migration?
Not by default, because the jwt_key claim already gives logout-invalidates-everything without a table. If the team prefers the blacklist app, the prompt can say so and the agent adds it with its migration and the extra tests.
What does the run need to execute the tests?
A Postgres database, which the agent starts in the sandbox and names through DATABASE_URL the way docker-compose.yml does, plus requirements/local.txt. It then runs the same ruff, mypy and pytest commands as .github/workflows/django.yml.