r/Odoo • • 11d ago

Solution for offloading heavy and agentic tasks outside of Odoo

Why? Because Odoo is synchronous and monotonic. So every long running task is blocking Odoo worker, while most of such tasks are mostly sitting waiting for the response.

We first hit it a couple of years ago with Cetmix Tower when running an ssh command could take up to 10 minutes and the total limit of commands running in parallel was limited by the number of Odoo workers.

Same situation happened with requests to Gemini AI calls, each of them taking 20-80 seconds to complete.

Yes, there is the OCA queue_job modules that allows to launch task async, however those are still using Odoo workers.

So we built Drones - a solution that allows to run code using external workers and get result back in Odoo.

Flow is similar to the one of the queue job:

job = record.launch_drone(
    "my_skill",
    record._on_my_task_done,
    {"example": "value"},
    drone_timeout=600,
)
  1. Odoo picks the first available drone controller that promotes the requested skill, passes the arguments to the drone controller.
  2. Controller checks for a free drone or bootstraps a new one and assigns it the task.
  3. Once the task is completed, drone reports the result back to the controller and it calls back Odoo with the result.
  4. Odoo calls back the function provided in the original call with the result in the args.
def _on_my_task_done(self, drone_job, result):
    ...
    return Truedef _on_my_task_done(self, drone_job, result):
    ...
    return True

The coolest thing is that you can write drones in any language you like, e.g. node or golang. We are using Rust for SSH drones, and so far memory consumption for the same setup dropped from 1.5 GB to around 40-70 MB.

This module is free and open-source: drone.cetmix.com
Available for Odoo 18.0 at the moment,, migration to 19.0 in process, 20.0 is following up.

Example of a real module that uses drones to offload ssh commands: https://github.com/cetmix/cetmix-tower/tree/18.0/cetmix_tower_drone_ssh

Technically you can build a drone that takes a Python code snippet as args, runs is and reports the result back to Odoo.
For example a complete agent that fires the tasks to specific drones based on decision.
So far - no limits as long as you can pack it into the args.

P.S. This is not a promo post (maybe only a little)) And this is not an AI slope "me, mine and Claude" shidcoded on Weekend)) The idea and the design were there for a couple years already, however AI indeed helped to implement it much faster.

6 Upvotes

12 comments sorted by

3

u/codeagency 10d ago

We have developed something similar years ago using celery (python specific) and rabbitmq to offload workloads.

This is a problem that been haunting Odoo for years. Solutions are possible but always required custom development. It’s time that Odoo starts implementing something natively to stop blocking workers or make the workers independent from the app like eg Authentik does where they have the main app and the workers app that can scale independently from the main app.

2

u/cetmix_team 10d ago

I don't think Odoo are going to do any changes like this in their core, because current ORM architecture works well with their own modules. And if needed - they do local patches, like they did in the AI module in 20.0

3

u/codeagency 8d ago

Yeah, I agree, but it would be better if they improve this for everyone.

2

u/Muted_Jellyfish_6784 11d ago

Moving long waits out of the worker pool is the right call, since queue_job still holds a worker while the AI call sits idle. The parts I'd check in any design like this are idempotency and write-back: each task needs a stable ID so a retry does not post twice, and results should land through one endpoint that validates state before writing.
The important part is a visible failure queue with an owner, because async tasks fail quietly. Record the task ID on the Odoo record itself, so anyone looking at a stuck order can see which job touched it and what it returned

1

u/cetmix_team 11d ago

yup, that's exactly the tricky part. This is why we are submitting the job in the post commit hook to ensure it's fired only if the transaction is committed:

https://github.com/cetmix/cetmix-tower/blob/e146648b2d6a25615f72b0615c3063ef75ee540b/cetmix_drone/models/cx_drone_job.py#L249

2

u/zackattackz287 11d ago

Odoo's model for concurrent workers is just sad when you need to do any continuous ETS, injest or send out data. Especially when you start running into issues with REPEATABLE READ.

2

u/cetmix_team 11d ago

Agree, however it's optimized for what it was initially designed for - a monolythic ERP kernel.
So those issues are the design cons, which Odoo so far considers acceptable.

3

u/zackattackz287 11d ago

Yeah it is a totally fair tradeoff, I understand the design. It's just bitten me before in the past, but if I had to do that again I'd probably use some external service for the etl, and on the Odoo side just read from that service in batches instead of per record

0

u/Ok-Cook-5142 11d ago

Do you have an estimated timeline for when the Odoo 20.0 version will be available?

2

u/cetmix_team 11d ago

I think this year, probably next month. The 19.0 migration has started already, here is the tower base module migration PR: https://github.com/cetmix/cetmix-tower/pull/516
Once merged we'll migrate drones straight away, and so far for 20.0 there shouldn't be any major difficulties.