Function overrideSwarm

  • Overrides an existing swarm schema in the swarm system with a new or partial schema. This function updates the configuration of a swarm identified by its swarmName, applying the provided schema properties. It operates outside any existing method or execution contexts to ensure isolation, leveraging beginContext for a clean execution scope. Logs the override operation if logging is enabled in the global configuration.

    Parameters

    • OptionalswarmSchema: TSwarmSchema

      The schema containing the swarm’s unique name and optional properties to override.

      • swarmName

        The unique identifier of the swarm to override, matching ISwarmSchema["swarmName"].

    Returns ISwarmSchema

    No return value; the override is applied directly to the swarm’s swarm schema service.

    If the swarm schema service encounters an error during the override operation (e.g., invalid swarmName or schema).

    // Override a swarm’s schema with new properties
    overrideSwarm({
    swarmName: "MainSwarm",
    defaultAgent: "WeatherAgent",
    policies: ["ContentFilter"],
    });
    // Logs the operation (if enabled) and updates the swarm schema in the swarm system.