Agents: default context injection to continuation-skip#67447
Agents: default context injection to continuation-skip#67447neeravmakwana wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummarySwitches Confidence Score: 5/5Safe to merge — the one-line default change is well-contained, every affected surface is updated, and both modes remain valid. All findings are P2 (a stale test-helper default that no longer reflects production semantics). No logic, data-integrity, or security issues found. Runtime behavior is correct and backed by updated unit tests. attempt.spawn-workspace.context-injection.test.ts — the local helper still defaults to "always"; low priority but worth aligning.
|
|
Addressed all current AI review feedback in one follow-up. What was raised
What I changed
Validation run
No additional AI review findings remained actionable after this fix. |
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Workspace bootstrap guardrails may be skipped by default on continuation turns (loss of system-prompt policies across restarts/compaction gaps)
DescriptionThe default This is a security regression because those bootstrap files commonly contain repo-/workspace-specific safety constraints, tool restrictions, and operational policies. When they are not re-injected, the model can operate without seeing those guardrails. Key issue in the current logic:
Vulnerable flow (default config path):
Vulnerable code excerpts: // defaults now skip re-injection
export function resolveContextInjectionMode(config?: OpenClawConfig): AgentContextInjection {
return config?.agents?.defaults?.contextInjection ?? "continuation-skip";
}const isContinuationTurn =
params.contextInjectionMode === "continuation-skip" &&
params.bootstrapContextRunKind !== "heartbeat" &&
(await params.hasCompletedBootstrapTurn(params.sessionFile));
const context = isContinuationTurn
? ({ bootstrapFiles: [], contextFiles: [] } as unknown as TContext)
: await params.resolveBootstrapContextForRun();This can allow an attacker/user to exploit the absence of workspace-defined restrictions on later turns (especially after restarts or any situation where prior system prompt is not preserved) to induce unsafe tool use or bypass intended project policies. RecommendationDo not skip bootstrap injection unless you can prove the current model request still contains the bootstrap guardrails. Safer options:
Example (conservative fix: default to always): export function resolveContextInjectionMode(config?: OpenClawConfig): AgentContextInjection {
return config?.agents?.defaults?.contextInjection ?? "always";
}Example (additional guard before skipping): const canSkip = providerSupportsVerifiedPromptCache && promptCacheStillValid;
const isContinuationTurn =
params.contextInjectionMode === "continuation-skip" &&
canSkip &&
params.bootstrapContextRunKind !== "heartbeat" &&
(await params.hasCompletedBootstrapTurn(params.sessionFile));Analyzed PR: #67447 at commit Last updated on: 2026-04-16T00:48:14Z |
|
Thanks — I reviewed the Aisle report in detail. I am not making an additional code change for this one because the finding treats workspace bootstrap text as a hard security boundary, but in OpenClaw the hard security controls are enforced in runtime policy/tooling paths, not by continued prompt reinjection. Why this is not a security regression in this PR
Scope clarification
Operational fallbackIf an operator wants strict per-turn reinjection, they can explicitly set: {
agents: { defaults: { contextInjection: "always" } }
}Given the above, I’m keeping this PR focused as-is. |
Summary
agents.defaults.contextInjectionimplicitly resolved to\"always\".\"continuation-skip\", updated config/help/docs text to match, and refreshed the config baseline hash.\"always\"behavior still exists unchanged, and continuation safety checks (heartbeat/compaction marker handling) remain the same.Change Type
Scope
Linked Issue/PR
Root Cause
resolveContextInjectionMode()was\"always\", so bootstrap context was reinjected unless users explicitly opted into\"continuation-skip\".alwaysas the default.Regression Test Plan
src/agents/bootstrap-files.test.ts(resolveContextInjectionModedefaults)src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-injection.test.tssrc/agents/pi-embedded-runner/run/attempt.spawn-workspace.bootstrap-marker.test.tsalwaysoverride behavior.User-visible / Behavior Changes
agents.defaults.contextInjectionis now\"continuation-skip\".agents.defaults.contextInjection: \"always\".Diagram
Security Impact
Repro + Verification
Environment
agents.defaults.contextInjectionpath and explicitcontinuation-skippathSteps
pnpm test src/agents/bootstrap-files.test.ts -t \"resolveContextInjectionMode\".pnpm test src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-injection.test.ts src/agents/pi-embedded-runner/run/attempt.spawn-workspace.bootstrap-marker.test.ts.pnpm config:docs:gen.Expected
Actual
Evidence
Human Verification
pnpm testandpnpm buildlanes were not run for this focused change.Review Conversations
Compatibility / Migration
Risks and Mitigations
agents.defaults.contextInjection: \"always\"remains available and documented.Additional Notes
Made with Cursor