Skip to content

fix: increase session TTL to 7 days - #39

Merged
four-bytes-robby merged 1 commit into
mainfrom
fix/session-ttl
Jun 14, 2026
Merged

fix: increase session TTL to 7 days#39
four-bytes-robby merged 1 commit into
mainfrom
fix/session-ttl

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Jun 14, 2026

Copy link
Copy Markdown
Member

Prevents active sessions from being evicted after 1 hour. Closes the token counter reset bug.

Change

  • src/four-opencode-token-budget-guard.ts: default FOUR_TBG_SESSION_TTL_MS from 60 * 60 * 1000 (1 hour) to 7 * 24 * 60 * 60 * 1000 (7 days)
  • Active sessions longer than 1 hour were being evicted from the SessionTokenCache, causing the token counter to reset mid-session

Why 7 days

  • Aligns with typical opencode session lifetime
  • Env var override (FOUR_TBG_SESSION_TTL_MS) still available for shorter/longer values

Summary by cubic

Increase the default session TTL from 1 hour to 7 days in SessionTokenCache to stop active-session eviction and token counter resets. Override via FOUR_TBG_SESSION_TTL_MS is still supported; change is in src/four-opencode-token-budget-guard.ts.

Written for commit 46e07dc. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

Chores

  • Extended default session timeout from 1 hour to 7 days, allowing users to maintain active sessions longer before automatic expiration.

@four-bytes-robby
four-bytes-robby merged commit 4ba9e26 into main Jun 14, 2026
2 of 3 checks passed
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f02d2d02-d911-43f1-9acf-d141942861fa

📥 Commits

Reviewing files that changed from the base of the PR and between 66b4d05 and 46e07dc.

📒 Files selected for processing (1)
  • src/four-opencode-token-budget-guard.ts

📝 Walkthrough

Walkthrough

The default fallback value for the FOUR_TBG_SESSION_TTL_MS environment variable, used when constructing SessionTokenCache, is increased from 1 hour (60 * 60 * 1000) to 7 days (7 * 24 * 60 * 60 * 1000).

Changes

Session TTL Default Update

Layer / File(s) Summary
SessionTokenCache default TTL: 1 hour → 7 days
src/four-opencode-token-budget-guard.ts
The hardcoded fallback for FOUR_TBG_SESSION_TTL_MS is changed from 60 * 60 * 1000 to 7 * 24 * 60 * 60 * 1000, extending the default session lifetime from 1 hour to 7 days.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/session-ttl

Comment @coderabbitai help to get the list of available commands and usage tips.

@four-bytes-robby
four-bytes-robby deleted the fix/session-ttl branch June 14, 2026 10:51
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.

1 participant