Function overrideAgent

  • Overrides an existing agent schema in the swarm system with a new or partial schema. This function updates the configuration of an agent identified by its agentName, 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

    • OptionalagentSchema: TAgentSchema

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

      • agentName

        The unique identifier of the agent to override, matching IAgentSchemaInternal["agentName"].

    Returns IAgentSchemaInternal

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

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

    // Override an agent’s schema with new properties
    overrideAgent({
    agentName: "WeatherAgent",
    description: "Updated weather query handler",
    tools: ["getWeather"],
    });
    // Logs the operation (if enabled) and updates the agent schema in the swarm.