There should be a new execution mode field (or something to that effect) which decides what kind of environment the agent (and therefore the task) runs in (either "host" or "container"). If it's unset, it should default to "host" mode. It should be set when the task is added to the DB. For now, it'll always be "host", and the logic to decide between "host" and "container" will be determined in a follow-on ticket once PM-2614 has added the necessary configuration to distinguish which environment it is running in.
This work should be to add this to the task DB model and set it properly when the task is inserted, but will not do the work to fix all the existing host-specific queries.