Skip to content

[FEATURE]: Re-announce tools after context compaction #20290

Closed as not planned
Closed as not planned

Description

@AndresCdo

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

After context compaction, the model loses awareness of available tools and capabilities because the compacted message history no longer contains the original tool announcements.

Problem: When SessionCompaction.process() runs, it replaces the full message history with a summary. The model no longer sees the tool definitions that were present in earlier turns. This can cause the model to:

  • Stop using tools it previously had access to
  • Become confused about what capabilities are available
  • Ask the user to re-list available tools

Proposed Solution: After compaction completes, inject a synthetic user message that reminds the model it still has access to all previously available tools and should continue with its current task.

// After compaction.process() returns "continue":
const userMsg: MessageV2.User = {
  id: MessageID.ascending(),
  sessionID,
  role: "user",
  time: { created: Date.now() },
  agent: lastUser.agent,
  model: lastUser.model,
}
yield* sessions.updateMessage(userMsg)
yield* sessions.updatePart({
  id: PartID.ascending(),
  messageID: userMsg.id,
  sessionID,
  type: "text",
  text: "<system-reminder>Context was compacted. You still have access to all previously available tools and capabilities. Continue with your current task.</system-reminder>",
  synthetic: true,
})

Impact: Prevents model confusion after compaction, especially in long-running agentic sessions where compaction happens multiple times.

Risk: Minimal — single synthetic message, marked as synthetic: true so it does not appear in user-facing history.

Related

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 31, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions