Skip to content

feat: use Codex-style compaction prompt for context compression - #1269

Closed
teknium1 wants to merge 2 commits into
mainfrom
hermes/hermes-8ea7cef0
Closed

feat: use Codex-style compaction prompt for context compression#1269
teknium1 wants to merge 2 commits into
mainfrom
hermes/hermes-8ea7cef0

Conversation

@teknium1

@teknium1 teknium1 commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m pytest tests/agent/test_context_compressor.py -n0 -q
  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m pytest tests/ -n0 -q
  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m hermes_cli.main chat -q "Say hello in three words."

Replace the generic summarization prompt ('Summarize these conversation
turns concisely') with a task-oriented handoff prompt inspired by
OpenAI's Codex CLI compaction flow (researched in #499).

The new prompt frames compression as a 'CONTEXT CHECKPOINT COMPACTION'
and instructs the summarization model to produce a structured handoff
summary that includes:
- Current progress and key decisions
- User preferences and constraints discovered
- Clear next steps remaining
- Critical data (file paths, URLs, error messages, code snippets)
- Tool calls made and their key results

This produces better summaries because the model understands the summary
will be used by another LLM to continue the work, rather than treating
it as a generic text compression task.

No behavioral change to the compression algorithm itself — same
positional protection, same role alternation, same [CONTEXT SUMMARY]:
prefix. Only the prompt sent to the summarization model changes.

Inspired by PR #776 by @kshitijk4poor.
@teknium1

Copy link
Copy Markdown
Contributor Author

Superseded — the current compressor prompt on main is already a structured handoff format with explicit sections (Goal, Constraints, Progress, Key Decisions, Relevant Files, Next Steps, Critical Context) plus iterative compression support. This is more detailed and structured than the Codex-style prompt proposed here.

@teknium1 teknium1 closed this Mar 26, 2026
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