← Back to PRs

#17321: feat: add configurable idle trigger system

by kmixter open 2026-02-15 16:59 View on GitHub →
gateway size: XL
## Summary - Adds a configurable idle trigger system that proactively messages users when sessions have been idle for a configured duration - Supports per-agent `session.onIdle` config with customizable delay, prompt, and IDLE.md file ## Test plan - [x] Unit tests included (`idle-trigger-runner.test.ts`) - [x] Tested that it works 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR implements a configurable idle trigger system that proactively messages users when sessions have been idle for a configured duration. The implementation closely follows the existing heartbeat runner pattern and includes proper error handling, comprehensive unit tests, and integration with the gateway lifecycle. **Key changes:** - Added `session.onIdle` configuration array supporting multiple triggers per agent with customizable delays, prompts, and IDLE.md files - Implemented per-trigger timestamp tracking (`lastIdleTriggeredAt`) to prevent duplicate triggers - Integrated idle trigger runner into gateway startup, shutdown, and hot-reload flows - Added IDLE_OK_TOKEN for silent acknowledgment pattern (similar to HEARTBEAT_OK) **Implementation highlights:** - Proper error handling with try/catch ensures runner continues after errors - Skip sessions without deliverable origins (e.g., webchat, cron) - Visibility checks respect channel-specific heartbeat settings - File-based triggers include IDLE.md content directly in prompts - Custom prompts take precedence over file-based configuration The code is production-ready with thorough test coverage and follows established patterns from the heartbeat system. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with minimal risk - implementation follows established patterns, includes comprehensive tests, and handles edge cases properly - Score reflects solid implementation quality with proper error handling, extensive test coverage (473 lines of tests), and successful integration into existing gateway infrastructure. The previously flagged error handling issue has been addressed. Minor inefficiency noted with double timestamp updates in success path is intentional per code comments. Zod schema could add validation for mutually exclusive fields but runtime handles gracefully. - No files require special attention - the implementation is well-structured and thoroughly tested <sub>Last reviewed commit: 44fc936</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs