A framework for running persistent AI agents.
Project description
Cousins
A framework for running persistent AI agents ("cousins").
A cousin is a long-lived AI agent with its own identity, memory, and chat surface — not a one-shot prompt, but an agent that persists across sessions and reboots. Cousins is the machinery to define, run, and maintain them.
Install
pip install cousins
Stdlib-only Python (3.11 or newer); no runtime third-party dependencies.
End-to-end: a Telegram bot driven by a local Ollama model
from cousins import client
from cousins.transports import OllamaTransport, TelegramBotTransport
from cousins.bridges.telegram import TelegramBridge
from cousins.chat import ClientBackend
c = client.build_client("ollama", transport=OllamaTransport(model="phi4-mini"))
bot = TelegramBotTransport(token="<your-bot-token>", poll_timeout=25)
bridge = TelegramBridge(bot=bot, backend=ClientBackend(c))
while True:
bridge.poll_once()
That is a working LLM-on-Telegram bot in eight lines, against a local
Ollama model with no API keys. See docs/site/bridges.md
for the longer walkthrough (system prompts, error translation,
persisting messages to the chat-server).
What ships today (v0.2.8)
cousinsCLI —init,onboard,run,serve-chat.- Provider abstraction + LLM client — stable contract, capability
enforcement, offline
EchoTransportplus live transports. - Live transports (
cousins.transports):OllamaTransportfor a local Ollama HTTP server (no credential).TelegramBotTransportfor the Telegram Bot API.
- Telegram bridge (
cousins.bridges.telegram) — normalises updates, routes them through aChatBackend, handles long-poll offsets. - Chat package (
cousins.chat):Store— sqlite-backed per-cousin message log.Server— stdlib threading HTTP server withon_inbound/on_outboundhost-seam callbacks.EchoBackend+ClientBackend— concrete bridge backends.
- Configuration — strict
cousin.tomlschema with[sandbox]modes (host / systemd / container). - Onboarding wizard — guided first-cousin scaffold; writes a
validated
cousin.toml,memory/, anAGENTS.mdstub, and a.env.exampletemplate when the provider needs credentials. - Runtime layout — platform-appropriate install root (Windows
%APPDATA%, macOS Application Support, XDG on Linux). - Releases — SemVer, Keep-a-Changelog cadence, GitHub Releases with attached sdist + wheel.
Layout
src/cousins/ the package
├─ bridges/ channel adapters (telegram)
├─ chat/ store + HTTP server + bridge backends
├─ providers/ provider abstraction
├─ transports/ live network-backed transports
├─ client.py LLM client + Transport seam
├─ config.py cousin.toml load + validate
├─ layout.py runtime directory layout
├─ onboarding.py cousins onboard wizard
├─ run.py cousins run handler
├─ runtime.py sandbox-mode launch artifact rendering
└─ version.py SemVer 2.0.0
tests/unit/ fast, isolated tests
tests/auto/ integration / end-to-end tests
docs/ architecture, contribution, site, perimeter policy
.github/workflows/ CI
Getting started
cousins init # runtime layout at a default root
cousins onboard --root ./cousins # guided setup for a new cousin
cousins serve-chat <slug> --root ./cousins # foreground chat HTTP server
With Nix:
nix build # build the package
nix develop # dev shell
nix flake check # run the test suite in a sandbox
Tests
No dependencies, no pytest — stdlib only:
python3 -m tests._runner # everything
python3 -m tests._runner unit # only unit tests
python3 -m tests._runner --filter chat -v
CI runs the same command across Python 3.11–3.13. Live integration tests against real backends are gated behind environment variables:
COUSINS_LIVE_OLLAMA=1 python3 -m tests._runner unit --filter ollama
COUSINS_LIVE_TELEGRAM=1 COUSINS_TELEGRAM_BOT_TOKEN=... \
python3 -m tests._runner unit --filter telegram
Roadmap
Tracked as the product-track items in the origin framework's backlog. What's deferred from v0.2.x:
- Anthropic and OpenAI live transports (gated on credentials to verify against).
- Host-style chat-server features (tmux fan-out, static file serving,
agent-log endpoints) — the host wires its own glue via
on_inbound/on_outboundseams today. - The full cousin lifecycle (spawn / flip / transplant / reincarnate), memory layers, hooks and scheduling — migrating in from the origin framework.
Documentation
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cousins-0.2.8.tar.gz.
File metadata
- Download URL: cousins-0.2.8.tar.gz
- Upload date:
- Size: 64.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbb323f732dde559cedbf9bce1c7559b20e31a252ade779affdf090b59b67cc2
|
|
| MD5 |
c59dbcf999e59757786c26b12a2e779b
|
|
| BLAKE2b-256 |
c3142bea47ee007966b98588aa65a8952a4cfeb5826566a44339301ffdae4994
|
File details
Details for the file cousins-0.2.8-py3-none-any.whl.
File metadata
- Download URL: cousins-0.2.8-py3-none-any.whl
- Upload date:
- Size: 74.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f7384275f632577e70689d50ce6922c1b6c91132e95a22123860a169245c66
|
|
| MD5 |
008055868b8cb29f2cff19dba286874d
|
|
| BLAKE2b-256 |
9240fdd009d6c8106b3db33a131dcffd75527e9b94c1de6bd917c39cf7eb346c
|