Session: 2026-01-16 14:30:00 America/New_York
2026/9/14 5:52:44 网站建设 项目流程

Session: 2026-01-16 14:30:00 America/New_York

【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 🦞项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw

  • Session Key: agent:main:main
  • Session ID: abc123def456
  • Source: telegram
自动重置产生的文件用 `Reason: daily` 或 `Reason: idle` 代替命令来源。 配置选项: | 选项 | 类型 | 默认值 | 说明 | | ---- | ---- | ---- | ---- | | `messages` | number | 15 | 记忆文件中包含的 user/assistant 消息条数 | | `llmSlug` | boolean | false | 用已配置的模型生成描述性文件名 slug,而非时间戳 slug | | `model` | string | agent 默认 | 配置别名、默认 provider 上的裸模型 ID,或 `provider/model` 覆盖 | 完整配置示例: ```json { "hooks": { "internal": { "entries": { "session-memory": { "enabled": true, "messages": 25, "llmSlug": true, "model": "sonnet" } } } } }

行为要点(均有 HOOK.md 与源码佐证):

  • 默认使用 workspace 目录(默认~/.openclaw/workspace);
  • 时间戳 slug 是默认值,保证重置处理保持快速;
  • LLM slug 只在llmSlug: true时才会调用已配置的 LLM provider(任意 provider 均可),生成失败时回退到时间戳 slug
  • sonnet这类别名会被解析,裸模型 ID 走 agent 默认 provider,provider/model形式可显式指定其他 provider。

前置条件方面需要注意:该 hook 的requires.config: ["workspace.dir"]内部资格标记(eligibility marker),不是要你去openclaw.json里添加的键。真正要做的是确保 agent workspace 已解析——用agents.defaults.workspaceagents.entries.<id>.workspace配置。

禁用方式:

openclaw hooks disable session-memory

或显式配置"session-memory": { "enabled": false }后重启 Gateway。

三、启用与验证:正确姿势

README 特别强调一个容易踩的坑:"发现且资格满足"不等于"运行中的 Gateway 已加载该 hook"。发现(discovery)和资格(eligibility)只是静态条件;要让 hook 真正生效,必须在该 Gateway 实际使用的配置中启用它,并重启 Gateway 使其重新加载 handlers

标准操作流程:

# 1. 查看某个 hook 的状态与元数据 openclaw hooks info command-logger # 2. 在配置中启用 openclaw hooks enable command-logger

对于已安装为系统服务的 Gateway:

openclaw gateway restart

对于前台开发用的 Gateway:停止并重启你自己拥有的那个进程——不要 kill 掉不相干的 Gateway 进程

以 command-logger 为例的端到端验证方法:在一个测试会话里发送/new/reset,然后检查<state-dir>/logs/commands.log是否出现了对应的 JSONL 记录。

多 agent 场景的一个细节:使用--agent <id>可以选择用于发现(discovery)的 workspace;但注意,持久化的 hook entry 是全局的,不是某个 agent 的专属启用开关。

四、源码布局与 Bundled 目录的发现机制

每个内置 hook 的目录结构完全一致,以command-logger为例:

src/hooks/bundled/command-logger/ ├── HOOK.md # 描述符:frontmatter 声明事件订阅与前置条件 └── handler.ts # 默认导出的 HookHandler

【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 🦞项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询