openclaw - 💡(How to fix) Fix [Bug]: Active Memory recall context uses full OpenClaw prompt envelope [1 pull requests]

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…

Active Memory builds the recall subagent conversation context from the full before_prompt_build event.prompt, so Telegram/OpenClaw runtime envelopes can inflate recall prompts to ~30k chars even when the actual memory search query is clamped to ~480 chars.

Root Cause

Active Memory was pinned to xAI because the inherited OpenAI/Codex route timed out in the pre-prompt hook. With xAI, the recall runs complete, which exposes the remaining prompt-size bug separately from provider latency.

Fix Action

Fixed

Code Example

{
  "plugins": {
    "entries": {
      "active-memory": {
        "enabled": true,
        "config": {
          "enabled": true,
          "agents": ["main"],
          "allowedChatTypes": ["direct", "group"],
          "model": "xai/grok-4.20-beta-latest-non-reasoning",
          "thinking": "off",
          "timeoutMs": 8000,
          "setupGraceTimeoutMs": 2000,
          "logging": true,
          "persistTranscripts": false,
          "recentUserTurns": 2,
          "recentAssistantTurns": 1,
          "recentUserChars": 400,
          "recentAssistantChars": 250
        }
      }
    }
  }
}

---

2026-05-29T17:19:39.596+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=5646 searchQueryChars=480
2026-05-29T17:19:43.591+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=ok elapsedMs=3996 summaryChars=143

2026-05-29T17:24:24.249+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=30179 searchQueryChars=480
2026-05-29T17:24:28.158+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=ok elapsedMs=3910 summaryChars=157

2026-05-29T17:28:01.163+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=29351 searchQueryChars=479
2026-05-29T17:28:04.493+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=no_relevant_memory elapsedMs=3331 summaryChars=0

---

const query = buildQuery({
  latestUserMessage: event.prompt,
  recentTurns,
  config,
});
const searchQuery = buildSearchQuery({
  latestUserMessage: event.prompt,
  recentTurns,
});
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Active Memory builds the recall subagent conversation context from the full before_prompt_build event.prompt, so Telegram/OpenClaw runtime envelopes can inflate recall prompts to ~30k chars even when the actual memory search query is clamped to ~480 chars.

Steps to reproduce

  1. Run OpenClaw 2026.5.28-beta.1 with active-memory enabled for a Telegram group/topic session.
  2. Configure Active Memory with logging enabled and a fast model route.
  3. Send normal Telegram group/topic messages where OpenClaw assembles runtime/context metadata into the prompt envelope.
  4. Observe Active Memory log lines where queryChars is tens of thousands of chars while searchQueryChars remains ~480.

Expected behavior

Active Memory should derive the recall subagent's latest-user-message context from the actual current user request, or from a bounded/sanitized fallback, so channel/runtime metadata and historical OpenClaw context envelopes are not sent as the recall conversation context.

Actual behavior

The memory tool query is bounded, but the recall subagent's conversation context still receives the large assembled event.prompt envelope. In the observed Telegram topic, this produced queryChars=29351 and queryChars=30179 on ordinary user questions.

OpenClaw version

OpenClaw 2026.5.28-beta.1 (84fd629)

Operating system

Ubuntu 24.04 / Linux gateway host

Install method

npm global / systemd user gateway

Model

Main route: openai-codex/gpt-5.5; Active Memory route: xai/grok-4.20-beta-latest-non-reasoning

Provider / routing chain

OpenClaw gateway -> Telegram group/topic -> Active Memory bundled plugin -> xAI provider route for the recall subagent

Additional provider/model setup details

Active Memory was pinned to xAI because the inherited OpenAI/Codex route timed out in the pre-prompt hook. With xAI, the recall runs complete, which exposes the remaining prompt-size bug separately from provider latency.

Relevant config shape, redacted:

{
  "plugins": {
    "entries": {
      "active-memory": {
        "enabled": true,
        "config": {
          "enabled": true,
          "agents": ["main"],
          "allowedChatTypes": ["direct", "group"],
          "model": "xai/grok-4.20-beta-latest-non-reasoning",
          "thinking": "off",
          "timeoutMs": 8000,
          "setupGraceTimeoutMs": 2000,
          "logging": true,
          "persistTranscripts": false,
          "recentUserTurns": 2,
          "recentAssistantTurns": 1,
          "recentUserChars": 400,
          "recentAssistantChars": 250
        }
      }
    }
  }
}

Logs, screenshots, and evidence

2026-05-29T17:19:39.596+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=5646 searchQueryChars=480
2026-05-29T17:19:43.591+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=ok elapsedMs=3996 summaryChars=143

2026-05-29T17:24:24.249+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=30179 searchQueryChars=480
2026-05-29T17:24:28.158+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=ok elapsedMs=3910 summaryChars=157

2026-05-29T17:28:01.163+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning start timeoutMs=8000 queryChars=29351 searchQueryChars=479
2026-05-29T17:28:04.493+02:00 [plugins] active-memory: agent=main session=agent:main:telegram:group:-1003352789296:topic:74 activeProvider=xai activeModel=grok-4.20-beta-latest-non-reasoning done status=no_relevant_memory elapsedMs=3331 summaryChars=0

Source inspection on current main shows the direct cause:

const query = buildQuery({
  latestUserMessage: event.prompt,
  recentTurns,
  config,
});
const searchQuery = buildSearchQuery({
  latestUserMessage: event.prompt,
  recentTurns,
});

buildSearchQuery sanitizes and clamps the memory tool query to 480 chars, but buildQuery still uses the same unbounded prompt for the recall subagent's conversation context.

Impact and severity

Affected: Active Memory users on channel sessions where OpenClaw injects large runtime/context envelopes, observed on Telegram group topics.

Severity: Medium. Replies still complete with a fast recall model, but every affected turn wastes tokens and adds latency risk in a blocking pre-prompt hook. With slower or Codex-routed models, this can contribute to timeouts or circuit-breaker skips.

Frequency: Reproduced on multiple consecutive real Telegram topic turns in the same live gateway.

Consequence: Active Memory remains usable only with extra tuning, and the recall subagent sees context it was explicitly told not to use.

Additional information

Related but not exact duplicates:

  • #72015 tracks the broader blocking Active Memory reliability issue.
  • #86996 tracks Active Memory plus Codex app-server latency/timeouts.
  • #66060 covered older embedded-agent bootstrap prompt bloat and was closed as fixed.
  • #83752/#83773 cover Telegram Active Memory latency/RSS symptoms.

This report is narrower: even after the memory search query is bounded and the embedded agent bootstrap is lightweight, the recall subagent conversation context still uses the full event.prompt envelope.

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…

FAQ

Expected behavior

Active Memory should derive the recall subagent's latest-user-message context from the actual current user request, or from a bounded/sanitized fallback, so channel/runtime metadata and historical OpenClaw context envelopes are not sent as the recall conversation context.

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 [Bug]: Active Memory recall context uses full OpenClaw prompt envelope [1 pull requests]