Skip to content

feat(compaction): re-inject workspace context files after compaction#2020

Closed
mylukin wants to merge 1 commit intoopenclaw:mainfrom
mylukin:feat/after-compaction-context-injection
Closed

feat(compaction): re-inject workspace context files after compaction#2020
mylukin wants to merge 1 commit intoopenclaw:mainfrom
mylukin:feat/after-compaction-context-injection

Conversation

@mylukin
Copy link
Copy Markdown
Contributor

@mylukin mylukin commented Jan 26, 2026

Summary

This PR ensures that USER.md, SOUL.md, and IDENTITY.md are automatically re-injected into the compaction summary when context gets compressed. This solves the problem of the agent losing persona and user preferences after context compression.

Changes

  1. compaction-safeguard.ts:

    • Added buildContextRefreshSection() function to read and format workspace context files
    • Re-inject these files into the summary after compaction
  2. Plugin hook enhancement:

    • Modified after_compaction hook to support returning appendToSummary text
    • Allows plugins to inject additional context into the compaction summary

Testing

  • Manually verified that USER.md content is included in compaction summary
  • Build passes without errors

Related Issue

Fixes context compression causing loss of user preferences (English reply format, voice settings, etc.)

This change ensures that USER.md, SOUL.md, and IDENTITY.md are automatically
re-injected into the compaction summary, so the agent retains persona and
user preferences after context compression.

Changes:
- Add context file re-injection in compaction-safeguard.ts
- Wire up after_compaction plugin hook with result type for additional injection
- Allow plugins to append custom text to compaction summary via after_compaction hook

Closes: context compression causing loss of user preferences
@mylukin mylukin force-pushed the feat/after-compaction-context-injection branch from 55073d7 to bfa83bd Compare January 26, 2026 02:47
@mylukin
Copy link
Copy Markdown
Contributor Author

mylukin commented Jan 26, 2026

Closing: After investigation, the system prompt is rebuilt fresh each turn and bootstrap files are already re-injected. Context pruning only affects tool results, not the system prompt or workspace context files. This PR is not needed.

@mylukin mylukin closed this Jan 26, 2026
@mylukin mylukin deleted the feat/after-compaction-context-injection branch January 26, 2026 11:19
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