Multiple agents communication
Introduction
This file can be run on any platform supporting Python, with the necessary install permissions. This example shows how to create two different agents and make them communicate using the uAgents Python library.
Please check out the example code in our examples repo (opens in a new tab) to run this locally.
Supporting documentation
The agent
Self hosted
agents.pyfrom uagents import Agent, Bureau, Context alice = Agent(name="alice") bob = Agent(name="bob") @alice.on_interval(period=2.0) async def introduce_alice(ctx: Context): ctx.logger.info(f"Hello, I'm agent {alice.name}.") @bob.on_interval(period=2.0) async def introduce_bob(ctx: Context): ctx.logger.info(f"Hello, I'm agent {bob.name}.") bureau = Bureau() bureau.add(alice) bureau.add(bob) if __name__ == "__main__": bureau.run()