GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: enhance compaction prompts for higher-fidelity context restoration by ryanwyler · Pull Request #4 · gignit/opencode

Conversation

@ryanwyler

@ryanwyler ryanwyler commented Mar 1, 2026

Copy link
Copy Markdown

Issue for this PR

Closes anomalyco#3031
Also addresses anomalyco#14368 and anomalyco#2945

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Provides SIGNIFICANT improvements for maintaining a session after compaction. This rewrites the compaction system prompt and inline template so the agent retains significant working context to continue after compaction. Re-frames compaction as a memory transfer rather than a summary, expands the inline template from 5 sections to 8 (adding separated User Directives, Failed Approaches, Resolved Code and Discoveries, and How Things Work Now), and adds imperative preservation rules for resolved code, credentials, and user corrections.

Good to use paired with this PR to be able to use different models during compaction controlled via TUI: anomalyco#14665

How did you verify your code works?

Tested against a real multi-hour session export, comparing compaction output across 5 prompt iterations. Final version benchmarked against a 22-cycle reference compaction from the same session.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ryanwyler
feat: enhance compaction prompts for higher-fidelity context restoration
5bf2540
Rewrite both the system prompt (compaction.txt) and the inline user
message template (compaction.ts defaultPrompt) to produce compaction
output that enables an AI agent to resume complex work after a full
context wipe.

## System prompt (compaction.txt)

Reframed from summarization to memory transfer. The model is told its
context is about to be wiped and everything not written down will be
lost. Preservation rules are direct commands, not conditionals:

- PRESERVE resolved code verbatim — query patterns, state machines,
  auth flows, data model behaviors, correct field names, API response
  shapes. Do not describe code that you can show.
- INCLUDE failed approaches numbered for cross-cycle reference
- PRESERVE user directives as sacred, accumulating across cycles
- PRESERVE credentials and operational details
- RESOLVE implementation contradictions to settled state
- DISCARD debugging noise, narration, superseded work, trivial code

## Inline template (compaction.ts defaultPrompt)

Expanded from 5 sections to 8, structured around what an agent needs
most when told to continue with no prior context:

1. Objective — immediate next action, current blockers
2. User Directives — separated from task instructions, accumulate
3. Plan — remaining steps, enough detail to pick up mid-step
4. Failed Approaches — exhaustive, numbered, highest-value section
5. Resolved Code & Discoveries — verbatim code blocks and patterns
   that would be painful to rediscover
6. How Things Work Now — settled system state as direct instructions
7. Accomplished — completed, in-progress, remaining as direct facts
8. Relevant files / environment — modification status, credentials,
   credential sync locations, endpoints, service ports

## Approach

Developed through iterative testing against a long-running multi-
compaction session, comparing output quality at each step. Key
phrasings were refined based on measurable differences in what the
model chose to preserve or discard — particularly around verbatim
code inclusion, failed approach depth, and credential capture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Model in BUILD mode does not have enough context to continue after compaction

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ryanwyler
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.