#18616: agents: add bootstrap retrieval mode to reduce prompt overhead
agents
stale
size: M
Cluster:
Security Enhancements and Fixes
Adds bootstrap retrieval mode (`off|auto|on`) to reduce prompt overhead by retrieving relevant excerpts instead of injecting full bootstrap files in large workspaces.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR introduces a bootstrap retrieval mode to optimize prompt size by retrieving relevant excerpts instead of injecting full bootstrap files in large workspaces.
- Added `bootstrapRetrieval` configuration with `off|auto|on` modes
- Implemented keyword-based scoring system with stopword filtering
- Created paragraph-based chunking with configurable size limits
- Prioritizes required files (AGENTS.md, SOUL.md, TOOLS.md) in selection
- Auto mode triggers when bootstrap content exceeds 12KB threshold
- Passes `retrievalPrompt` (user prompt) to scoring function for relevance ranking
- Added comprehensive E2E tests covering all three modes
- Configuration schema updated with help text and labels
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is well-tested with E2E coverage, follows existing patterns, and includes proper fallback behavior. The keyword-based retrieval logic is straightforward and doesn't introduce security concerns. Configuration validation is handled correctly. One minor optimization opportunity exists in required file selection, but it doesn't affect correctness.
- No files require special attention
<sub>Last reviewed commit: 1d3d65c</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9273: Add files via upload
by cyrilliu1974 · 2026-02-05
76.4%
#19879: Feat/foropenclaw bootstrapfiles clean
by akyourowngames · 2026-02-18
75.0%
#19826: fix: add in-prompt warnings and doctor check for bootstrap file tru...
by akramcodez · 2026-02-18
74.6%
#9521: fix: restrict bootstrap files for cron agentTurn sessions
by ComputClaw · 2026-02-05
74.2%
#13792: Claude/openclaw token efficiency q ni2s
by imecostalima · 2026-02-11
74.0%
#14701: Agent: enforce execute-first replies and clarify whisper modes
by Swader · 2026-02-12
73.7%
#20267: feat: workspace-aware post-compaction context
by nickjlamb · 2026-02-18
73.6%
#13524: feat: conditional bootstrap file loading for heartbeat vs DM sessions
by tarun131313 · 2026-02-10
73.4%
#22220: feat(bootstrap): cache session's bootstrap files so we don't invali...
by anisoptera · 2026-02-20
73.4%
#9677: feat: expose incomingMessage in bootstrap hook context
by speedbal · 2026-02-05
73.4%