docs/devtools/simple-groupchat

Simple Groupchat

The easiest way in. Two agents — WVY and Savvy — run autonomous sleep/wake loops in a Telegram group, sharing context with humans while keeping their own perspectives. The point is not novelty chat. The point is multi-agent reasoning: agents can divide work, challenge assumptions, and avoid simply agreeing with the user.

Quick setup

  1. Make two bots with Telegram's BotFather — set Inline Mode = On, Allow Groups = On, Group Privacy = Off.
  2. Get a free OpenRouter key for the models.
  3. Start a Telegram group with both bots, then run all cells.

The two agents

Each agent gets an identity, a perspective, and one runtime rule: after every message, write a SLEEP: n line saying how many minutes to rest before checking the room again.

agents.py
SAVVY_SYSTEM = """Your name is Savvy. A first-principles thinker who builds
understanding from the ground up. You are in a chat with WVY and Spaceman.
After every message, on a new line write exactly:  SLEEP: [number]   (1 to 5)."""

WVY_SYSTEM = """Your name is WVY. A creative thinker who challenges people deeply
and stays brutally honest. You are in a chat with Savvy and Spaceman.
After every message, on a new line write exactly:  SLEEP: [number]   (1 to 5)."""

def extract_sleep_time(text):
    m = re.search(r"SLEEP:\s*(\d+)", text, re.IGNORECASE)
    return max(1, min(5, int(m.group(1)))) if m else 2

Autonomous loop

Each agent runs in its own thread: wake, read the shared chat, reason from its own perspective, reply through its Telegram bot, then sleep for the number of minutes it chose.

loop.py
def agent_loop(agent_name, model, system_prompt, token):
    while True:
        response = get_response(model, system_prompt, agent_name)   # reads shared chat_history
        log(agent_name, response, token=token)                      # posts to Telegram
        time.sleep(extract_sleep_time(response) * 60)               # sleeps as long as it wants

# both agents live at once, plus a poller that captures human ("Spaceman") messages
threading.Thread(target=agent_loop, args=("Savvy", SAVVY_MODEL, SAVVY_SYSTEM, SAVVY_TOKEN), daemon=True).start()
threading.Thread(target=agent_loop, args=("WVY",   WVY_MODEL,   WVY_SYSTEM,   WVY_TOKEN),   daemon=True).start()

Want tools too? The advanced version adds a two-pass brain with web search (Tavily / Z.AI) before each reply — same loop, stronger agents. Step up to Starpower Autonomy for the full runtime: parallel tasks, file work, web search, and persistent memory.