What the agent does
The agent starts from the issue and the repository in its own cloud sandbox and reads the blog models before it writes a line. In a site like wagtail/bakerydemo (Wagtail >=8.0,<8.1 on Django >=6.0,<6.1), bakerydemo/blog/models.py defines BlogPage(Page) with subtitle, introduction, a StreamField body, date_published, authors through BlogPersonRelationship and tags = ClusterTaggableManager(through=BlogPageTag). Its get_tags property already builds a URL per tag under the parent BlogIndexPage, and BlogIndexPage(RoutablePageMixin, Page) serves a tags/<slug>/ archive through get_posts(tag). So the raw material for related posts, tags on every post and a way to list posts by tag, is already there; what is missing is the query that ranks other posts by how many tags they share.
Then it reads the templates. bakerydemo/templates/blog/blog_page.html renders the authors, {{ page.body }} and, when page.get_tags is non-empty, a pill list under the heading "Find more blog posts with similar tags". bakerydemo/templates/blog/blog_index_page.html renders each post through includes/card/blog-listing-card.html inside a {% wagtailcache 500 posts tag %} block. The agent plans to reuse that card include for the related posts, so they look like the index and no new CSS is needed, and to place the section after the tag pills, where a reader who has finished the post is looking for the next one.
The change lands in the files that own it. BlogPage gets a related_posts method: live BlogPage objects that share at least one tag with this page, excluding the page itself, annotated with the count of shared tags and ordered by that count and then -date_published, limited to the number the issue names. It is a method, not a field, so makemigrations --check --noinput in .github/workflows/ci.yml stays clean and no migration ships. blog_page.html gains a section that loops over page.related_posts and includes the listing card, guarded so a post with no tags or no live siblings renders nothing extra. Templates are run through djhtml, because make lint-server checks them with djhtml --check alongside ruff format --check, ruff check and curlylint.
Last, it writes the test and runs the suite the way CI does. bakerydemo/base/tests/test_home_page.py shows the project's pattern: a WagtailPageTestCase with setUpTestData that builds the page tree once and a Site with hostname testserver. The agent adds bakerydemo/blog/tests/test_related_posts.py in the same shape: an index page, four posts with overlapping tags, one of them unpublished, and assertions that the post sharing two tags comes first, the draft never appears, and the page itself is excluded. With DJANGO_SETTINGS_MODULE=bakerydemo.settings.test, which uses a local-memory cache and the immediate task backend, it runs ./manage.py check, ./manage.py makemigrations --check --noinput and ./manage.py test against the default SQLite database, then make lint-server, fixing what fails before it pushes.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "A Linear issue labeled agent says: \"Show related posts at the bottom of each blog post: other published posts that share the most tags, newest first among ties, at most the number the issue states.\" Before changing anything, read the blog models and templates: how BlogPage stores tags, what BlogIndexPage already does with tags, and which include renders a post card on the index. Add a related_posts method on BlogPage that returns live posts sharing at least one tag, ranked by shared-tag count then date_published descending, excluding the page itself, and capped at the issue's number. Render them in the blog page template with the existing listing card include, after the tag list, and render nothing when there are none. Do not add a model field or a migration. Add a test in the project's WagtailPageTestCase style covering ranking, the cap, exclusion of the page itself and of unpublished posts. Run manage.py check, makemigrations --check, the test suite with the test settings module, and the project's lint target until they pass, then open a pull request that links back to the issue.",
"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 with a small diff: the related_posts method in bakerydemo/blog/models.py, the new section in bakerydemo/templates/blog/blog_page.html, and a test module under bakerydemo/blog/tests/. No migration is included, and the description says why: the ranking is a query over tags the posts already carry, not new data.
The transcript carries the proof: the manage.py check and makemigrations --check output, each manage.py test run with the new tests named, and the make lint-server run showing ruff, curlylint and djhtml clean. If the repository runs its CI on pull requests, the test-server and lint-server jobs run there as well, so the reviewer sees the same results on GitHub.
Before merging, a reviewer checks that the query does not run once per card (the test can assert the number of queries), that the cap and ordering match the issue, that the section is hidden rather than rendered empty on posts with no tags, and that the related cards use the same renditions and alt text as the index listing.
Run it on every Linear issue labelled agent
In the console, an automation with a linear trigger on linear.issue.labeled and the label agent starts one run per labelled issue in the Project's repository. The trigger appends the issue's text after the saved prompt, so each issue carries its own numbers and wording and the prompt stays fixed. Changes made by an app integration never fire it, and the automation's max_runs_per_hour bounds how many runs a burst of labelling can start.
From your own server, the same job is one POST /o/{org}/sessions per issue, with the repository in resources and the issue's https://linear.app/<workspace>/issue/<ID> URL beside it so Rush reads the issue through your Linear connection. A webhook_url on the API key receives run.completed or run.failed for every run that key starts, with the session_url to read the pull request link from.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
A Wagtail change is only done when the page tree, the tags and the templates agree, and checking that means a migrated database, a test site and a rendered page. In a Rush sandbox the agent installs requirements/development.txt, builds the SQLite database the test settings expect, runs the suite and the lint target, and renders the page in its own browser if it wants to look, all without touching your laptop or your staging site.
A label in Linear becomes a reviewable pull request whose reasoning is on the record: the transcript shows the agent reading blog/models.py and the templates before it writes, and every test and lint run with its output. Several labelled issues can run at once, each in its own sandbox on its own branch, and each pull request links back to the issue that asked for it.
Frequently asked questions
Does this add a model field or a migration?
No. The related posts are computed from the tags BlogPage already has through ClusterTaggableManager, so the change is a method and a template block. makemigrations --check --noinput, which the project's CI runs, stays clean.
Will editors be able to pick related posts by hand?
Not in this change; the issue asks for a tag-based ranking. A follow-up could add an InlinePanel of hand-picked pages that overrides the automatic list. The pull request notes that option so the team can decide separately.
How does it avoid slowing the blog page down?
The query is one annotated BlogPage queryset with the cap applied in the database, and the test counts queries so a per-card lookup would fail it. The section renders through the same card include the index uses, so image renditions are the ones Wagtail already caches.
Which Python and Django does it use to run the tests?
Whatever the repository pins. In bakerydemo that is Django >=6.0,<6.1 and Wagtail >=8.0,<8.1 from requirements/base.txt, installed with uv the way .github/workflows/ci.yml does, and run with DJANGO_SETTINGS_MODULE=bakerydemo.settings.test.