Start with ownership, not fashion
Choose a modular monolith when one team owns the workflow end to end and releases it together. Keep model calls behind a clear interface so the rest of the product does not depend on a vendor SDK. Put slow jobs on a queue when the user does not need an immediate answer. That shape keeps local development simple and makes the first production release easier to observe.
Extract a worker or service only when a concrete constraint appears: dedicated hardware for inference, a different release cadence, separate capacity limits, or a queue that competes with interactive traffic. Batch document processing is a common example. Measure queue age, p95 response time and the cost of a successful job before and after the change.
Price the network boundary honestly
A process boundary adds timeouts, retries, partial failures and versioned contracts. Name an owner for the extracted service, define the data contract, make retries idempotent and rehearse rollback. Count the full cost of both options: hosting, monitoring, on-call time, schema migration and the time spent explaining failures to product owners.
Do not treat “we might scale later” as a reason to pay that cost now. A well-modular monolith can isolate AI modules behind interfaces and still run in one deployable unit. Extract when the operating evidence shows the shared process is the bottleneck, not when a diagram looks cleaner.
Protect latency and control planes
Interactive product flows need predictable latency. Put long-running generation, embeddings and bulk classification off the request path. Keep human-approval gates and sensitive outward actions in the application that owns authorization, not inside a model worker that only sees a prompt. Log request metadata without storing private content when that is the product rule.
When you do extract a service, keep the control plane small: one queue, one retry policy, one health check and one owner. Multiple agent workers without shared ownership recreate the same coupling the split was meant to remove.
Decide with a short operating review
Before another extraction, write down: who owns the service, what happens on timeout, how to roll back, which metrics prove success and which user journeys must still work if the AI path is down. Compare those answers for the modular monolith and the split. Prefer the option that a small team can operate for the next release, not the option that matches a generic microservices talk.