Skip to content

feat: a thread keeps its own idle compaction choice - #37519

Closed
NeilTheFisher wants to merge 1 commit into
pingdotgg:mainfrom
NeilTheFisher:feat/idle-compaction-per-thread
Closed

NeilTheFisher wants to merge 1 commit into
pingdotgg:mainfrom
NeilTheFisher:feat/idle-compaction-per-thread

Conversation

@NeilTheFisher

Copy link
Copy Markdown

Problem

Idle compaction is a server/instance setting. A long thread you plan to come back to cannot opt into compacting while its prompt cache is still warm, and a thread you are done with keeps paying for it while you are away.

What changed

  • A thread stores its own idleCompaction (beforeCacheExpires | onReturn | off; absent or null inherits), carried by the existing thread.metadata.update command rather than a new one.
  • Resolution is thread → provider instance → server default (resolveThreadIdleCompaction), and a managed-policy lock on idleCompaction still outranks the thread.
  • The model picker footer gains a per-thread pill beside permissions, Claude-only because background compaction is driven by Claude's prompt-cache expiry.
  • The resume-compaction offer (the compact-before-send chip) is now capability-driven instead of hard-coded to claudeAgent: any provider that advertises a native /compact gets it. That adds OpenCode (v1 and v2), Codex, and the other native-compaction providers, and the per-thread choice plus policy lock apply to them too.
  • Mobile and the queued-message send path honour the same per-thread choice.

What stays Claude-only

Background compaction (sending /compact while you are away) fires on promptCacheExpiresAt, which only the Claude adapter reports. OpenCode gets the on-return offer instead, where /compact is the first turn when you come back, so nothing is spent while the thread sits idle.

Testing

  • vp run typecheck across the workspace and apps/web: clean.
  • settings.test.ts, contextWindow.test.ts, IdleCompaction.test.ts (5 new scheduler rows), the runtimeLayer lifecycle case, and the picker footer browser test pass.
  • Manual: toggled the pill against a running server and confirmed the tooltip, the stored thread value, and the resulting /compact turn.

Screenshots to follow.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@juliusmarminge

Copy link
Copy Markdown
Member

This has been a draft with no activity for more than three days, so it is being closed: the open pull requests are kept to work that is ready to be looked at.

Nothing is lost, the branch stays. When the work is ready, open a new pull request for it; this one will not be reopened.

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

Labels

needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants