DSL: get_host, get_service ... no result on agent

we’ve created a Namespace and Functions to replace config files with Json Host / Service Variables in a distributed icinga2 environment.

Issue is, that functions like get_host, get_service do not return any result on the agent while masters & satellites work fine.

Hostname: “abcd”
get_host(“abcd”) returns the host and properties on master and satellites
get_host(“abcd”) returns null on agent

crosschecked with on agent: icinga2 object list | grep -i abcd
only endpoint and zone are available on the agent and these objects do not contain the services and variables

Sample function:
returns list of unique Json keys from Custom Variable [“Custom Filesystem Option”] for all services of the host

namespace cfg {
	function getMonitoredInstances(hostname,service){
	  log(LogInformation,"Console","getMonitoredInstances hostname: " + hostname + " servicename: " + service)
	  var monitored = []
	  var svc = get_service(hostname,service)
	  for (var service in get_services(hostname)) {
			if (service.vars["Custom Filesystem Option"] && service.check_command == svc.check_command) {
				monitored += Json.decode(service.vars["Custom Filesystem Option"].keys())
	  return monitored.unique()

Call from Icinga2 Command Arguments (DSL):
using cfg;
return cfg.getMonitoredInstances(macro("$host.name$"),macro("$service.name$"));

The Argument is properly compiled on Masters and Satellites but returns an exception on agents.
From Icinga Log File:
[2021-04-12 15:53:19 +0200] information/Console: getMonitoredInstances hostname: abcd servicename: dummy_service
[2021-04-12 15:49:33 +0200] warning/PluginUtility: Error: Invalid type in for expression: Empty
for (var service in get_services(hostname))

This is correct as host and service objects are not required at any agent following Top Down Command Endpoint which is default.