Function importAgent

  • Imports an agent from an AgentExportConfig object.

    For type: 'agent', calls the agent() factory with the stored config. For type: 'agency', calls the agency() factory with the stored config plus the sub-agent roster and strategy.

    The imported agent is a fully functional instance with generate, stream, session, and close methods.

    Parameters

    Returns Agent

    A new Agent instance constructed from the config.

    Throws

    If the config is invalid or missing required fields.

    Example

    const config = JSON.parse(fs.readFileSync('agent.json', 'utf-8'));
    const agent = importAgent(config);
    const reply = await agent.generate('Hello!');