'Create an agent for this widget
@param agent_id: the agent ID
@param config: the agent configuration dict
@param version: the config version key
@param context: the current S3DashboardContext'

def create_agent(self, agent_id, config=None, version=None, context=None):

    agent_config = dict(self.defaults)
    if config:
        agent_config.update(config)
    agent = self.agents.get(agent_id)
    if agent:
        agent.config = agent_config
        agent.version = version
    else:
        agent = S3DashboardAgent(agent_id, widget=self, config=agent_config, version=version)
        self.agents[agent_id] = agent
        on_create_agent = self.on_create_agent
        if on_create_agent:
            on_create_agent(agent, context)
    return agent
