{
  "schemaVersion": "1.0",
  "item": {
    "slug": "context-aware-delegation",
    "name": "Context-Aware Delegation (SmartBeat)",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/RGBA-Research/context-aware-delegation",
    "canonicalUrl": "https://clawhub.ai/RGBA-Research/context-aware-delegation",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/context-aware-delegation",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=context-aware-delegation",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "SKILL.md",
      "examples/morning-report-cron.json",
      "examples/sub-agent-with-context.sh"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/context-aware-delegation"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/context-aware-delegation",
    "agentPageUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent",
    "manifestUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "(aka \"SmartBeat\")",
        "body": "Problem: Isolated sessions (cron jobs, sub-agents) can't see your main session conversation history. They're cheap (use Haiku) but blind to context.\n\nSolution: 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."
      },
      {
        "title": "Morning Report Example",
        "body": "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.\n\nSolution: Isolated session queries main session history first.\n\n// Inside your cron payload.message:\n\"1. Query main session history: sessions_history('agent:main:telegram:direct:{userId}', limit=50)\n2. Read memory files: memory/YYYY-MM-DD.md\n3. Fetch weather for Austin 78721\n4. Generate report combining:\n   - Recent conversation highlights\n   - Memory file summaries\n   - Current conditions\n5. Send via Telegram + email\"\n\nCost: ~$0.03 with Haiku (10x cheaper than Sonnet main session)\nContext: Full awareness of overnight work"
      },
      {
        "title": "1. Identify Main Session Key",
        "body": "# List sessions to find main\nsessions_list(limit=10)\n# Typical main session key format:\n# agent:main:telegram:direct:{userId}\n# agent:main:main"
      },
      {
        "title": "2. Query History from Isolated Session",
        "body": "// In cron job, sub-agent, or event handler:\nsessions_history({\n  sessionKey: \"agent:main:telegram:direct:8264585335\",\n  limit: 50  // Last 50 messages\n})\n\nReturns conversation history even though you're in an isolated session."
      },
      {
        "title": "3. Use Context + Execute Task",
        "body": "Your isolated session now has:\n\n✅ Conversation history (what was discussed)\n✅ Memory files (persistent notes)\n✅ Cheap model (Haiku)\n✅ Full tool access"
      },
      {
        "title": "Cron Jobs with Context",
        "body": "Morning reports:\n\nSchedule: 8 AM daily\nModel: Haiku (~$0.03/run)\nTask: Read overnight work, check email, send summary\nContext: Last 50 messages from main session\n\nEnd-of-day summaries:\n\nSchedule: 9 PM daily\nModel: Haiku\nTask: What got done today? What's pending?\nContext: Today's full conversation\n\nPeriodic check-ins:\n\nSchedule: Every 2 hours (9 AM - 9 PM)\nModel: Haiku\nTask: Anything urgent in email/calendar?\nContext: Recent discussion about priorities"
      },
      {
        "title": "Sub-Agent Delegation",
        "body": "Background builds:\n\nsessions_spawn({\n  task: \"Build the AREF product page based on our discussion\",\n  model: \"haiku\",\n  // In the task prompt:\n  // \"First, query main session history to see our conversation about AREF requirements...\"\n})\n\nResearch tasks:\n\nsessions_spawn({\n  task: \"Research Unreal Engine integration patterns. Reference our earlier discussion about AREF goals.\",\n  model: \"haiku\"\n})"
      },
      {
        "title": "Event-Driven Handlers",
        "body": "Webhook arrives → isolated session handles it:\n\n// Webhook payload triggers isolated session\n// Session logic:\n\"1. Query main session to see: what did J and I agree about this client?\n2. Process webhook based on that context\n3. Take action or notify\""
      },
      {
        "title": "Cost Comparison",
        "body": "ApproachModelContextCost/RunWhen to UseMain sessionSonnetFull~$0.30Complex interactive workIsolated (blind)HaikuNone~$0.03Simple scheduled tasksContext-aware delegationHaikuFull~$0.03Background tasks needing context\n\nSavings: ~10x cheaper than main session, with same context awareness."
      },
      {
        "title": "Finding Your Main Session Key",
        "body": "sessions_list({ kinds: [\"main\"], limit: 5 })\n// Or:\nsessions_list({ limit: 10 })\n// Look for: agent:main:telegram:direct:{yourUserId}"
      },
      {
        "title": "How Much History?",
        "body": "10 messages: Just recent context (~2KB)\n50 messages: Last few hours of work (~10KB)\n100 messages: Full day or multi-session context (~20KB)\n\nStart with 50, adjust based on needs."
      },
      {
        "title": "Combining History + Memory",
        "body": "Best results come from:\n\nSessions history: Recent interactive work\nMemory files: Persistent decisions/notes\n\n\"1. sessions_history(limit=30) → what we discussed today\n2. read memory/2026-02-13.md → decisions logged\n3. Combine both sources for complete picture\""
      },
      {
        "title": "Morning Report Recipe",
        "body": "Complete example for daily morning report:\n\nCron Job Setup:\n\n{\n  schedule: { kind: \"cron\", expr: \"0 8 * * *\", tz: \"America/Chicago\" },\n  sessionTarget: \"isolated\",\n  payload: {\n    kind: \"agentTurn\",\n    model: \"haiku\",\n    message: `Generate morning report:\n\n1. Query main session: sessions_history('agent:main:telegram:direct:8264585335', limit=50)\n2. Read yesterday's memory: memory/YYYY-MM-DD.md\n3. Get weather: Austin 78721\n4. Check email (gog or himalaya)\n5. Check calendar events for today\n\nReport format:\n📍 WEATHER: [conditions]\n🌙 OVERNIGHT: [from session history - what we worked on]\n📝 PERSISTENT NOTES: [from memory file]\n📧 EMAIL: [urgent only]\n📅 CALENDAR: [today's events]\n🔗 DASHBOARD: [mission control link]\n\nSend to Telegram using message tool.\n\nNote: Email delivery from isolated sessions requires SMTP credentials or is better handled via main session heartbeats for reliability.`\n  },\n  delivery: { mode: \"announce\", to: \"8264585335\", channel: \"telegram\" }\n}\n\nCost: $0.03/report ($1/month)\nContext: Full overnight work awareness\nTiming: Exact (8 AM every day)"
      },
      {
        "title": "Limitations",
        "body": "History truncation:\n\nsessions_history returns limited content (typically last N messages)\nVery long messages may be truncated\nFor deep archives, rely on memory files\n\nMain session must exist:\n\nIf main session is brand new (no messages), history is empty\nIsolated sessions can't create main session history, only read it\n\nNot real-time:\n\nHistory reflects state when queried\nIf main session is actively running, very latest messages might not appear immediately"
      },
      {
        "title": "Best Practices",
        "body": "1. Write good memory summaries\nEven with session history access, persistent memory files are gold. Don't rely solely on conversation history.\n\n2. Query only what you need\nlimit=10 for quick context, limit=50 for substantial work, limit=100 for deep dives.\n\n3. Chain tools effectively\n\nsessions_history → memory_get → web_search → message\n\nContext first, then action.\n\n4. Use Haiku for delegation, Sonnet for decisions\n\nIsolated background work: Haiku\nInteractive problem-solving: Sonnet\nMorning reports/summaries: Haiku\nArchitecture discussions: Sonnet"
      },
      {
        "title": "Troubleshooting",
        "body": "\"Empty session history\"\n\nCheck session key is correct: sessions_list()\nMain session might be new (no messages yet)\nUse limit parameter\n\n\"Content truncated\"\n\nReduce limit (fewer messages = more complete content)\nRely on memory files for archival data\n\n\"Isolated session can't send messages\"\n\nUse message tool, not sessions_send\nEnsure delivery.mode is set in cron config OR use message tool directly"
      },
      {
        "title": "Related Patterns",
        "body": "Heartbeats: Main session periodic checks (full context, main model)\nSub-agents: Long-running background tasks\nCron jobs: Scheduled isolated work\nMemory files: Persistent cross-session storage"
      },
      {
        "title": "Credits",
        "body": "Discovered by RGBA Research during OpenClaw optimization work.\nPublished to ClawHub as open pattern for the community.\n\nContact: https://rgbaresearch.com\nLicense: MIT (free to use, adapt, share)"
      }
    ],
    "body": "Context-Aware Delegation\n(aka \"SmartBeat\")\n\nProblem: Isolated sessions (cron jobs, sub-agents) can't see your main session conversation history. They're cheap (use Haiku) but blind to context.\n\nSolution: 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.\n\nQuick Start\nMorning Report Example\n\nYou 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.\n\nSolution: Isolated session queries main session history first.\n\n// Inside your cron payload.message:\n\"1. Query main session history: sessions_history('agent:main:telegram:direct:{userId}', limit=50)\n2. Read memory files: memory/YYYY-MM-DD.md\n3. Fetch weather for Austin 78721\n4. Generate report combining:\n   - Recent conversation highlights\n   - Memory file summaries\n   - Current conditions\n5. Send via Telegram + email\"\n\n\nCost: ~$0.03 with Haiku (10x cheaper than Sonnet main session) Context: Full awareness of overnight work\n\nPattern Overview\n1. Identify Main Session Key\n# List sessions to find main\nsessions_list(limit=10)\n# Typical main session key format:\n# agent:main:telegram:direct:{userId}\n# agent:main:main\n\n2. Query History from Isolated Session\n// In cron job, sub-agent, or event handler:\nsessions_history({\n  sessionKey: \"agent:main:telegram:direct:8264585335\",\n  limit: 50  // Last 50 messages\n})\n\n\nReturns conversation history even though you're in an isolated session.\n\n3. Use Context + Execute Task\n\nYour isolated session now has:\n\n✅ Conversation history (what was discussed)\n✅ Memory files (persistent notes)\n✅ Cheap model (Haiku)\n✅ Full tool access\nUse Cases\nCron Jobs with Context\n\nMorning reports:\n\nSchedule: 8 AM daily\nModel: Haiku (~$0.03/run)\nTask: Read overnight work, check email, send summary\nContext: Last 50 messages from main session\n\n\nEnd-of-day summaries:\n\nSchedule: 9 PM daily\nModel: Haiku\nTask: What got done today? What's pending?\nContext: Today's full conversation\n\n\nPeriodic check-ins:\n\nSchedule: Every 2 hours (9 AM - 9 PM)\nModel: Haiku\nTask: Anything urgent in email/calendar?\nContext: Recent discussion about priorities\n\nSub-Agent Delegation\n\nBackground builds:\n\nsessions_spawn({\n  task: \"Build the AREF product page based on our discussion\",\n  model: \"haiku\",\n  // In the task prompt:\n  // \"First, query main session history to see our conversation about AREF requirements...\"\n})\n\n\nResearch tasks:\n\nsessions_spawn({\n  task: \"Research Unreal Engine integration patterns. Reference our earlier discussion about AREF goals.\",\n  model: \"haiku\"\n})\n\nEvent-Driven Handlers\n\nWebhook arrives → isolated session handles it:\n\n// Webhook payload triggers isolated session\n// Session logic:\n\"1. Query main session to see: what did J and I agree about this client?\n2. Process webhook based on that context\n3. Take action or notify\"\n\nCost Comparison\nApproach\tModel\tContext\tCost/Run\tWhen to Use\nMain session\tSonnet\tFull\t~$0.30\tComplex interactive work\nIsolated (blind)\tHaiku\tNone\t~$0.03\tSimple scheduled tasks\nContext-aware delegation\tHaiku\tFull\t~$0.03\tBackground tasks needing context\n\nSavings: ~10x cheaper than main session, with same context awareness.\n\nImplementation Tips\nFinding Your Main Session Key\nsessions_list({ kinds: [\"main\"], limit: 5 })\n// Or:\nsessions_list({ limit: 10 })\n// Look for: agent:main:telegram:direct:{yourUserId}\n\nHow Much History?\n10 messages: Just recent context (~2KB)\n50 messages: Last few hours of work (~10KB)\n100 messages: Full day or multi-session context (~20KB)\n\nStart with 50, adjust based on needs.\n\nCombining History + Memory\n\nBest results come from:\n\nSessions history: Recent interactive work\nMemory files: Persistent decisions/notes\n\"1. sessions_history(limit=30) → what we discussed today\n2. read memory/2026-02-13.md → decisions logged\n3. Combine both sources for complete picture\"\n\nMorning Report Recipe\n\nComplete example for daily morning report:\n\nCron Job Setup:\n\n{\n  schedule: { kind: \"cron\", expr: \"0 8 * * *\", tz: \"America/Chicago\" },\n  sessionTarget: \"isolated\",\n  payload: {\n    kind: \"agentTurn\",\n    model: \"haiku\",\n    message: `Generate morning report:\n\n1. Query main session: sessions_history('agent:main:telegram:direct:8264585335', limit=50)\n2. Read yesterday's memory: memory/YYYY-MM-DD.md\n3. Get weather: Austin 78721\n4. Check email (gog or himalaya)\n5. Check calendar events for today\n\nReport format:\n📍 WEATHER: [conditions]\n🌙 OVERNIGHT: [from session history - what we worked on]\n📝 PERSISTENT NOTES: [from memory file]\n📧 EMAIL: [urgent only]\n📅 CALENDAR: [today's events]\n🔗 DASHBOARD: [mission control link]\n\nSend to Telegram using message tool.\n\nNote: Email delivery from isolated sessions requires SMTP credentials or is better handled via main session heartbeats for reliability.`\n  },\n  delivery: { mode: \"announce\", to: \"8264585335\", channel: \"telegram\" }\n}\n\n\nCost: $0.03/report ($1/month) Context: Full overnight work awareness Timing: Exact (8 AM every day)\n\nLimitations\n\nHistory truncation:\n\nsessions_history returns limited content (typically last N messages)\nVery long messages may be truncated\nFor deep archives, rely on memory files\n\nMain session must exist:\n\nIf main session is brand new (no messages), history is empty\nIsolated sessions can't create main session history, only read it\n\nNot real-time:\n\nHistory reflects state when queried\nIf main session is actively running, very latest messages might not appear immediately\nBest Practices\n\n1. Write good memory summaries Even with session history access, persistent memory files are gold. Don't rely solely on conversation history.\n\n2. Query only what you need limit=10 for quick context, limit=50 for substantial work, limit=100 for deep dives.\n\n3. Chain tools effectively\n\nsessions_history → memory_get → web_search → message\n\n\nContext first, then action.\n\n4. Use Haiku for delegation, Sonnet for decisions\n\nIsolated background work: Haiku\nInteractive problem-solving: Sonnet\nMorning reports/summaries: Haiku\nArchitecture discussions: Sonnet\nTroubleshooting\n\n\"Empty session history\"\n\nCheck session key is correct: sessions_list()\nMain session might be new (no messages yet)\nUse limit parameter\n\n\"Content truncated\"\n\nReduce limit (fewer messages = more complete content)\nRely on memory files for archival data\n\n\"Isolated session can't send messages\"\n\nUse message tool, not sessions_send\nEnsure delivery.mode is set in cron config OR use message tool directly\nRelated Patterns\nHeartbeats: Main session periodic checks (full context, main model)\nSub-agents: Long-running background tasks\nCron jobs: Scheduled isolated work\nMemory files: Persistent cross-session storage\nCredits\n\nDiscovered by RGBA Research during OpenClaw optimization work. Published to ClawHub as open pattern for the community.\n\nContact: https://rgbaresearch.com License: MIT (free to use, adapt, share)"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/RGBA-Research/context-aware-delegation",
    "publisherUrl": "https://clawhub.ai/RGBA-Research/context-aware-delegation",
    "owner": "RGBA-Research",
    "version": "1.0.2",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/context-aware-delegation",
    "downloadUrl": "https://openagent3.xyz/downloads/context-aware-delegation",
    "agentUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent",
    "manifestUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/context-aware-delegation/agent.md"
  }
}