Summary
Limit how long Claude sessions can run or how many turns they can take to prevent runaway costs.
Implementation Options
- Max turns - Count messages in a thread, stop responding after N turns
- Max duration - Track session start time, stop after X minutes
- Token budget - Track approximate token usage (harder to implement)
Suggested Behavior
MAX_TURNS_PER_SESSION=50 - After 50 back-and-forth messages, warn then stop
MAX_SESSION_DURATION_MS=3600000 - 1 hour max
- Send warning message before hitting limit
Priority
Lower - Claude Code already has its own context limits, this is a secondary safeguard
Related
- Independent of other safety features
Summary
Limit how long Claude sessions can run or how many turns they can take to prevent runaway costs.
Implementation Options
Suggested Behavior
MAX_TURNS_PER_SESSION=50- After 50 back-and-forth messages, warn then stopMAX_SESSION_DURATION_MS=3600000- 1 hour maxPriority
Lower - Claude Code already has its own context limits, this is a secondary safeguard
Related