Service variables not available on Agent?

I am trying to access service variables on an Icinga Agent, but they seem not to be available.

Setup: Icinga Master and Icinga Agent, Configuration is done via Director.

Service definition:

object Service "Test" {
    host_name = "svprxp02"
    check_command = "Test"
    max_check_attempts = "3"
    check_period = "7x24"
    check_interval = 1m
    retry_interval = 1m
    check_timeout = 1m
    enable_notifications = true
    enable_active_checks = true
    enable_passive_checks = true
    enable_event_handler = true
    enable_flapping = false
    enable_perfdata = true
    volatile = false
    command_endpoint = host_name
    vars.mail_alerting = false
    vars.parameters = [ "-param1", "wert1", "-param2", "wert2" ]
}

Command definition:

object CheckCommand "check_test" {
    import "plugin-check-command"
    command = [ MyPlugins + "/check_test" ]
    arguments += {
        _X = {
            required = true
            skip_key = true
            value = {{
                if(service.vars.parameters) {
              var res = []
              for( var elem in service.vars.parameters) {
            	res.add(macro(elem))
              }
              return res
            }
            }}
        }
    }
}

The check script:

#!/bin/bash

echo "Alles OK" $@
exit 0

#echo "Alles Warning"
#exit 1

echo "Alles Critical"
exit 2

When i remove the “command_endpoint” from the service definition, so the command runs on the master, everything is fine and i get the plugin output:

Alles OK -param1 wert1 -param2 wert2

But when the command runs on the agent, i get an error

Error: Error while evaluating expression: Tried to access undefined script variable ‘service’

So my question is: What am i doing wrong? Why are the service vars not exported to the agent?

When i run icinga2 console on the agent, i even cannot find any host or service objects:

ICINGA2_API_PASSWORD=****** icinga2 console --connect https://root@localhost:5665/
Icinga 2 (version: v2.14.0-188-g236071596)
Type $help to view available commands.
<1> => NodeName
"svprxp02"
<2> => var h=get_objects(Host)
null
<3> => h
[ ]
<4> => var h=get_objects(Service)
null
<5> => h
[ ]
<6> => var h=get_objects(Zone)
null
<7> => h
[ {
        __name = "master"
        -- lot of data deleted --
}, {
        __name = "director-global"
        -- lot of data deleted --
}, {
        __name = "svprxp02"
        -- lot of data deleted --
} ]

I have no idea why there isn’t any hosts or services defined. But i have other services running on the agent which run quite fine.

Have you tried value = "$parameters$"?