#21542: feat(config): add injectMode for workspace bootstrap files
agents
size: S
## Summary
Add a new configuration option to control how often bootstrap files are injected:
- every-turn (default): Current behavior
- once: Inject only on first message (~90% token savings)
- minimal: Inject only AGENTS.md + TOOLS.md every turn
## Problem
All workspace bootstrap files injected every message = ~2MB redundant context per 100 messages.
## Solution
1. Added workspace.injectMode to config schema
2. Added inject-mode.ts helper functions
3. Backward compatible (defaults to every-turn)
## Files
- src/config/zod-schema.agent-defaults.ts
- src/agents/pi-embedded-helpers/inject-mode.ts (new)
Closes #21538
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a new `injectMode` configuration option to control bootstrap file injection frequency, but introduces a **breaking schema change** that will cause runtime errors.
**Critical Issue:**
- The schema changes `agents.defaults.workspace` from `z.string().optional()` to `z.object({ injectMode: ... }).optional()`, breaking all existing code that reads `workspace` as a string path
- Multiple files access `config.agents?.defaults?.workspace` expecting a string: `src/commands/setup.ts:42`, `extensions/llm-task/src/llm-task-tool.ts:188`, `src/wizard/onboarding.ts:149`, etc.
- Existing user configs with `workspace: "/path/to/dir"` will fail Zod validation
- No migration strategy or backward compatibility handling provided
**Additional Concerns:**
- The new `inject-mode.ts` file is never imported or used anywhere in the codebase, suggesting incomplete implementation
- The PR description claims "backward compatible" but the schema change is not backward compatible
**Recommendation:**
The `workspace` field needs to support both the legacy string format AND the new object format. Consider using `z.union([z.string(), z.object({ injectMode: ... })]).optional()` with proper type guards and migration logic.
<h3>Confidence Score: 0/5</h3>
- This PR contains a breaking schema change that will cause runtime failures
- Score of 0 (critical issues) because the schema change from string to object for `agents.defaults.workspace` breaks backward compatibility and will cause runtime errors in at least 10+ locations throughout the codebase where the field is accessed as a string. The PR claims to be "backward compatible" but introduces a breaking change without migration logic.
- src/config/zod-schema.agent-defaults.ts requires immediate attention - the workspace field change must be reverted or made truly backward compatible
<sub>Last reviewed commit: 5d832cb</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#15568: feat: configurable workspace context files (agents.defaults.context...
by koatora20 · 2026-02-13
79.1%
#19560: docs: refactor agent workspace default location & bootstrap configu...
by ashinkuniyil · 2026-02-17
74.4%
#19879: Feat/foropenclaw bootstrapfiles clean
by akyourowngames · 2026-02-18
72.9%
#10943: fix(config): resolve Control UI "Unsupported schema node" for confi...
by kraftbj · 2026-02-07
72.2%
#22140: feat(config): add usageDefault to agent defaults for persistent /us...
by Mellowambience · 2026-02-20
71.8%
#22917: fix: Use agent's configured workspace when spawned as subagent
by jriff · 2026-02-21
69.7%
#9726: feat: add identityDir config for separate identity file location
by rickburn · 2026-02-05
69.7%
#11096: fix(plugins): require explicit trust for workspace and external plu...
by T1mn · 2026-02-07
69.7%
#20267: feat: workspace-aware post-compaction context
by nickjlamb · 2026-02-18
69.6%
#14640: feat(agents): support per-agent temperature and maxTokens in agents...
by lailoo · 2026-02-12
69.5%