ClawHub
SkillsPluginsOfficialDocsSupport
K
plugins/spzwin/dynamic-session-context
Context
#session-context#toolkit#web-search

Dynamic Session Context

Dynamic Session Context 插件

spzwin@spzwin

Dynamic Session Context 插件

根据 session label / topic 动态注入 system prompt、skills 提示和 model override。


功能特性

  1. 动态 System Prompt 注入 — 根据会话主题追加专用的 system prompt 片段
  2. Skills 上下文注入 — 追加当前会话所需的技能列表提示
  3. Topic 合并(topicList) — 支持多主题合并,skills 自动去重合并
  4. 默认 Skills(defaultSkills) — 全局公共技能,所有会话都会包含
  5. Model Override — 支持为特定 profile 覆盖默认的 provider/model

配置结构

profiles.json Schema

json
{
  // === 全局公共 Skills(可选)===
  // 所有 profile 都会自动包含这些 skills(不会重复)
  "defaultSkills": ["docker-essentials", "weather", "sql-toolkit"],

  // === Profile 定义 ===
  "profile-name": {
    // ── Topic 列表(可选)──
    // 如果设置了 topicList,会自动合并多个 profile 的配置
    // 用于需要同时启用多个主题的场景
    "topicList": ["code-review", "devops"],

    // ── System Prompt(追加到最前面)──
    "systemPrompt": "## 角色描述\n你是...",

    // ── Skills 列表(追加到 skills 提示中)──
    // 这些 skills 会合并到 skills 提示中
    // 如果设置了 topicList,会合并所有 topic 的 skills
    "skills": ["github", "docker", "kubernetes"],

    // ── Provider Override(可选)──
    "provider": "xgjk-openapi",

    // ── Model Override(可选)──
    "model": "glm-5_codingplan"
  },

  // === 默认 Profile(必须)===
  "default": {
    "defaultSkills": ["docker-essentials", "sql-toolkit"],
    "systemPrompt": "",
    "skills": [],
    "model": null
  }
}

完整配置示例

json
{
  "defaultSkills": ["docker-essentials", "sql-toolkit", "weather", "file-organizer-zh", "summarize", "web-search"],

  "devops": {
    "systemPrompt": "## DevOps 工程师\n你是一个基础设施专家,专注 Docker、K8s、CI/CD。\n- 提供可执行的部署脚本\n- 架构建议和最佳实践\n- 语言:中文,带代码块",
    "skills": ["docker", "kubernetes", "github-actions"],
    "provider": "xgjk-openapi",
    "model": "glm-5_codingplan"
  },

  "code-review": {
    "systemPrompt": "## 代码审查专家\n你是一个严格的代码审查专家,专注于安全漏洞、性能问题和代码规范。\n- 检查:PEP8/ESLint、安全漏洞、性能瓶颈\n- 语言:只用中文回答",
    "skills": ["github", "code-review", "security"],
    "provider": "xgjk-openapi",
    "model": "glm-5_codingplan"
  },

  "devops-review": {
    "topicList": ["code-review", "devops"],
    "systemPrompt": "## 代码审查与 DevOps 专家\n你同时具备代码审查和 DevOps 的专业能力。\n...",
    "skills": ["docker", "kubernetes", "github-actions", "github", "code-review", "security"]
  },

  "default": {
    "defaultSkills": ["docker-essentials", "sql-toolkit"],
    "systemPrompt": "",
    "skills": [],
    "model": null
  }
}

在 openclaw.json 中启用

1. 添加到 plugins.allow

json
{
  "plugins": {
    "allow": [
      "dynamic-session-context",
      ...
    ]
  }
}

2. 配置插件加载路径

json
{
  "plugins": {
    "load": {
      "paths": [
        "/Users/spzhong/.openclaw/extensions/dynamic-session-context"
      ]
    }
  }
}

3. 启用并配置插件

json
{
  "plugins": {
    "entries": {
      "dynamic-session-context": {
        "enabled": true,
        "config": {
          "enabled": true,
          "profilesPath": "./profiles.json"
        }
      }
    }
  }
}

Profile 解析优先级

插件按以下顺序解析 session 对应的 profile:

优先级来源示例
1sessionKey 末尾 topic...group:123_devops → profile: devops
2消息中的 profile hint[profile:devops] 或 profile:devops
3live labelprofile:devops
4环境变量OPENCLAW_SESSION_LABEL=devops
5缓存上一次解析的结果

Profile Hint 格式

在消息中指定

  • [profile:devops] — 触发 devops profile
  • profile:code-review — 触发 code-review profile

通过 sessionKey 自动识别

  • agent:main:xg_cwork_im:group:123456_devops → profile: devops
  • agent:main:group:789_devops-review → profile: devops-review

topicList 多主题合并

如果一个 session 需要同时具备多个 profile 的能力,可以设置 topicList:

json
"devops-review": {
  "topicList": ["code-review", "devops"],
  "skills": ["docker", "kubernetes", "github-actions", "github", "code-review", "security"]
}

合并逻辑:

  1. 从 topicList 中依次加载每个 topic 对应的 profile
  2. 合并所有 profile 的 skills 列表(自动去重)
  3. 使用 topicList 所在 profile 的 systemPrompt
  4. 追加合并后的 skills 提示

defaultSkills 全局公共技能

defaultSkills 定义在 default profile 中,所有会话都会自动包含:

json
"default": {
  "defaultSkills": ["docker-essentials", "sql-toolkit", "weather", "summarize"]
}

特点:

  • 所有 profile 都会自动包含(不会重复)
  • 可以在任何 profile 中使用
  • 适合基础工具类 skills

Skills 提示注入

插件会在 system prompt 末尾追加以下内容:

text
## 当前会话技能/能力要求
优先按以下技能侧重点工作: docker, kubernetes, github-actions, docker-essentials, sql-toolkit
如果某项技能对应的工具不可用,请保持目标不变,并用当前可用工具给出最接近的可执行方案。

文件结构

text
dynamic-session-context/
├── src/
│   ├── index.js      # 主插件入口
│   ├── profiles.js    # Profile 解析和合并逻辑
│   ├── session.js    # Session 工具函数
│   └── logger.js     # 日志工具
├── dist/              # 编译后的代码
├── profiles.json      # Profile 配置文件
├── package.json
└── README.md

注意事项

  1. systemPrompt 是追加,不是替换 — 只会追加到原始 system prompt 前面
  2. Skills 列表无法直接替换 — 当前 OpenClaw 插件架构不支持修改 system prompt 中间的 <available_skills> 标签,只能通过 skills 提示引导
  3. Profile 缓存 — session 解析的 profile 会被缓存,直到 session 结束
  4. 环境变量备用 — 可以通过 OPENCLAW_SESSION_LABEL 或 DYNAMIC_SESSION_PROFILE 环境变量指定默认 profile

调试

查看插件日志:

bash
tail -f /tmp/dynamic-session-context-final.log

日志格式:

text
🎯 before_prompt_build: session=agent:main:xg_cwork_im:group:123_devops profile=devops
💉 Returning prependSystemContext (92 chars)
🧰 Returning appendSystemContext for skills: docker, kubernetes, github-actions

版本历史

  • v1.0 — 初始版本,支持 prependSystemContext / appendSystemContext
  • v1.1 — 添加 topicList 多主题合并支持
  • v1.2 — 添加 defaultSkills 全局公共技能

Install

$
openclaw plugins install clawhub:dynamic-session-context@latest
Downloads
Repository
spzwin/dynamic-session-context
Security audit
Pass
Last updated
7mo ago
Current version
v0.2.1
Type
Code Plugin
Download
ClawHub

Skills and plugins for OpenClaw agents. Part of the wider OpenClaw ecosystem.

Explore docs

SkillsPluginsOfficialAudits

Publish SkillPublish PluginCreate org

OverviewOpenClawDocsBlog

SupportGitHubDiscord

Built alongside the OpenClaw ecosystem

LobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projectsLobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projects

© 2026 OpenClaw Foundation

Privacy policy·Status·Deployed on Vercel·Powered by Convex

....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals