Responses Third Party Prompt Cache Patch
Patch the installed OpenClaw dist bundle so shouldStripResponsesPromptCache(model) stops deleting prompt_cache_key and prompt_cache_retention for third-party OpenAI-compatible Responses endpoints.
Source: https://github.com/tsunheimat/openclaw-responses-prompt-cache-patch
Quick install for OpenClaw
CODEBLOCK0
Risks
- - Write directly into the OpenClaw installation directory under
dist/. - Require Python 3 and Node.js on the target machine.
- Need a gateway restart after apply or rollback for the change to take effect.
Quick start
Run from this skill directory:
CODEBLOCK1
Roll back
CODEBLOCK2
Target selection
- - Default to the currently installed OpenClaw root by resolving the
openclaw executable. - Accept
--root /path/to/openclaw to patch a copied fixture or a different installation. - Scan
dist/pi-embedded-*.js first, then fall back to other dist/*.js bundles only if the target function moved.
What the scripts do
scripts/patch_prompt_cache.py
- - Support INLINECODE9
- Create timestamped backups before writing
- Apply a narrow patch only inside INLINECODE10
- Run
node --check after writing - Auto-restore the fresh backup if syntax validation fails
- Detect already-patched bundles and upgrade-style reapply situations
scripts/revert_prompt_cache.py
- - Restore the latest matching backup for each currently patched bundle
- Support INLINECODE13
- Validate restored files with INLINECODE14
Recommended verification flow
- 1. Run
--dry-run on the real installation. - Copy the target bundle into a fixture and run
--root <fixture> for real apply testing. - Run apply again to confirm idempotency.
- Run rollback on the same fixture.
第三方响应提示缓存补丁
修补已安装的OpenClaw分发包,使shouldStripResponsesPromptCache(model)停止删除第三方OpenAI兼容响应端点的promptcachekey和promptcacheretention。
来源:https://github.com/tsunheimat/openclaw-responses-prompt-cache-patch
OpenClaw快速安装
bash
clawhub install responses-third-party-prompt-cache-patch --workdir ~/.openclaw/workspace
风险
- - 直接写入dist/下的OpenClaw安装目录。
- 目标机器需要Python 3和Node.js。
- 应用或回滚后需要重启网关才能使更改生效。
快速开始
从此技能目录运行:
bash
python3 scripts/patchpromptcache.py --dry-run
python3 scripts/patchpromptcache.py
openclaw gateway restart
回滚
bash
python3 scripts/revertpromptcache.py
openclaw gateway restart
目标选择
- - 默认通过解析openclaw可执行文件定位当前安装的OpenClaw根目录。
- 接受--root /path/to/openclaw参数来修补复制的测试夹具或其他安装。
- 首先扫描dist/pi-embedded-.js,仅当目标函数移动时才回退到其他dist/.js包。
脚本功能
scripts/patchpromptcache.py
- - 支持--dry-run参数
- 写入前创建带时间戳的备份
- 仅在shouldStripResponsesPromptCache(model)内部进行精确修补
- 写入后运行node --check
- 语法验证失败时自动恢复最新备份
- 检测已修补的包和升级式重新应用情况
scripts/revertpromptcache.py
- - 为每个当前已修补的包恢复最新的匹配备份
- 支持--dry-run参数
- 使用node --check验证恢复的文件
推荐验证流程
- 1. 在实际安装上运行--dry-run。
- 将目标包复制到测试夹具中,使用--root 进行实际应用测试。
- 再次运行应用以确认幂等性。
- 在同一测试夹具上运行回滚。