openclaw - 💡(How to fix) Fix [Feature]: session_compact gateway method [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#68663Fetched 2026-04-19 15:08:56
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
renamed ×2labeled ×1

Add a gateway method session_compact that wraps the internal compactEmbeddedPiSessionDirect, callable via the plugin SDK's registerGatewayMethod, providing agents a proactive alternative on top of manual /compact commands or reactive triggers like compaction.safe.mode and compaction.reserveTokensFloor."

Root Cause

Add a gateway method session_compact that wraps the internal compactEmbeddedPiSessionDirect, callable via the plugin SDK's registerGatewayMethod, providing agents a proactive alternative on top of manual /compact commands or reactive triggers like compaction.safe.mode and compaction.reserveTokensFloor."

RAW_BUFFERClick to expand / collapse

Summary

Add a gateway method session_compact that wraps the internal compactEmbeddedPiSessionDirect, callable via the plugin SDK's registerGatewayMethod, providing agents a proactive alternative on top of manual /compact commands or reactive triggers like compaction.safe.mode and compaction.reserveTokensFloor."

Benefits

  • Immersive conversations: Agents can advice or tell you if you want to compact conversation before continuing
  • Lessen context overflow errors. During mid-conversation users can sometimes forgot to do /compact
  • 3 layers of context overflow protections. proactive, reactive and manual

Problem to solve

  • Allows agents to have capability to perform autonomous compaction between sessions.
  • Gives agents decisions to perform compaction in between sessions
  • Agents have no autonomous context management: Session compaction currently requires the user to manually run /compact; agents can't detect or trigger it themselves
  • Provide an alternative to manual compaction and compaction.mode and compaction.reserveTokensFloor configuration

Proposed solution

Add a session_compact gateway method via registerGatewayMethod in the plugin SDK that wraps the existing internal compactEmbeddedPiSessionDirect function.

or

Expose compactEmbeddedPiSession (or a public wrapper) via the plugin SDK's registerGatewayMethod allowing plugins to register a gateway method that wraps the internal compaction function.

Alternatives considered

Tried to create a plugin to enforce the proposed solution, but ended up discovering that there is no API exposed for the plugin

Impact

Affected users/systems/channels:

  • OpenClaw agents built on the plugin SDK
  • Any agent session that handles complex, multi-step, or long-running tasks
  • All channels (WhatsApp, Discord, Telegram, etc.) where OpenClaw agents operate

Severity:

  • Blocks workflow when context fills, the session dies mid-task with no recovery; the user must manually /new and restore context
  • Annoying even before death, rising context causes degraded performance and slower responses

Frequency:

  • Always for sessions that accumulate meaningful context the longer the session, the more inevitable the overflow
  • More frequent for agents doing research, coding, analysis, or any task-heavy workload

Consequence:

  • Session death mid-task, losing all in-flight context and continuity
  • Manual recovery required: user must manually run /new, losing conversation history
  • Extra manual work: agents cannot self-manage their context; users must babysit and manually trigger compaction

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Implement a gateway method session_compact via the plugin SDK's registerGatewayMethod to enable agents to perform autonomous session compaction.

Guidance

  • To address the issue, consider exposing the compactEmbeddedPiSessionDirect function or a public wrapper via the plugin SDK, allowing plugins to register a gateway method for session compaction.
  • Verify the feasibility of this approach by checking the plugin SDK's documentation and existing API endpoints for similar functionality.
  • Assess the potential impact on affected users and systems, including OpenClaw agents and channels like WhatsApp, Discord, and Telegram.
  • Evaluate the severity and frequency of context overflow errors to determine the priority of implementing this solution.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The proposed solution relies on the existence of the compactEmbeddedPiSessionDirect function and the plugin SDK's registerGatewayMethod. If these components are not available or have limitations, alternative approaches may be necessary.

Recommendation

Apply the workaround by implementing the session_compact gateway method via the plugin SDK, as it provides a proactive alternative to manual compaction and reactive triggers, addressing the root cause of context overflow errors.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: session_compact gateway method [1 participants]