public boolean tryAdd(final Agent agent)
    {
        Objects.requireNonNull(agent, "agent cannot be null");

        if (Status.ACTIVE != status)
        {
            throw new IllegalStateException("add called when not active");
        }

        return addAgent.compareAndSet(null, agent);
    }
@Test
    void shouldNotAllowAddAfterClose()
    {
        final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME);
        final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent);

        invoker.close();

        assertThrows(IllegalStateException.class, () -> compositeAgent.tryAdd(mock(Agent.class)));
    }