Skip to content

fix: return user-facing error when session reset after compaction failure#1187

Merged
steipete merged 3 commits intoopenclaw:mainfrom
fayrose:fix/compaction-failure-silent-reset
Jan 18, 2026
Merged

fix: return user-facing error when session reset after compaction failure#1187
steipete merged 3 commits intoopenclaw:mainfrom
fayrose:fix/compaction-failure-silent-reset

Conversation

@fayrose
Copy link

@fayrose fayrose commented Jan 18, 2026

Problem

When auto-compaction fails due to context overflow, the system resets the session and silently continues the execution loop without sending any response to the user. This makes it appear as if messages are being ignored, which is confusing and feels like data loss.

Root Cause

In agent-runner-execution.ts, when resetSessionAfterCompactionFailure() is called, the code uses continue to restart the loop instead of returning a user-facing response. Compare this to how role ordering conflicts are handled - they properly return an error message to the user.

Solution

  1. Replace the silent continue with a proper return that sends the user a clear error message
  2. Include actionable advice on how to prevent future occurrences

The error message now reads:

⚠️ Context limit exceeded during compaction. I've reset our conversation to start fresh - please try again.

To prevent this, increase your compaction buffer by setting agents.defaults.compaction.reserveTokensFloor to 4000 or higher in your config.

Changes

  • src/auto-reply/reply/agent-runner-execution.ts:
    • Embedded error context overflow case returns user message with config tip
    • Catch block compaction failure case returns user message with config tip

Testing

Tested on production instance experiencing this bug. After the fix:

  • Users receive clear error message instead of silence
  • Users get actionable config suggestion to prevent recurrence

…lure

Previously, when auto-compaction failed due to context overflow, the system
would reset the session and silently continue the execution loop without
sending any response to the user. This made it appear as if messages were
being ignored.

This change ensures users receive a clear error message explaining that
the context limit was exceeded and the conversation has been reset,
consistent with how role ordering conflicts are already handled.

Fixes the silent failure case where message + compaction exceeds context limits.
When context limit is exceeded, the error message now suggests
setting agents.defaults.compaction.reserveTokensFloor to 4000
or higher to prevent future occurrences.
@steipete
Copy link
Contributor

  • High: tests now assert retry + 2nd successful run, but new behavior
    returns a final error after reset. Update expectations or keep
    retry logic. src/auto-reply/reply/agent-runner.heartbeat-
    typing.runreplyagent-typing-heartbeat.retries-after-compaction-
    failure-by-resetting-session.test.ts:124 and src/auto-reply/reply/
    agent-runner.heartbeat-typing.runreplyagent-typing-
    heartbeat.retries-after-compaction-failure-by-resetting-
    session.test.ts:175
  • Medium: reset log says “and retrying,” but code now returns
    immediately. Update log or behavior. src/auto-reply/reply/agent-
    runner.ts:279
  • Low: user guidance says set reserveTokensFloor to 4000, but docs
    default is 20000; guidance may be misleading. Consider referencing
    default or docs. src/auto-reply/reply/agent-runner-execution.ts:393

@steipete
Copy link
Contributor

Thanks Lauren, looking into this - agree the current behavior is not ideal!

@steipete steipete merged commit a136c6a into openclaw:main Jan 18, 2026
16 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: $land_sha
  • Merge commit: $merge_sha

Thanks @fayrose!

@steipete
Copy link
Contributor

Landed follow-up fixes on main:

  • guard docs:list when docs dir missing (86950d3)
  • changelog entry for docs:list guard (ef125d5)
  • Gate: pnpm lint && pnpm build && pnpm test

PR already merged on 2026-01-18; no close action needed. Thanks @fayrose!

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.

3 participants