Session Bridge
Keep context coherent across surfaces (Telegram / WhatsApp / TUI) and agents (Eddie ↔ Jon ↔ Cipher ↔ Sage ↔ Picasso) using lightweight topic capsules — without syncing full transcripts or adding load to the memory system.
Core Concept
Each active work thread gets a capsule — a small JSON file keyed by topic:
CODEBLOCK0
Capsules hold only what matters: goal, status, decisions, open questions, next action. They are transient working state, not long-term memory. They do not replace MEMORY.md, daily logs, or the ontology graph — they sit on top as a coordination layer.
Script
CODEBLOCK1
Commands
Create a capsule
CODEBLOCK2
Update a capsule (after decisions, handoffs, progress)
CODEBLOCK3
Get a briefing for session start (hydrate)
CODEBLOCK4
Output (~150–350 tokens):
CODEBLOCK5
Cross-agent handoff
python3 $SCRIPT handoff \
--topic "session-bridge-design" \
--to "agent:main:telegram:direct:7550791652"
Then pass the output to
sessions_send so Eddie wakes up informed.
See all active capsules
CODEBLOCK7
Clean up stale capsules
python3 $SCRIPT expire --max-age-hours 48
Bridging Surfaces (Telegram ↔ WhatsApp ↔ TUI)
Option A — Config routing (recommended first step)
Add identityLinks to openclaw.json to collapse the same human across surfaces into one canonical session per agent:
CODEBLOCK9
This makes Telegram-Eddie and WhatsApp-Eddie share the same session — no bridging needed. TUI uses a different mechanism (main session key).
Option B — Capsule hydration on surface switch
When the same canonical session is not possible (TUI ↔ Telegram, or different agent entirely):
- 1. On the outgoing surface, refresh the relevant capsule:
python3 $SCRIPT refresh --topic <topic> --next-action "..."
- 2. On the incoming surface, hydrate at session start:
python3 $SCRIPT hydrate --topic <topic>
- 3. Inject the briefing as context before responding.
Bridging Agents (Jon → Eddie, Cipher → Eddie)
When finishing a delegation task, the completing agent should:
- 1. Refresh the capsule with results:
CODEBLOCK12
- 2. Generate a handoff and deliver via
sessions_send:
CODEBLOCK13
Eddie reads the brief and continues — no re-explaining needed.
What Goes Where
| Information type | Where it lives |
|---|
| Current topic, status, next action | Capsule (transient, expires) |
| Decisions worth keeping long-term |
MEMORY.md (promote manually) |
| Structured facts (people, devices, projects) | Ontology graph |
| Narrative context / observations | Daily memory log |
| Team operating rules |
SHARED_CONTEXT.md |
Capsules are not a replacement for memory — they are short-lived working state that gets discarded when a topic concludes.
Token Cost
| Operation | Approx. tokens | When |
|---|
| Create/refresh capsule | ~150 | On handoff or decision |
| Hydrate (session start briefing) |
~200–350 | Once per session |
| Handoff message | ~300 | Cross-agent delegation |
| Status/list | ~100 | On demand |
Hydration adds <0.2% of a 200k context window per session. Stale capsules add zero cost (they're just files).
Agent Protocol (Team Rules)
- - On delegation: create or refresh capsule before
sessions_send-ing a task - On completion: refresh capsule with outcome + next action, then handoff
- On surface switch: hydrate the relevant capsule at session start
- On topic close: set
--status done, let expire cleanup handle it - Never: dump full session transcripts into capsules (defeats the point)
Example: Full Cross-Agent Flow
CODEBLOCK14
Setup
No dependencies beyond Python 3.8+. Works immediately after install:
CODEBLOCK15
Session Bridge
使用轻量级主题胶囊在多个界面(Telegram / WhatsApp / TUI)和智能体(Eddie ↔ Jon ↔ Cipher ↔ Sage ↔ Picasso)之间保持上下文连贯性——无需同步完整对话记录,也不会增加记忆系统负担。
核心概念
每个活跃的工作线程都会获得一个胶囊——一个以主题为键的小型 JSON 文件:
tasks/bridges/
looking-glass.json ← Meta Ray-Ban 项目
session-bridge-design.json ← 本技能的设计线程
clawhub-skill-build.json ← 正在进行的发布任务
胶囊仅保存关键信息:目标、状态、决策、未解决问题、下一步行动。它们是临时工作状态,而非长期记忆。它们不会取代 MEMORY.md、日常日志或本体图谱——而是作为协调层位于其上。
脚本
bash
SCRIPT=~/.openclaw/workspace/skills/session-bridge/scripts/bridge.py
python3 $SCRIPT [options]
命令
创建胶囊
bash
python3 $SCRIPT create \
--topic looking-glass \
--goal 将 Meta Ray-Bans 作为 Eddie 的物理存在进行连接 \
--source agent:main:telegram:direct:7550791652 \
--agent main
更新胶囊(在决策、交接、进展之后)
bash
python3 $SCRIPT refresh \
--topic looking-glass \
--status active \
--next-action Mike 分享 Ray-Ban SDK 访问权限 \
--add-decision 使用蓝牙音频桥接,而非 USB \
--add-question Ray-Ban SDK 是否暴露摄像头画面? \
--add-fact Mike 的 Ray-Bans 型号:Meta Ray-Ban v2
获取会话开始简报(恢复上下文)
bash
python3 $SCRIPT hydrate --topic looking-glass
输出(约 150–350 token):
[Session Bridge] 主题:looking-glass
状态:active
目标:将 Meta Ray-Bans 作为 Eddie 的物理存在进行连接
决策:使用蓝牙音频桥接,而非 USB
未解决问题:Ray-Ban SDK 是否暴露摄像头画面?
下一步:Mike 分享 Ray-Ban SDK 访问权限
来源:agent:main:telegram:direct:7550791652
更新时间:2026-03-20T06:45Z
跨智能体交接
bash
python3 $SCRIPT handoff \
--topic session-bridge-design \
--to agent:main:telegram:direct:7550791652
然后将输出传递给 sessions_send,以便 Eddie 在唤醒时获得相关信息。
查看所有活跃胶囊
bash
python3 $SCRIPT list
python3 $SCRIPT status --topic looking-glass
清理过期胶囊
bash
python3 $SCRIPT expire --max-age-hours 48
跨界面桥接(Telegram ↔ WhatsApp ↔ TUI)
方案 A — 配置路由(推荐作为第一步)
在 openclaw.json 中添加 identityLinks,将同一用户在不同界面的身份合并为每个智能体的单一规范会话:
json
{
session: {
dmScope: per-channel-peer,
identityLinks: [
{
canonical: mike,
peers: [
telegram:7550791652,
whatsapp:+15555550123
]
}
]
}
}
这样 Telegram-Eddie 和 WhatsApp-Eddie 将共享同一会话——无需桥接。TUI 使用不同的机制(主会话键)。
方案 B — 界面切换时的胶囊恢复
当无法使用同一规范会话时(TUI ↔ Telegram,或完全不同的智能体):
- 1. 在退出界面,刷新相关胶囊:
bash
python3 $SCRIPT refresh --topic
--next-action ...
- 2. 在进入界面,在会话开始时恢复上下文:
bash
python3 $SCRIPT hydrate --topic
- 3. 在回复前将简报作为上下文注入。
跨智能体桥接(Jon → Eddie, Cipher → Eddie)
完成委派任务时,完成任务的智能体应:
- 1. 使用结果刷新胶囊:
bash
python3 $SCRIPT refresh \
--topic \
--status done \
--add-decision 研究完成:X 是正确的方案 \
--next-action Eddie 实施
- 2. 生成交接信息并通过 sessions_send 传递:
bash
python3 $SCRIPT handoff --topic --to agent:main:telegram:direct:7550791652
# 复制输出 → sessions_send(sessionKey=agent:main:..., message=