Problem
Long-running AI coding sessions accumulate large context windows, which degrades response quality and increases cost. There is currently no signal nudging the user to start a fresh session once a conversation has gone on for many turns.
Proposed Solution
Add a new prompt-submit (UserPromptSubmit) hook handler that counts human conversation turns per session and injects a gentle, one-time reminder when the count crosses a threshold.
- Threshold: default 20 turns, overridable via
TEAMAI_TURN_LIMIT.
- Frequency: hint once per session (fires on the first crossing, then stays quiet).
- Kill switch:
TEAMAI_TURN_HINT_DISABLED=1, independent from TEAMAI_RECALL_DISABLED.
Why this fits cleanly
- The hook dispatcher already fires on
prompt-submit for every user message (trackSlashHandler is already wired there), so one user turn == one prompt-submit.
- Handler return values are injected back into the session by the host (
hookSpecificOutput.additionalContext).
- Per-session counting + 24h TTL dedup is an established pattern (
todowrite-hint.ts).
Net change: one new handler + one small module. No dispatcher changes, no new command.
Implementation sketch
src/turn-limit-hint.ts — count store at ~/.teamai/sessions/<sid>-turn-count.json (24h TTL), resolveTurnLimit(), recordTurnAndShouldHint(), buildTurnLimitHintMessage().
- Register
turnLimitHintHandler on prompt-submit in hook-handlers.ts.
- Unit tests (threshold, once-only, TTL reset, env override, disable switch).
- End-to-end verification with the real CLI via
hook-dispatch prompt-submit.
- Sync docs (README + README.zh-CN + usage-guide both languages).
Alternatives Considered
- Count on
stop instead of prompt-submit: rejected — stop fires per assistant turn including tool loops, so it doesn't map to "human turns".
- Hard-block via
continue:false: rejected — too disruptive; a soft additionalContext nudge lets the model relay it at a natural moment.
- Reuse
TEAMAI_RECALL_DISABLED as the switch: rejected — coupling unrelated features; a dedicated switch is clearer.
Additional Context
Turn semantics: counts UserPromptSubmit events only; subagent round-trips and tool calls do not count, matching the "human conversation" intent.
Problem
Long-running AI coding sessions accumulate large context windows, which degrades response quality and increases cost. There is currently no signal nudging the user to start a fresh session once a conversation has gone on for many turns.
Proposed Solution
Add a new
prompt-submit(UserPromptSubmit) hook handler that counts human conversation turns per session and injects a gentle, one-time reminder when the count crosses a threshold.TEAMAI_TURN_LIMIT.TEAMAI_TURN_HINT_DISABLED=1, independent fromTEAMAI_RECALL_DISABLED.Why this fits cleanly
prompt-submitfor every user message (trackSlashHandleris already wired there), so one user turn == oneprompt-submit.hookSpecificOutput.additionalContext).todowrite-hint.ts).Net change: one new handler + one small module. No dispatcher changes, no new command.
Implementation sketch
src/turn-limit-hint.ts— count store at~/.teamai/sessions/<sid>-turn-count.json(24h TTL),resolveTurnLimit(),recordTurnAndShouldHint(),buildTurnLimitHintMessage().turnLimitHintHandleronprompt-submitinhook-handlers.ts.hook-dispatch prompt-submit.Alternatives Considered
stopinstead ofprompt-submit: rejected —stopfires per assistant turn including tool loops, so it doesn't map to "human turns".continue:false: rejected — too disruptive; a soft additionalContext nudge lets the model relay it at a natural moment.TEAMAI_RECALL_DISABLEDas the switch: rejected — coupling unrelated features; a dedicated switch is clearer.Additional Context
Turn semantics: counts UserPromptSubmit events only; subagent round-trips and tool calls do not count, matching the "human conversation" intent.