feat(agents): add contextInjection 'never' to disable bootstrap file injection#64094
feat(agents): add contextInjection 'never' to disable bootstrap file injection#64094xDarkicex wants to merge 0 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds The only gap is that the JSDoc comment on the Confidence Score: 5/5Safe to merge — the change is additive, backward compatible, and all affected surfaces (type, schema, runtime, docs, test) are consistently updated. Only a single P2 finding: the JSDoc on src/config/types.agent-defaults.ts — JSDoc comment needs the "never" bullet added.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34b2101daa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| contextInjection: z | ||
| .union([z.literal("always"), z.literal("continuation-skip"), z.literal("never")]) |
There was a problem hiding this comment.
Regenerate base config schema for the new contextInjection value
Adding "never" to AgentDefaultsSchema here updates config parsing, but the public schema contract is served from GENERATED_BASE_CONFIG_SCHEMA in src/config/schema.ts:463, and that generated artifact still only lists "always"/"continuation-skip" for agents.defaults.contextInjection (src/config/schema.base.generated.ts:3187-3200, :24201-24204). This leaves schema-driven consumers (including config UI/metadata clients) unaware of the new option even though runtime parsing accepts it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
P1 — Regenerated base config schema
Ran scripts/generate-base-config-schema.ts --write to regenerate schema.base.generated.ts. The contextInjection enum in the
generated schema contract now includes "never" and the help text reflects all three options. Config UI/metadata consumers will
now see the new option.
| contextInjectionMode === "never" || | ||
| (contextInjectionMode === "continuation-skip" && |
There was a problem hiding this comment.
Honor "never" mode during compaction prompts
This new branch only skips bootstrap files in runEmbeddedAttempt, but compaction still unconditionally loads and injects bootstrap context via resolveBootstrapContextForRun and contextFiles in src/agents/pi-embedded-runner/compact.ts:514 and :776. In sessions that trigger compaction, agents.defaults.contextInjection: "never" still injects AGENTS/SOUL content, so the mode is not actually “never” across the full embedded runner flow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
P2 — Honor "never" during compaction
Added resolveContextInjectionMode import to compact.ts and wrapped the resolveBootstrapContextForRun call at line ~514 with a
skip check:
const skipBootstrapInjection = contextInjectionMode === "never";
const { contextFiles } = skipBootstrapInjection
? { contextFiles: [] }
: await resolveBootstrapContextForRun({ ... });
With this, contextInjection: "never" is respected across the full embedded runner lifecycle — both in runEmbeddedAttempt (which
was already fixed) and in compaction prompts (this change).
34b2101 to
67e91dc
Compare
|
P1 — Regenerated base config schema P2 — Honor "never" during compaction const skipBootstrapInjection = contextInjectionMode === "never"; With this, contextInjection: "never" is respected across the full embedded runner lifecycle — both in runEmbeddedAttempt (which |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67e91dca5f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| contextInjection: z | ||
| .union([z.literal("always"), z.literal("continuation-skip"), z.literal("never")]) |
There was a problem hiding this comment.
Keep contextInjection tests aligned with new "never" mode
Adding "never" to AgentDefaultsSchema changes the accepted config contract, but the existing unit test suite still asserts that AgentDefaultsSchema.parse({ contextInjection: "never" }) should throw (src/config/zod-schema.agent-defaults.test.ts). That makes the schema tests fail in any test lane that includes this file, obscuring real regressions and blocking merges until the expectation is updated to accept the new mode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The test was rejecting "never" as invalid after it was added to the schema. Fixed by updating the test to accept "never" and
checking "unknown" instead for the rejection case.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a4fe68610
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| trigger: params.trigger, | ||
| runTimeoutMs: params.timeoutMs !== configuredRunTimeoutMs ? params.timeoutMs : undefined, | ||
| }); | ||
| const idleTimeoutMs = resolveLlmIdleTimeoutMs(params.config); |
There was a problem hiding this comment.
Pass idle-timeout options object to resolver
resolveLlmIdleTimeoutMs expects an options object ({ cfg, trigger, runTimeoutMs }), but this call passes params.config directly. That leaves cfg unset, so configured agents.defaults.llm.idleTimeoutSeconds, cron-trigger exemptions, and per-run timeout overrides are ignored and the resolver falls back to the 60s default. Runs that intentionally disable or extend idle timeout will now time out early.
Useful? React with 👍 / 👎.
| const appendPrompt = | ||
| resolveSystemPromptOverride({ | ||
| config: params.config, | ||
| agentId: sessionAgentId, |
There was a problem hiding this comment.
Restore provider prompt/text transforms in embedded runs
This commit stops applying provider transform hooks in the embedded runner: appendPrompt is now used directly without transformProviderSystemPrompt, and the stream wrapping for resolveProviderTextTransforms/wrapStreamFnTextTransforms was also removed. Any provider plugin relying on transformSystemPrompt or textTransforms will silently lose its compatibility rewrites (prompt/input/output replacements), changing runtime behavior for those providers.
Useful? React with 👍 / 👎.
| export async function compactEmbeddedPiSession( | ||
| params: CompactEmbeddedPiSessionParams, | ||
| ): Promise<EmbeddedPiCompactResult> { | ||
| const harnessResult = await maybeCompactAgentHarnessSession(params); | ||
| if (harnessResult) { | ||
| return harnessResult; | ||
| } | ||
| const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId); | ||
| const globalLane = resolveGlobalLane(params.lane); |
There was a problem hiding this comment.
Keep harness compaction delegation before PI fallback
compactEmbeddedPiSession now goes straight into PI compaction and no longer checks maybeCompactAgentHarnessSession first. That means harnesses implementing compact() through the agent-harness contract are skipped, so manual compaction calls from src/gateway/server-methods/sessions.ts will force PI compaction even when a non-PI harness is selected, which can break harness-managed session/compaction behavior.
Useful? React with 👍 / 👎.
9a4fe68 to
0c4a19d
Compare
Summary
Add
contextInjection: "never"option toagents.defaultsconfig, allowing memory/context plugins to own authored doc delivery via semantic retrieval instead of OpenClaw injecting raw workspace files."never"as a thirdcontextInjectionoption alongside"always"and"continuation-skip". When set,isContinuationTurnevaluates to true unconditionally, skipping all bootstrap file loading and injection."always"and"continuation-skip"behave identically. The memory plugin seams (MemoryCorpusSupplement,promptBuilder) are unchanged — this config only controls whether bootstrap files are injected; plugin context is orthogonal.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A — feature addition, not a bug fix.
Regression Test Plan (if applicable)
src/agents/bootstrap-files.test.ts—resolveContextInjectionModecontextInjection: "never"is parsed and returned correctly"never"caseUser-visible / Behavior Changes
agents.defaults.contextInjectionnow accepts"never"in addition to"always"and"continuation-skip""never", workspace bootstrap files (AGENTS.md, SOUL.md, etc.) are never injected into the system prompt"always"— no behavior change for existing usersDiagram (if applicable)
N/A
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
agents.defaults.contextInjection: "never"in config# Project Contextsection should appearExpected
Bootstrap files are not injected; the memory plugin's
promptBuilderandMemoryCorpusSupplementare the sole authored-doc surface.Actual
TBD (verified manually)
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
"never"mode; type-check, lint, and build all pass"never", rejects invalid valuesReview Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
"never"value foragents.defaults.contextInjection"always"Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None."never"without a memory plugin that can serve authored docs, leaving the agent with no authored context.