Skip to content

TWE-712: Remove wagtail_ai - #476

Merged
alxbridge merged 4 commits into
mainfrom
support/TWE-712-disable-wagtail-ai
Oct 29, 2026
Merged

alxbridge merged 4 commits into
mainfrom
support/TWE-712-disable-wagtail-ai

Conversation

@alxbridge

@alxbridge alxbridge commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

A recent upgrade of the any-llm-sdk transitive dependency pulls in both the OpenAI and Anthropic SDKs, adding ~55MB to every gunicorn worker and pushing production dynos over their 512MB quota.

As the feature's not currently in use, this is removed until needed and performance is better

Tracked on TWE-712

Description of Changes Made

I've removed the changes made to add wagtail-ai, including its dependencies, configuration, and related documentation.

Once a fix can be made to django-ai-core (which is responsible for how any-llm-sdk is pulled in), this PR can be reversed and the updated versions bumped.

Verification

Memray profiling showed the following memory usage for the site code before the Wagtail 8.0 upgrade which pulled in the newer dependency, after it, and with this PR:

Before upgrade After upgrade After upgrade,
with this PR
Peak heap (memray) 105.1 MB 177.5 MB 106.7 MB
Worker RSS after boot ~137 MB ~205 MB ~149 MB
Modules imported 2,787 4,540 2,207
Boot time (warm) ~2.2 s ~4.4 s ~1.7 s

Deployment

wagtail-ai's migrations created two tables: wagtail_ai_prompt (populated with default prompts) and wagtail_ai_agentsettings, as well as content types and permissions in existing tables. Uninstalling the package doesn't remove any of these. To clean them up:

1. roll back the wagtail-ai migrations while the app is still installed. This drops both tables and their django_migrations rows:

heroku run -a torchbox-com-[staging/production] -- python manage.py migrate wagtail_ai zero

2. Deploy.

3. After deployment, remove the stale content types for the uninstalled app. This also deletes their permissions and any group permissions assigned to them:

heroku run -a torchbox-com-[staging/production] -- python manage.py remove_stale_contenttypes --include-stale-apps

It lists what it will delete and asks for confirmation. Check that the list only contains wagtail_ai entries before answering yes. Drop --include-stale-apps and it won't touch content types for uninstalled a
pps at all.

MR Checklist

  • Add a description of your pull request and instructions for the reviewer to verify your work.
  • If your pull request is for a specific ticket, link to it in the description.
  • Stay on point and keep it small so the merge request can be easily reviewed.
  • Tests and linting passes.

Unit tests

  • Added
  • Not required

Documentation

Browser testing

  • I have tested in the following browsers and environments (edit the list as required)
    • Latest version of Chrome on mac
    • Latest version of Firefox on mac
    • Latest version of Safari on mac
    • Safari on last two versions of iOS
    • Chrome on last two versions of Android
  • Not required

Data protection

  • Not relevant
  • This adds new sources of PII and documents it and modifies Birdbath processors accordingly

Light and dark mode

  • I have tested the changes in both light and dark mode
  • The change is not relevant to dark and light mode

Accessibility

  • Automated WCAG 2.1 tests pass
  • HTML validation passes
  • Manual WCAG 2.1 tests completed
  • I have tested in a screen reader
  • I have tested in high-contrast mode
  • Any animations removed for prefers-reduced-motion
  • Not required

Sustainability

  • Images are optimised and lazy-loading used where appropriate
  • SVGs have been optimised
  • Performance and transfer of data considered
  • If JavaScript is needed alternatives have been considered
  • Not required

Pattern library

  • The pattern library component for this template displays correctly, and does not break parent templates
  • The styleguide is updated if relevant
  • Changes are not relevant the pattern library

A recent upgrade of the any-llm-sdk transitive dependency pulls in both
the OpenAI and Anthropic SDKs, adding ~55MB to every gunicorn worker and
pushing production dynos over their 512MB quota. As the feature's not
currently in use, this is removed until needed and performance is better

@zerolab zerolab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alxbridge I say let's fully nuke it and revisit once improvements are released upstream

alxbridge and others added 2 commits October 28, 2026 17:08
This reverts commit 4c8377e.

Per review, wagtail-ai is being removed entirely instead (next commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit f8a27b6.

wagtail-ai pulls in django-ai-core and any-llm-sdk, which since the
Wagtail 8 upgrade load both the OpenAI and Anthropic SDKs in every
worker (~55MB each), pushing production dynos over their memory quota.
No AI provider is configured in production, so remove it until the
upstream import improvements are released.

Conflicts in pyproject.toml and poetry.lock (both changed by the Wagtail
8 upgrade) were resolved by dropping the wagtail-ai dependency and
running `poetry lock --no-update`; only wagtail-ai and its transitive
dependencies are removed from the lock file. Also adds a CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alxbridge alxbridge changed the title TWE-712: Remove wagtail_ai from INSTALLED_APPS TWE-712: Remove wagtail_ai Oct 28, 2026
@alxbridge
alxbridge merged commit 5ec3141 into main Oct 29, 2026
10 checks passed
@alxbridge
alxbridge deleted the support/TWE-712-disable-wagtail-ai branch October 29, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants