Skip to content

Improve compaction messages to enable better post-compaction agent behavior#7259

Merged
tlongwell-block merged 1 commit intomainfrom
compaction-explicit-message
Feb 16, 2026
Merged

Improve compaction messages to enable better post-compaction agent behavior#7259
tlongwell-block merged 1 commit intomainfrom
compaction-explicit-message

Conversation

@tlongwell-block
Copy link
Collaborator

Summary

Updates the continuation messages injected after context compaction to explicitly inform the agent that its context was compacted. This gives the agent accurate information about its own state, enabling it to act appropriately after compaction events.

Problem

The previous wording was passive and indirect:

"The previous message contains a summary that was prepared because a context limit was reached."

This phrasing obscures what actually happened. The agent doesn't clearly understand that:

  1. Its context window was compacted
  2. It's now operating from a summary, not full conversation history
  3. It may need to re-verify assumptions or reload context

Solution

Updated all three continuation messages to use explicit, direct language:

"Your context was compacted. The previous message contains a summary of the conversation so far."

This accurate framing allows agents to:

  • Understand their current state
  • Make informed decisions about whether to reload context (e.g., re-read files, check TODO)
  • Avoid assumptions based on "remembered" details that may have been lost in summarization

Changes

  • CONVERSATION_CONTINUATION_TEXT — normal conversation flow
  • TOOL_LOOP_CONTINUATION_TEXT — compaction during active tool execution
  • MANUAL_COMPACT_CONTINUATION_TEXT — user-triggered /compact

Testing

All existing context_mgmt tests pass. No behavioral changes to compaction logic—this is purely a wording improvement to the injected messages.

…mpacted

Update all three continuation text constants to explicitly tell the LLM
that its context was compacted:

- CONVERSATION_CONTINUATION_TEXT: for normal conversation flow
- TOOL_LOOP_CONTINUATION_TEXT: when compaction happens mid-tool-loop
- MANUAL_COMPACT_CONTINUATION_TEXT: when user triggers /compact

The new wording uses 'Your context was compacted' rather than the passive
'a summary was prepared because a context limit was reached'. Also adds
consistent trailing periods to all three constants.
Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be even better if we just injected the reason into the template we render so this is just inside an {% if %} statement there, but we can do that some other time.

@tlongwell-block tlongwell-block added this pull request to the merge queue Feb 16, 2026
Merged via the queue into main with commit 23e5e57 Feb 16, 2026
25 of 26 checks passed
@tlongwell-block tlongwell-block deleted the compaction-explicit-message branch February 16, 2026 19:24
michaelneale added a commit that referenced this pull request Feb 17, 2026
* main:
  fix: handle reasoning_content for Kimi/thinking models (#7252)
  feat: sandboxing for macos (#7197)
  fix(otel): use monotonic_counter prefix and support temporality env var (#7234)
  Streaming markdown (#7233)
  Improve compaction messages to enable better post-compaction agent behavior (#7259)
  fix: avoid shell-escaping special characters except quotes (#7242)
tlongwell-block added a commit that referenced this pull request Feb 17, 2026
* origin/main:
  docs: playwright CLI skill tutorial (#7261)
  install node in goose dir (#7220)
  fix: relax test_basic_response assertion for providers returning reasoning_content (#7249)
  fix: handle reasoning_content for Kimi/thinking models (#7252)
  feat: sandboxing for macos (#7197)
  fix(otel): use monotonic_counter prefix and support temporality env var (#7234)
  Streaming markdown (#7233)
  Improve compaction messages to enable better post-compaction agent behavior (#7259)
  fix: avoid shell-escaping special characters except quotes (#7242)
  fix: use dynamic port for Tetrate auth callback server (#7228)
  docs: removing LLM Usage admonitions (#7227)
  feat(otel): respect standard OTel env vars for exporter selection (#7144)
  fix: fork session (#7219)
  Bump version numbers for 1.24.0 release (#7214)
  Move platform extensions into their own folder (#7210)
  fix: ignore deprecated skills extension (#7139)

# Conflicts:
#	Cargo.lock
#	Cargo.toml
zanesq added a commit that referenced this pull request Feb 17, 2026
…led-extensions-cmd

* 'main' of github.com:block/goose: (24 commits)
  Set up direnv and update flake inputs (#6526)
  fix: restore subagent tool call notifications after summon refactor (#7243)
  fix(ui): preserve server config values on partial provider config save (#7248)
  fix(claude-code): allow goose to run inside a Claude Code session (#7232)
  fix(openai): route gpt-5 codex via responses and map base paths (#7254)
  feat: add GoosePlatform to AgentConfig and MCP initialization (#6931)
  Fix copied over (#7270)
  feat(gemini-cli): add streaming support via stream-json events (#7244)
  fix: filter models without tool support from recommended list (#7198)
  fix(google): handle more thoughtSignature vagaries during streaming (#7204)
  docs: playwright CLI skill tutorial (#7261)
  install node in goose dir (#7220)
  fix: relax test_basic_response assertion for providers returning reasoning_content (#7249)
  fix: handle reasoning_content for Kimi/thinking models (#7252)
  feat: sandboxing for macos (#7197)
  fix(otel): use monotonic_counter prefix and support temporality env var (#7234)
  Streaming markdown (#7233)
  Improve compaction messages to enable better post-compaction agent behavior (#7259)
  fix: avoid shell-escaping special characters except quotes (#7242)
  fix: use dynamic port for Tetrate auth callback server (#7228)
  ...
katzdave added a commit to YusukeShimizu/goose that referenced this pull request Feb 17, 2026
* origin/main: (263 commits)
  working_dir usage more clear in add_extension (block#6958)
  Use Canonical Models to set context window sizes (block#6723)
  Set up direnv and update flake inputs (block#6526)
  fix: restore subagent tool call notifications after summon refactor (block#7243)
  fix(ui): preserve server config values on partial provider config save (block#7248)
  fix(claude-code): allow goose to run inside a Claude Code session (block#7232)
  fix(openai): route gpt-5 codex via responses and map base paths (block#7254)
  feat: add GoosePlatform to AgentConfig and MCP initialization (block#6931)
  Fix copied over (block#7270)
  feat(gemini-cli): add streaming support via stream-json events (block#7244)
  fix: filter models without tool support from recommended list (block#7198)
  fix(google): handle more thoughtSignature vagaries during streaming (block#7204)
  docs: playwright CLI skill tutorial (block#7261)
  install node in goose dir (block#7220)
  fix: relax test_basic_response assertion for providers returning reasoning_content (block#7249)
  fix: handle reasoning_content for Kimi/thinking models (block#7252)
  feat: sandboxing for macos (block#7197)
  fix(otel): use monotonic_counter prefix and support temporality env var (block#7234)
  Streaming markdown (block#7233)
  Improve compaction messages to enable better post-compaction agent behavior (block#7259)
  ...

# Conflicts:
#	crates/goose/src/providers/openai.rs
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.

2 participants

Comments