Function changeToAgent

  • Changes the active agent for a given client session in a swarm.

    This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies, logging the operation if enabled, and executing the change using a TTL-limited, queued runner. The execution is wrapped in beginContext to ensure it runs outside of existing method and execution contexts.

    Parameters

    • agentName: string

      The name of the agent to use or reference.

    • clientId: string

      The unique identifier of the client session.

    Returns Promise<boolean>

    If session or agent validation fails, or if the agent change process encounters an error.

    await changeToAgent("AgentX", "client-123");