#7975: feat(commands): add /reset-context command
docs
stale
Cluster:
Context Management Enhancements
## Summary
- Adds `/reset-context` text-only command that provides a "panic button" for context overflow
- Runs compaction, checks usage %, and advises `/new` if still >70%
## Behavior
1. Runs `/compact` on current session
2. Checks context usage percentage after compaction
3. If ≤70%: `✅ Сжато. Текущая загрузка: 45%`
4. If >70%: `⚠️ Контекст слишком большой (82%). Отправьте /new`
## Files
- `src/auto-reply/reply/commands-reset-context.ts` - handler
- `src/auto-reply/reply/commands-reset-context.test.ts` - 5 tests
- `src/auto-reply/commands-registry.data.ts` - command registration
- `src/auto-reply/reply/commands-core.ts` - handler import
- `docs/tools/slash-commands.md` - docs EN
- `docs/zh-CN/tools/slash-commands.md` - docs ZH
## Test plan
- [x] `pnpm vitest run commands-reset-context.test.ts` - 5/5 passed
- [x] `pnpm build` - success
- [ ] Manual test in Telegram
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds a new text-only `/reset-context` slash command that aborts any active embedded PI run, triggers a compaction, then reports post-compaction context usage and suggests `/new` when usage remains above 70%. Wires the handler into the command dispatch list, registers the command in the chat command registry, adds Vitest coverage for core behaviors, and documents the command in EN and zh-CN slash-command docs.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but has a couple behavior inconsistencies that could surprise users on some surfaces.
- Core changes are localized (new command handler + registry/docs/tests) and follow existing compaction patterns, but `/reset-context` currently ignores the `allowTextCommands` gate and always stops further processing even when compaction fails, which can change behavior in restricted surfaces or failure modes.
- src/auto-reply/reply/commands-reset-context.ts (text command gating, failure-mode behavior, usage% calculation); tests lock in Russian responses.
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#18997: fix: improve context overflow error messages and docs
by realhoratiobot · 2026-02-17
78.2%
#12965: fix: suggest /clear in context overflow error message
by asklee-klawd · 2026-02-10
76.6%
#15749: fix: improve context overflow error with diagnostic details
by superlowburn · 2026-02-13
75.1%
#5360: fix(compaction): add emergency pruning for context overflow
by sgwannabe · 2026-01-31
73.8%
#19923: feat: track held messages during compaction gate and split verifica...
by PrivacySmurf · 2026-02-18
73.6%
#20861: feat(context): add conversation transcript stats to /context command
by davidrudduck · 2026-02-19
73.5%
#10273: fix(agents): detect and auto-compact mid-run context overflow
by terryops · 2026-02-06
72.6%
#6059: fix #6044
by vivganes · 2026-02-01
72.5%
#9620: fix: increase auto-compaction reserve buffer to 40k tokens
by Arlo83963 · 2026-02-05
72.4%
#13318: fix(agents): prevent sanitizeUserFacingText from rewriting conversa...
by hleliofficiel · 2026-02-10
72.2%