Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@austinm911
Copy link
Contributor

Problem

When returning to a Slack thread after >60 minutes, a new session was created, losing all conversation context.

Root Cause

The 60-minute idle timeout (designed for DMs) was resetting thread sessions:

const freshEntry = entry && Date.now() - entry.updatedAt <= idleMs;
// stale → new sessionId → new .jsonl → context lost

Solution

Thread sessions skip the idle timeout, preserving the existing session:

const isThreadSession = sessionKey.includes(":thread:");
const freshEntry = entry && (isThreadSession || Date.now() - entry.updatedAt <= idleMs);
// thread → same sessionId → same .jsonl → messages append → context preserved

Behavior:

  • Thread sessions: never expire (user can still /new or /compact to reset manually)
  • DM sessions: unchanged (still expire after idleMinutes)

Changes

File Change
src/auto-reply/reply/session.ts Skip idle check for :thread: sessions
src/auto-reply/reply/session.test.ts 3 new tests for idle timeout behavior

Testing

pnpm test src/auto-reply/reply/session  # 16 tests pass
pnpm lint                                # 0 warnings, 0 errors

austinm911 and others added 4 commits January 17, 2026 19:11
Hypothesis: The 60-minute idle timeout (DEFAULT_IDLE_MINUTES) is treating
thread sessions the same as DMs. When returning to a thread after >60 min,
a new session is created instead of continuing the existing one.

Relevant files documented for investigation.
Thread sessions (Slack threads, etc.) now have infinite idle timeout.
Users explicitly continue conversations in threads and expect full context
to always be available. They can manually /compact or /new if needed.

This fixes the issue where returning to a Slack thread after >60 min
would create a new session, losing all prior conversation history.

Session keys containing ':thread:' are now treated as always fresh.
@steipete
Copy link
Contributor

Landed on main via 367826f (feat(session): add daily reset policy).

Changes:

  • Daily reset policy (default 4am local) + per-type overrides + idle windows (first expiry wins); legacy idle-only preserved.
  • Shared reset policy helper used by auto-reply sessions, CLI session resolution, and web snapshots; thread detection honors thread metadata and key markers.
  • Added reset policy tests and updated docs + changelog.

Tests:

  • pnpm lint
  • pnpm build
  • pnpm test (failed: pi-embedded-runner.run-embedded-pi-agent.writes-models-json-into-provided-agentdir.test.ts timeouts; gateway.tool-calling.mock-openai.test.ts tick timeout; gateway/server.cron.test.ts timeouts)
  • pnpm docs:build
  • pnpm test (failed: pi-embedded-runner.run-embedded-pi-agent.writes-models-json-into-provided-agentdir.test.ts timeouts; gateway/server.cron.test.ts timeout)

@steipete steipete closed this Jan 18, 2026
@steipete
Copy link
Contributor

Follow-up landed on main via f86b24c (refactor(session): centralize thread reset detection).

Changes:

  • Centralized thread detection helper for reset type.
  • Added daily boundary + per-type reset tests and a session snapshot heartbeat override test.
  • Refactored session reset schema snippet reuse.

Tests:

  • pnpm lint
  • pnpm build
  • pnpm test
  • pnpm docs:build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants