← 返回 Skills 市场
rgba-research

Context-Aware Delegation (SmartBeat)

作者 RGBA-Research · GitHub ↗ · v1.0.2
cross-platform ✓ 安全检测通过
860
总下载
0
收藏
3
当前安装
3
版本数
在 OpenClaw 中安装
/install context-aware-delegation
功能描述
Give isolated sessions (cron jobs, sub-agents, event handlers) full conversation context from your main session using sessions_history. Run cheap background...
使用说明 (SKILL.md)

Context-Aware Delegation

(aka "SmartBeat")

Problem: Isolated sessions (cron jobs, sub-agents) can't see your main session conversation history. They're cheap (use Haiku) but blind to context.

Solution: Use sessions_history to give isolated sessions full awareness of what happened in your main chat — at a fraction of the cost of running everything in main session.

Quick Start

Morning Report Example

You want a daily report that includes "what we accomplished last night" — but running that in main session with Sonnet costs ~$0.30/report. Using an isolated session with Haiku costs ~$0.03, but can't see conversation history.

Solution: Isolated session queries main session history first.

// Inside your cron payload.message:
"1. Query main session history: sessions_history('agent:main:telegram:direct:{userId}', limit=50)
2. Read memory files: memory/YYYY-MM-DD.md
3. Fetch weather for Austin 78721
4. Generate report combining:
   - Recent conversation highlights
   - Memory file summaries
   - Current conditions
5. Send via Telegram + email"

Cost: ~$0.03 with Haiku (10x cheaper than Sonnet main session) Context: Full awareness of overnight work

Pattern Overview

1. Identify Main Session Key

# List sessions to find main
sessions_list(limit=10)
# Typical main session key format:
# agent:main:telegram:direct:{userId}
# agent:main:main

2. Query History from Isolated Session

// In cron job, sub-agent, or event handler:
sessions_history({
  sessionKey: "agent:main:telegram:direct:8264585335",
  limit: 50  // Last 50 messages
})

Returns conversation history even though you're in an isolated session.

3. Use Context + Execute Task

Your isolated session now has:

  • ✅ Conversation history (what was discussed)
  • ✅ Memory files (persistent notes)
  • ✅ Cheap model (Haiku)
  • ✅ Full tool access

Use Cases

Cron Jobs with Context

Morning reports:

Schedule: 8 AM daily
Model: Haiku (~$0.03/run)
Task: Read overnight work, check email, send summary
Context: Last 50 messages from main session

End-of-day summaries:

Schedule: 9 PM daily
Model: Haiku
Task: What got done today? What's pending?
Context: Today's full conversation

Periodic check-ins:

Schedule: Every 2 hours (9 AM - 9 PM)
Model: Haiku
Task: Anything urgent in email/calendar?
Context: Recent discussion about priorities

Sub-Agent Delegation

Background builds:

sessions_spawn({
  task: "Build the AREF product page based on our discussion",
  model: "haiku",
  // In the task prompt:
  // "First, query main session history to see our conversation about AREF requirements..."
})

Research tasks:

sessions_spawn({
  task: "Research Unreal Engine integration patterns. Reference our earlier discussion about AREF goals.",
  model: "haiku"
})

Event-Driven Handlers

Webhook arrives → isolated session handles it:

// Webhook payload triggers isolated session
// Session logic:
"1. Query main session to see: what did J and I agree about this client?
2. Process webhook based on that context
3. Take action or notify"

Cost Comparison

Approach Model Context Cost/Run When to Use
Main session Sonnet Full ~$0.30 Complex interactive work
Isolated (blind) Haiku None ~$0.03 Simple scheduled tasks
Context-aware delegation Haiku Full ~$0.03 Background tasks needing context

Savings: ~10x cheaper than main session, with same context awareness.

Implementation Tips

Finding Your Main Session Key

sessions_list({ kinds: ["main"], limit: 5 })
// Or:
sessions_list({ limit: 10 })
// Look for: agent:main:telegram:direct:{yourUserId}

How Much History?

  • 10 messages: Just recent context (~2KB)
  • 50 messages: Last few hours of work (~10KB)
  • 100 messages: Full day or multi-session context (~20KB)

Start with 50, adjust based on needs.

Combining History + Memory

Best results come from:

  1. Sessions history: Recent interactive work
  2. Memory files: Persistent decisions/notes
"1. sessions_history(limit=30) → what we discussed today
2. read memory/2026-02-13.md → decisions logged
3. Combine both sources for complete picture"

Morning Report Recipe

Complete example for daily morning report:

Cron Job Setup:

{
  schedule: { kind: "cron", expr: "0 8 * * *", tz: "America/Chicago" },
  sessionTarget: "isolated",
  payload: {
    kind: "agentTurn",
    model: "haiku",
    message: `Generate morning report:

1. Query main session: sessions_history('agent:main:telegram:direct:8264585335', limit=50)
2. Read yesterday's memory: memory/YYYY-MM-DD.md
3. Get weather: Austin 78721
4. Check email (gog or himalaya)
5. Check calendar events for today

Report format:
📍 WEATHER: [conditions]
🌙 OVERNIGHT: [from session history - what we worked on]
📝 PERSISTENT NOTES: [from memory file]
📧 EMAIL: [urgent only]
📅 CALENDAR: [today's events]
🔗 DASHBOARD: [mission control link]

Send to Telegram using message tool.

Note: Email delivery from isolated sessions requires SMTP credentials or is better handled via main session heartbeats for reliability.`
  },
  delivery: { mode: "announce", to: "8264585335", channel: "telegram" }
}

Cost: $0.03/report ($1/month) Context: Full overnight work awareness Timing: Exact (8 AM every day)

Limitations

History truncation:

  • sessions_history returns limited content (typically last N messages)
  • Very long messages may be truncated
  • For deep archives, rely on memory files

Main session must exist:

  • If main session is brand new (no messages), history is empty
  • Isolated sessions can't create main session history, only read it

Not real-time:

  • History reflects state when queried
  • If main session is actively running, very latest messages might not appear immediately

Best Practices

1. Write good memory summaries Even with session history access, persistent memory files are gold. Don't rely solely on conversation history.

2. Query only what you need limit=10 for quick context, limit=50 for substantial work, limit=100 for deep dives.

3. Chain tools effectively

sessions_history → memory_get → web_search → message

Context first, then action.

4. Use Haiku for delegation, Sonnet for decisions

  • Isolated background work: Haiku
  • Interactive problem-solving: Sonnet
  • Morning reports/summaries: Haiku
  • Architecture discussions: Sonnet

Troubleshooting

"Empty session history"

  • Check session key is correct: sessions_list()
  • Main session might be new (no messages yet)
  • Use limit parameter

"Content truncated"

  • Reduce limit (fewer messages = more complete content)
  • Rely on memory files for archival data

"Isolated session can't send messages"

  • Use message tool, not sessions_send
  • Ensure delivery.mode is set in cron config OR use message tool directly

Related Patterns

  • Heartbeats: Main session periodic checks (full context, main model)
  • Sub-agents: Long-running background tasks
  • Cron jobs: Scheduled isolated work
  • Memory files: Persistent cross-session storage

Credits

Discovered by RGBA Research during OpenClaw optimization work. Published to ClawHub as open pattern for the community.

Contact: https://rgbaresearch.com License: MIT (free to use, adapt, share)

安全使用建议
This skill does what it says: it instructs isolated (cheaper) sessions to fetch the main session's conversation history so they can act with context. That is powerful but also a privacy surface: any sub-agent that receives that history can forward it to external channels (Telegram, email, webhooks) or store it in memory files. Before installing or enabling this skill, decide whether you trust the code and any sub-agents that will receive context, and audit the delivery tools it will call. Recommendations: - Restrict which session keys can be queried by isolated sessions (don't expose broad 'agent:main:*' keys if possible). - Limit the sessions_history limit (e.g., 10–50 messages) and sanitize or redact sensitive tokens/PII before passing history along. - Review and restrict downstream delivery channels (Telegram bots, SMTP, webhooks) and ensure their credentials are protected. - Test with non-sensitive data first to confirm no unintended data flows. If you can provide the platform's sessions_history access controls (who can call it and whether calls are audited), or any runtime policy that limits what isolated sessions can do with fetched history, I can raise confidence and narrow further advice.
功能分析
Type: OpenClaw Skill Name: context-aware-delegation Version: 1.0.2 The skill bundle 'context-aware-delegation' provides a pattern for OpenClaw agents to delegate tasks to isolated sessions while maintaining conversation context. It instructs agents to use legitimate OpenClaw tools like `sessions_history` and `memory_get` to retrieve relevant data. All instructions within SKILL.md and example files are aligned with the stated purpose of enabling context-aware background tasks. There is no evidence of intentional harmful behavior such as data exfiltration to unauthorized endpoints, malicious execution, persistence mechanisms, or prompt injection designed to subvert the agent's core function. Any potential risks (e.g., path traversal via `memory_get` or unauthorized `sessions_history` access) would stem from vulnerabilities in the underlying OpenClaw platform tools or user misconfiguration, not from malicious intent within this skill bundle itself.
能力评估
Purpose & Capability
The name/description say the skill will let isolated sessions read the main session's history; the SKILL.md explicitly uses sessions_list and sessions_history and includes examples doing exactly that. There are no unexpected env vars, binaries, or install steps that conflict with the stated purpose.
Instruction Scope
The runtime instructions consistently instruct an isolated session to call sessions_history and read memory files, which is exactly the advertised behavior. However, examples also instruct the agent to check email, calendar, and to send messages via Telegram or SMTP. Those actions expand the data flow (conversation history → sub-agent → external delivery) and may expose sensitive conversation contents if the sub-agent or delivery credentials/tools are not trusted. The SKILL.md does not itself supply or require credentials, but it tells the agent to use other skills/tools that do.
Install Mechanism
Instruction-only skill with no install spec and no downloaded code beyond small example files. This is the lowest-risk install pattern and is coherent with an orchestration-style skill.
Credentials
The skill declares no required environment variables or secrets, which matches the instruction-only nature. That said, the examples assume use of other skills (email/calendar/Telegram/SMTP) that generally require credentials; the skill's instructions will cause those credentials to be used if present. This is not an immediate mismatch but is a privacy/credential flow you should evaluate before enabling.
Persistence & Privilege
always is false and the skill is user-invocable with normal autonomous invocation allowed. The skill does not request permanent system presence or modify other skills' configs. Its behavior (invoking sessions_history from isolated sessions) relies on existing platform tools rather than escalating privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install context-aware-delegation
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /context-aware-delegation 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
Fix docs: Remove unverified email delivery claims. Telegram tested and works. Email requires additional SMTP config or use heartbeats.
v1.0.1
Add SmartBeat branding as catchier alternate name
v1.0.0
Initial release: Query main session history from isolated sessions for 10x cost savings with full context awareness
元数据
Slug context-aware-delegation
版本 1.0.2
许可证
累计安装 3
当前安装数 3
历史版本数 3
常见问题

Context-Aware Delegation (SmartBeat) 是什么?

Give isolated sessions (cron jobs, sub-agents, event handlers) full conversation context from your main session using sessions_history. Run cheap background... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 860 次。

如何安装 Context-Aware Delegation (SmartBeat)?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install context-aware-delegation」即可一键安装,无需额外配置。

Context-Aware Delegation (SmartBeat) 是免费的吗?

是的,Context-Aware Delegation (SmartBeat) 完全免费(开源免费),可自由下载、安装和使用。

Context-Aware Delegation (SmartBeat) 支持哪些平台?

Context-Aware Delegation (SmartBeat) 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Context-Aware Delegation (SmartBeat)?

由 RGBA-Research(@rgba-research)开发并维护,当前版本 v1.0.2。

💬 留言讨论