#9521: fix: restrict bootstrap files for cron agentTurn sessions
agents
stale
size: XS
Cluster:
Cron Job Enhancements
## Summary
Cron jobs with `agentTurn` payload now receive only `AGENTS.md` and `TOOLS.md`, matching sub-agent behavior.
Previously they received all 8 bootstrap files (SOUL.md, MEMORY.md, USER.md, IDENTITY.md, etc.) which is unnecessary for task-focused scheduled jobs.
## Changes
- Add `isCronSessionKey()` helper to detect cron session keys
- Add `isRestrictedBootstrapSession()` combining subagent + cron checks
- Rename `SUBAGENT_BOOTSTRAP_ALLOWLIST` to `RESTRICTED_BOOTSTRAP_ALLOWLIST`
- Update `filterBootstrapFilesForSession()` to use new combined check
## Impact
- Reduced token usage for cron jobs
- Faster cron execution
- Cleaner separation: task runners vs conversational sessions
## Before/After
| Session Type | Before | After |
|--------------|--------|-------|
| Main session | All 8 files | All 8 files |
| Sub-agent | AGENTS.md + TOOLS.md | AGENTS.md + TOOLS.md |
| Cron agentTurn | All 8 files ❌ | AGENTS.md + TOOLS.md ✅ |
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR introduces a shared `isRestrictedBootstrapSession()` predicate (sub-agent OR cron session) and updates workspace bootstrap filtering so restricted sessions only receive `AGENTS.md` and `TOOLS.md` instead of the full bootstrap set. The routing layer (`src/routing/session-key.ts`) now re-exports the new helpers from `src/sessions/session-key-utils.ts`, and `filterBootstrapFilesForSession()` in `src/agents/workspace.ts` uses that combined check to apply the allowlist.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are small, localized, and use the same session-key parsing pattern as existing helpers; no additional call sites were introduced beyond bootstrap filtering, and the behavior change matches the stated intent (cron agentTurn sessions now receive the restricted bootstrap set).
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#13524: feat: conditional bootstrap file loading for heartbeat vs DM sessions
by tarun131313 · 2026-02-10
80.0%
#20188: fix: Update sessionFile path when rolling to new session in cron jobs
by jriff · 2026-02-18
77.0%
#20072: feat(sessions_spawn): add sessionKey param to reuse sub-agent sessions
by Be1Human · 2026-02-18
76.9%
#16390: fix(cron): jobs land in wrong agent session when agentId isn't in a...
by yinghaosang · 2026-02-14
76.8%
#5977: fix(ui): handle optional agentId and add updateCronJob function
by xpnobug · 2026-02-01
76.8%
#22707: fix: pass agentDir to runEmbeddedPiAgent in cron isolated sessions
by mrlerner · 2026-02-21
76.6%
#12310: cron: pass agentDir to embedded runner for isolated sessions
by magendary · 2026-02-09
76.6%
#8097: fix: auto-convert one-shot reminders for reliable delivery
by Gerrald12312 · 2026-02-03
76.4%
#23501: fix(cron): force new session ID for isolated cron jobs (#23470)
by stakeswky · 2026-02-22
76.1%
#6315: fix(cron): persist isolated sessions (fixes #6217) - attempt 2
by ChaitanyaSai-Meka · 2026-02-01
76.0%