Skip to content

prompt: strengthen scratch-directory ephemerality warning - #10

Merged
RowitZou merged 1 commit into
mainfrom
feature/scratch-loss-warning
May 22, 2026
Merged

prompt: strengthen scratch-directory ephemerality warning#10
RowitZou merged 1 commit into
mainfrom
feature/scratch-loss-warning

Conversation

@RowitZou

Copy link
Copy Markdown
Owner

背景

Environment Info 段会告诉 agent 把 git clone / 装依赖 / 构建放到 scratch 快速盘下做,但只在末尾补了一句软提醒 "Scratch is temporary — copy anything worth keeping into the workspace"。实测中 agent 克隆成功后基本会丢掉这句,把用户要的交付物(克隆下来的仓库、下载的文件)留在 ephemeral 的 scratch 盘上,worker 重启后丢失。

api-log 实例:用户要求 clone 三个仓库,agent 把仓库克隆进 /scratch/repos/lightclaw 后未拷回工作区。

改动

把末尾那句软提醒换成明确的丢失警告:

  • scratch 在 worker 重启 / 容器销毁 / sandbox 重置 时会被无预警、整个清空,留在里面的东西永久丢失;
  • 一旦某次克隆 / 下载 / 构建产出了用户需要的东西,立刻拷进工作区,绝不把交付物留在 scratch。

前两句(scratch 定位 + "重 IO 放 scratch")保持不变。

注:讨论中曾考虑写"系统会定时清理 scratch",经核对 inbox-aging 只清理工作区内的 .lightclaw/{inbox,downloads,exec},不碰 /scratch —— /scratch 仅由生命周期事件清空。故 prompt 里不写"定时清理"这个不存在的机制。

影响范围

只有渲染 scratch 段的 6 个 Bash-capable role(main / generalist / localExplorer / coder / archivist / reviewer)的 system prompt 变化;4 个无 Bash 的 role(webSearcher / feishuSecretary / memoryExtractor / memoryCurator)byte-identical 不变。role-prompt.snapshot.test.ts 的 6 个对应 hash 已同步更新。

验证

  • pnpm typecheck
  • pnpm exec tsx --test src/agents/role-prompt.snapshot.test.ts
  • pnpm exec tsx --test src/prompt.test.ts ✅ (5/5)
  • pnpm exec tsx --test src/tools/tool-description.snapshot.test.ts ✅ (无关联,确认未受影响)

🤖 Generated with Claude Code

The Environment Info section told the agent to run git clone / installs /
builds under the scratch directory but only closed with a soft "Scratch
is temporary — copy anything worth keeping" trailer. The model routinely
drops that trailer once a clone succeeds, leaving user-facing
deliverables stranded on the ephemeral fast disk.

Replace the trailer with an explicit loss warning: scratch is wiped
without warning whenever the worker restarts, the container is removed,
or the sandbox is reset; anything left there is permanently lost; a
deliverable must be copied into the workspace as soon as it is produced.

Only the six Bash-capable roles that render the scratch section (main,
generalist, localExplorer, coder, archivist, reviewer) change; the four
Bash-less roles stay byte-identical. role-prompt snapshot hashes updated
accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the system-prompt guidance about using the scratch directory by replacing a soft “scratch is temporary” reminder with an explicit data-loss warning, aiming to reduce cases where agents leave deliverables in ephemeral storage.

Changes:

  • Updated the “Environment Info” scratch guidance to clearly state scratch is wiped on worker/container lifecycle events and that deliverables must be copied into the workspace immediately.
  • Updated role prompt snapshot hashes for the six Bash-capable roles impacted by the prompt text change.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/prompt.ts Rewrites the scratch-directory warning to be explicit about wipe conditions and required copy-back behavior.
src/agents/role-prompt.snapshot.test.ts Updates SHA-256 snapshot hashes for the affected role prompts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RowitZou
RowitZou merged commit d12d5a2 into main May 22, 2026
1 check passed
@RowitZou
RowitZou deleted the feature/scratch-loss-warning branch May 24, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants