Skip to content

Commit 4dcbde0

Browse files
committed
fix(agents): document skipBootstrap runtime scope and add regression for existing workspace files
Codex review on PR #75217 noted that the runtime resolver guard correctly honors agents.defaults.skipBootstrap, but the public docs at docs/gateway/config-agents.md still described it as workspace-creation-only, and the diff did not include a regression proving `contextFiles` / `injectedWorkspaceFiles` stay empty when existing workspace files are present and skipBootstrap is true. Align the public contract with the new runtime behavior: - docs/gateway/config-agents.md now describes both effects of skipBootstrap (creation + runtime injection) and points users at `contextInjection: 'never'` if they want to keep files on disk but skip injection only. - src/config/types.agent-defaults.ts JSDoc on `skipBootstrap` mirrors the doc wording so editor hover and SDK consumers see the same contract. Add a regression in src/agents/bootstrap-files.test.ts that exercises the exact failure mode the issue described: write AGENTS.md and SOUL.md into the workspace, then call resolveBootstrapFilesForRun and resolveBootstrapContextForRun with skipBootstrap=true and assert both return empty results. A second case sets skipBootstrap=false / unset and asserts AGENTS.md is still resolved, so the guard does not regress the default path. Refs #75184
1 parent a69ba75 commit 4dcbde0

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

docs/gateway/config-agents.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ Optional default skill allowlist for agents that do not set
5959

6060
### `agents.defaults.skipBootstrap`
6161

62-
Disables automatic creation of workspace bootstrap files (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`).
62+
Skips workspace bootstrap files for pre-configured deployments. When set to `true`, OpenClaw both:
63+
64+
1. **Disables automatic creation** of workspace bootstrap files (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`) at workspace setup.
65+
2. **Skips runtime injection** of any existing workspace bootstrap files into the system prompt on every turn (CLI and embedded runtime).
66+
67+
Use this when the deployment supplies its own system prompt, or when you want a workspace-bootstrap-free environment without keeping stray files out of the prompt manually. If you only want to skip injection but keep the files on disk for tooling, use `agents.defaults.contextInjection: "never"` instead.
6368

6469
```json5
6570
{

src/agents/bootstrap-files.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,44 @@ describe("resolveBootstrapFilesForRun", () => {
141141
expect(agentsContextFiles).toHaveLength(1);
142142
expect(agentsContextFiles[0]?.content).toBe("workspace rules");
143143
});
144+
145+
it("returns no bootstrap files when agents.defaults.skipBootstrap is true even if workspace files exist", async () => {
146+
// Regression for #75184: workspace creation already honored skipBootstrap
147+
// (agent-command.ts:373 passes ensureBootstrapFiles: !skipBootstrap), but
148+
// any workspace that already had AGENTS.md / SOUL.md / etc. on disk would
149+
// still be picked up by the runtime resolver and injected into the system
150+
// prompt. Honor skipBootstrap at the resolver so existing workspace files
151+
// also stay out of injection without forcing users onto contextInjection.
152+
const workspaceDir = await makeTempWorkspace("openclaw-skip-bootstrap-");
153+
await fs.writeFile(path.join(workspaceDir, "AGENTS.md"), "workspace rules", "utf8");
154+
await fs.writeFile(path.join(workspaceDir, "SOUL.md"), "soul content", "utf8");
155+
156+
const files = await resolveBootstrapFilesForRun({
157+
workspaceDir,
158+
config: { agents: { defaults: { skipBootstrap: true } } } as never,
159+
});
160+
expect(files).toEqual([]);
161+
162+
const context = await resolveBootstrapContextForRun({
163+
workspaceDir,
164+
config: { agents: { defaults: { skipBootstrap: true } } } as never,
165+
});
166+
expect(context.contextFiles).toEqual([]);
167+
});
168+
169+
it("still resolves workspace bootstrap files when skipBootstrap is false or unset", async () => {
170+
const workspaceDir = await makeTempWorkspace("openclaw-skip-bootstrap-off-");
171+
await fs.writeFile(path.join(workspaceDir, "AGENTS.md"), "workspace rules", "utf8");
172+
173+
const filesUnset = await resolveBootstrapFilesForRun({ workspaceDir });
174+
expect(filesUnset.some((file) => file.name === "AGENTS.md" && !file.missing)).toBe(true);
175+
176+
const filesFalse = await resolveBootstrapFilesForRun({
177+
workspaceDir,
178+
config: { agents: { defaults: { skipBootstrap: false } } } as never,
179+
});
180+
expect(filesFalse.some((file) => file.name === "AGENTS.md" && !file.missing)).toBe(true);
181+
});
144182
});
145183

146184
describe("resolveBootstrapContextForRun", () => {

src/config/types.agent-defaults.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ export type AgentDefaultsConfig = {
222222
systemPromptOverride?: string;
223223
/** Provider-independent prompt overlays applied by model family. */
224224
promptOverlays?: PromptOverlaysConfig;
225-
/** Skip bootstrap (BOOTSTRAP.md creation, etc.) for pre-configured deployments. */
225+
/**
226+
* Skip workspace bootstrap files for pre-configured deployments. When true,
227+
* disables automatic creation of `BOOTSTRAP.md` / `AGENTS.md` / `SOUL.md` /
228+
* etc., AND skips runtime injection of any existing workspace bootstrap
229+
* files into the system prompt (CLI + embedded runtime). Use
230+
* `contextInjection: "never"` instead if you want to keep the files on disk
231+
* but skip prompt injection only.
232+
*/
226233
skipBootstrap?: boolean;
227234
/**
228235
* Controls when workspace bootstrap files (AGENTS.md, SOUL.md, etc.) are

0 commit comments

Comments
 (0)