首页openclaw插件 › Dynamic Session Context — 插件工具

代码插件 安全

Dynamic Session Context — 插件工具

v0.2.0

The plugin's code, instructions, and file access are coherent with its stated purpose (per-session profile injection); there is no sign it attempts network exfiltration or unrelated privilege escalation, but it does persist mappings and write logs that may contain user content and it reads a couple of env vars that are not declared in the SKILL.md.

0· 0·0 当前
下载插件包 项目主页
最后更新
2026/4/11
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
The plugin's code, instructions, and file access are coherent with its stated purpose (per-session profile injection); there is no sign it attempts network exfiltration or unrelated privilege escalation, but it does persist mappings and write logs that may contain user content and it reads a couple of env vars that are not declared in the SKILL.md.
安全有层次,运行前请审查代码。

版本

latestv0.2.02026/4/11
● 无害

安装命令 点击复制

官方npx clawhub@latest install dynamic-session-context
镜像加速npx clawhub@latest install dynamic-session-context --registry https://cn.clawhub-mirror.com

插件文档

dynamic-session-context

同一 agent 按不同 session 注入不同上下文 的 OpenClaw 插件。

它能做什么

    • 同一个 agent,在不同 session 中做不同事情
    • 按 session 自定义 system prompt
    • 按 session 动态指定 skills
    • 按 session 指定不同 model/provider
    • 支持显式持久化 session -> profile 绑定

当前结论

在 OpenClaw 2026.4.9 下,这个插件已经验证通过:

    • 按 session 命中不同 profile
    • 注入不同 system prompt
    • 注入不同 skills context
    • 覆盖 provider/model
    • 终端中显式创建/续写 session 并命中对应 profile

已验证的真实命中日志

    • 💾 Using persisted session profile for agent:main:explicit:dsc-explicit-bind-001: devops
    • 🔄 Returning providerOverride: "openai-codex"
    • 🔄 Returning modelOverride: "gpt-5.3-codex"
    • 💉 Returning prependSystemContext ...
    • 🧰 Returning appendSystemContext for skills: docker, kubernetes, github-actions

最终判断

如果你的目标是:

一个 agent,在不同 session 中做不同事情,并根据 session 自定义 system prompt、动态指定 skills

那么答案是:

可以,而且当前版本已经能在已验证链路中稳定实现。

说明:

    • 对显式 session 链路,已经验证可用
    • 对能稳定拿到 sessionKeysessionId 的链路,已经验证可用
    • 对 OpenClaw 所有未知内部链路承诺绝对 100%,目前不做这个承诺

推荐用法

    • 先启用插件
    • profiles.json 定义 profile
    • dsc profile set 绑定 session 和 profile
    • openclaw agent --local --session-id ... 创建/续写明确 session
    • 用日志核对 profile 命中情况

启用插件

本插件在 openclaw.plugin.json 中默认是:

"enabledByDefault": false

所以使用前请先在你的 OpenClaw 环境中启用它。

常见做法是通过 OpenClaw 的插件管理能力启用本扩展,然后再执行下面的 CLI 命令。

关于 session-profiles.json

首次发布时,session-profiles.json 为空是正常的:

{}

因为它不是让用户手写的主配置文件,而是运行时 session 绑定表

正确使用方式是:

    • 先在 profiles.json 里定义 profile
    • 再通过 openclaw dsc profile set ... 生成绑定

例如:

openclaw dsc profile set \
  --session agent:main:main \
  --session-id example-session-id \
  --profile-name devops

如果想看格式示例,可参考:

session-profiles.example.json

用户怎么使用这个插件

这个插件的使用方式,不是“每次手动调用插件”,而是:

    • 先在 profiles.json 里定义不同 profile
    • 再把某个 session 绑定到某个 profile
    • 之后在这个 session 里正常使用 agent

也就是说,插件是在后台按 session 自动生效的。

一个最常见的使用流程

第一步:定义 profile

例如在 profiles.json 中定义一个 devops

{
  "devops": {
    "systemPrompt": "你是一个 DevOps 工程师",
    "skills": ["docker", "kubernetes", "github-actions"],
    "provider": "openai-codex",
    "model": "gpt-5.3-codex"
  },
  "default": {
    "systemPrompt": "",
    "skills": [],
    "provider": null,
    "model": null
  }
}

第二步:把 session 绑定到 profile

openclaw dsc profile set \
  --session-id devops-session-001 \
  --profile-name devops

第三步:在这个 session 中正常使用 agent

openclaw agent --local \
  --session-id devops-session-001 \
  --message "帮我排查 Kubernetes Pod CrashLoopBackOff" \
  --json

当这个 session 已经绑定到 devops 后,插件会自动为它注入:

    • devops 对应的 system prompt
    • devops 对应的 skills context
    • devops 对应的 provider/model

你可以把它理解成

    • profiles.json 负责定义“有哪些角色/模式”
    • dsc profile set 负责指定“某个 session 用哪个角色”
    • openclaw agent --local --session-id ... 负责真正进入这个 session 使用 agent

CLI 用法

设置绑定

openclaw dsc profile set \
  --session agent:main:main \
  --session-id 5b395e35-c1ee-4a9c-b645-6ec8aa07eee0 \
  --profile-name devops

查看绑定

openclaw dsc profile get \
  --session agent:main:main \
  --session-id 5b395e35-c1ee-4a9c-b645-6ec8aa07eee0

清除绑定

openclaw dsc profile clear \
  --session agent:main:main \
  --session-id 5b395e35-c1ee-4a9c-b645-6ec8aa07eee0

列出绑定

openclaw dsc profile list

重要说明

set 子命令请使用:

--profile-name

不要再使用:

--profile

因为它会和 OpenClaw 根 CLI 的全局 --profile 冲突。

文档入口

    • 新手安装、启用插件与第一次跑通:QUICKSTART.md
    • 完整使用手册、终端验证步骤、问题复盘和结论报告:README-DETAIL.md

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务