Skip to content

[FEATURE]: Session Summarization with New Session Creation #21760

@PVLPM

Description

@PVLPM

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Add a feature to summarize the current session's context and seamlessly start a new session with that summary auto-loaded, enabling users to continue long-running tasks without losing critical information to context window limits or compaction-induced hallucinations/truncation.


Detailed Description

Problem Statement

When working on complex, multi-step tasks that span many turns, users eventually hit context window limits. The current options are:

  1. Compaction — Compresses conversation but is lossy (information gets truncated/hallucinated)
  2. Manual copy-paste — Tedious, error-prone, loses context granularity
  3. Start fresh — Lose all context, decisions, and progress (if no memory plugin is installed)

This creates a gap for users doing long implementation chains where continuity matters.

Proposed Solution

Implement a session summarization + new session creation flow:

  1. Trigger: Button in UI (over input field) + automatic warning at threshold (e.g., 50% context (can be configurable)) + slash command (e.g., /summarize-to-new)
  2. Process: Creates a new session with a system prompt referencing the old session ID
  3. Transfer: The new session's AI automatically reads and summarizes the referenced session's context
  4. Result: User lands in a new session with full awareness of previous work without context bleeding

User Experience Flow

[Session A - Context at 50%+]
┌───────────────────────────────────────┐
│  UI shows: "Summarize to New Session" │
│  button above input field             │
└───────────────────────────────────────┘
          │
          ▼ (user clicks)
[Session A] --summarization triggered--> [Session B created with prompt]
                                            "Summarize from ses_abc123"
                                                  │
                                                  ▼
                                         [Session B AI reads Session A]
                                                  │
                                                  ▼
                                         [Session B has full summary]
                                         [Ready to continue work]

Feature Specifications

1. Trigger Mechanisms

Trigger Description
Dedicated button Visible in UI above the input field, appears when context ≥50%
Automatic warning Toast/indicator when context exceeds 50% suggesting summarization
Slash command /summarize-to-new for power users (TUI accessibility)

2. Session Summary Contents

The summary should capture:

  • Original goal — What the user set out to accomplish
  • Decisions + rationale — Key architectural choices, trade-offs, why decisions were made
  • Pending tasks — What's left to do, blocked items, next steps
  • File changes — Files modified (optional, since git log can reconstruct this)
  • Related context — Any cross-session references if applicable

3. Session ID Integration

Element Behavior
Session ID display Show session ID somewhere in UI (chat header or status area)
Referencing User can mention session ID in new session by himself (e.g., "continue from ses_abc123")
Auto-load When new session references old session ID, AI automatically reads and summarizes that session's context

4. Transfer Mechanism

  • Direct transfer: Summary is transferred to new session automatically (no manual copy-paste)
  • No lossy compaction: Unlike compaction, this preserves full context fidelity
  • Review opportunity: User can review summary before it gets loaded if needed (optional)

5. Slash Command

/summarize-to-new [session-id-to-reference]
  • Without args: Summarizes current session and starts new one
  • With args: Creates new session that references specified session ID for summary

Comparison with Existing Patterns

Dyad Builder (Reference Implementation)

Dyad Builder implements similar functionality:

  • Button "Summarize to new session" appears at 50%+ context
  • Creates new session with prompt: "Summarize from chat-id=##"
  • AI in new session reads and summarizes the referenced session

OpenCode Compaction (Existing Mechanism)

Compaction compresses conversation history but is lossy — it truncates and can hallucinate details. This new feature:

  • Is non-lossy — preserves exact decisions, rationale, and context
  • Complements compaction rather than replacing it
  • Gives users a clean handoff option before compaction becomes necessary

This feature does NOT conflict with compaction — users can:

  1. Use summarization as a preventive measure (before hitting strict limits)
  2. Use compaction when summarization isn't triggered in time
  3. Both mechanisms can coexist serving different needs

Edge Cases & Considerations

Scenario Behavior
Session A is still active Summarization creates Session B referencing A
Session A is closed AI falls back to available session data (history still exists)
Referenced session was already summarized Chain references possible (A→B→C)
User starts new session without this feature Normal behavior, no changes
Multiple sessions open simultaneously Each session isolated, summarization is per-session

Implementation Notes

  • Session IDs should be human-readable and display in UI (e.g., ses_abc123)
  • The summarization prompt should be customizable or follow sensible defaults
  • Consider persisting summaries to .sessions/{session-id}.md for audit trail
  • Agent auto-load behavior should parse references naturally (e.g., "continue from ses_abc123")

Priority

High — This is a quality-of-life feature for users doing complex, multi-session work. It directly addresses context window limitations without resorting to lossy compaction.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions