openclaw - 💡(How to fix) Fix Feature: Cross-session context injection via channel mentions [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#59862Fetched 2026-04-08 02:39:41
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Fix Action

Fix / Workaround

  1. Agent-level workaround (available today): The agent can use sessions_list + sessions_history manually, but this is ad-hoc, burns tokens per use, and requires the agent to "know" it should do this.

Code Example

{
  session: {
    crossSessionContext: {
      enabled: false,          // opt-in
      maxTokens: 2000,         // per-run budget for injected context
      summaryDepth: 50,        // messages to consider for summary
      cacheTtlMinutes: 30,     // cache summaries
      strategy: "summary",     // "summary" | "raw" | "hybrid"
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

OpenClaw sessions are isolated silos. When an agent builds deep context in one channel (e.g. a long-running project discussion in #popt-ai), that knowledge is trapped — inaccessible to other sessions without manual copy-paste or the agent explicitly using sessions_history.

In Discord (and potentially other platforms), users naturally reference other channels with #channel-name mentions. These are already rendered as <#channelId> in the message body, but OpenClaw does not act on them.

Proposed solution

When a message contains a channel mention (<#channelId>), OpenClaw should optionally resolve it to the bound session and inject a compressed summary of that session's recent context into the current run.

Flow:

  1. Gateway detects <#channelId> pattern(s) in the inbound message
  2. Resolves channel ID → session key via the session store
  3. Fetches recent history from the target session (configurable depth)
  4. Generates a compressed summary (LLM-generated or last-N messages)
  5. Injects the summary into the current run's context (e.g. as a system prompt addition or a synthetic context block)

Example user experience:

User in #frontend: "Use the API design we discussed in #backend — apply it to the new components"

Agent receives the #backend session summary automatically and can act on it without the user re-explaining.

Design considerations

Summary strategy

  • Default: LLM-generated summary of last N messages (token-efficient)
  • Optional: raw last-N messages for full fidelity (--full or config flag)
  • Cache summaries with a TTL to avoid re-summarizing on every mention

Token budget

  • Injected cross-session context should respect a configurable token cap (e.g. crossSessionContext.maxTokens: 2000)
  • Multiple channel mentions in one message should share the budget

Config surface

{
  session: {
    crossSessionContext: {
      enabled: false,          // opt-in
      maxTokens: 2000,         // per-run budget for injected context
      summaryDepth: 50,        // messages to consider for summary
      cacheTtlMinutes: 30,     // cache summaries
      strategy: "summary",     // "summary" | "raw" | "hybrid"
    }
  }
}

Security / scoping

  • Only inject from sessions belonging to the same agent (no cross-agent leaks by default)
  • Respect sendPolicy — if a session is deny, don't expose its content
  • Option to allowlist/denylist specific sessions for cross-injection

Platform support

  • Discord: <#channelId> — natural fit, already parsed
  • Slack: <#C123|channel-name> — same pattern
  • Other platforms: could support explicit syntax like @session:key or #channel-name

Implementation paths

  1. Hook-based (plugin): A message:received or message:preprocessed hook detects mentions, fetches history, and injects context. Could work with existing context engine plugin API (systemPromptAddition).

  2. Core feature: Native gateway support in the message pipeline. More efficient (no extra LLM call for caching), better UX, and consistent across channels.

  3. Agent-level workaround (available today): The agent can use sessions_list + sessions_history manually, but this is ad-hoc, burns tokens per use, and requires the agent to "know" it should do this.

Prior art / related

  • sessions_history tool already supports cross-session reads
  • bootstrap-extra-files hook demonstrates dynamic context injection
  • Context Engine plugin API (assemblesystemPromptAddition) provides the injection point
  • Channel .md files in workspace are a static version of per-channel context

Open questions

  • Should the summary be visible to the user (e.g. "📎 Injected context from #backend: ...")?
  • Should this work bidirectionally (both sessions get each other's context)?
  • How to handle stale sessions (last active 2 weeks ago)?
  • Should the agent be able to trigger this programmatically (e.g. sessions_context(sessionKey) tool)?

extent analysis

TL;DR

To address the issue of isolated OpenClaw sessions, implement a feature to resolve channel mentions and inject a compressed summary of the referenced session's recent context into the current run.

Guidance

  • Detect channel mentions (<#channelId>) in inbound messages and resolve them to the bound session key via the session store.
  • Fetch recent history from the target session and generate a compressed summary (e.g., LLM-generated or last-N messages).
  • Inject the summary into the current run's context, respecting a configurable token cap and caching summaries to avoid re-summarization.
  • Consider implementing this feature as a core functionality or a plugin, ensuring security and scoping to prevent cross-agent leaks and respecting sendPolicy.

Example

No explicit code example is provided, but the implementation could involve modifying the message pipeline to detect channel mentions and inject context using the Context Engine plugin API (systemPromptAddition).

Notes

The proposed solution requires careful consideration of design aspects, such as summary strategy, token budget, and security/scoping. The implementation path chosen (hook-based, core feature, or agent-level workaround) will impact the efficiency, UX, and consistency of the solution.

Recommendation

Apply a workaround by using the sessions_list and sessions_history tools manually, although this is ad-hoc and burns tokens per use. A more efficient solution would be to implement the proposed feature as a core functionality or a plugin, ensuring a consistent and efficient UX across channels.

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: Cross-session context injection via channel mentions [1 participants]