openclaw - ๐Ÿ’ก(How to fix) Fix Feature: Post-turn hook for persistent workspace protocol enforcement [1 comments, 2 participants]

Official PRs (โ€ฆ)
ON THIS PAGE

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#69921โ€ขFetched 2026-04-22 07:46:41
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ร—1

Root Cause

Long conversations suffer from context compression. After compression, workspace-based rules in AGENTS.md (like WAL/memory sync protocols) get ignored because they were only injected once at the beginning.

Fix Action

Fix / Workaround

Workaround (current)

Code Example

{
  "hooks": {
    "postTurn": "node /path/to/sync-state.js"
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Long conversations suffer from context compression. After compression, workspace-based rules in AGENTS.md (like WAL/memory sync protocols) get ignored because they were only injected once at the beginning.

Proposed Solution

Add a post-turn hook mechanism that runs after each assistant reply completes. This would allow:

  1. Executing a shell command or script after every turn
  2. Forcing a tool call (e.g., write to SESSION-STATE.md) at the end of each turn
  3. Configurable per-agent or globally

Example config:

{
  "hooks": {
    "postTurn": "node /path/to/sync-state.js"
  }
}

Or simpler: a system-level instruction that gets appended after every assistant message.

Use Case

  • Memory WAL protocol enforcement across long conversations
  • Auto-saving conversation state
  • Proactive agent tracking updates
  • Any operation that must persist regardless of context window pressure

Workaround (current)

Repeat critical constraints in SOUL.md/IDENTITY.md to increase retention probability, but this is unreliable.

extent analysis

TL;DR

Implement a post-turn hook mechanism to execute a script or command after each assistant reply, ensuring workspace-based rules are reapplied.

Guidance

  • Identify the specific rules in AGENTS.md that are being ignored after context compression and determine the best approach to reapply them using the post-turn hook.
  • Consider using the proposed config format to specify a post-turn hook, such as executing a shell command or script to sync state.
  • Evaluate the use of a system-level instruction that gets appended after every assistant message as an alternative solution.
  • Assess the feasibility of implementing the post-turn hook mechanism globally or on a per-agent basis.

Example

{
  "hooks": {
    "postTurn": "node /path/to/sync-state.js"
  }
}

This example config snippet demonstrates how to specify a post-turn hook using the proposed format.

Notes

The proposed solution assumes that the post-turn hook mechanism can be implemented in a way that is compatible with the existing system architecture. Additionally, the choice of script or command to execute after each turn will depend on the specific requirements of the workspace-based rules being reapplied.

Recommendation

Apply workaround: Implement the proposed post-turn hook mechanism to ensure that workspace-based rules are reapplied after each assistant reply, as this approach addresses the root cause of the issue and provides a flexible solution for various use cases.

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: Post-turn hook for persistent workspace protocol enforcement [1 comments, 2 participants]