#Cancel LLM request

1 messages · Page 1 of 1 (latest)

gritty geyser
#

Is there a way in OpenClaw to persist an inbound message to the session history and transcript without triggering any LLM API call? I need the agent to maintain full conversation context for future turns, but I want to skip the inference and the external request entirely for specific messages while ensuring they are still saved to the session file.

orchid eagleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

gritty geyser
#

@fresh hawk

gritty geyser
#

@fresh hawk

fresh hawkBOT
# gritty geyser <@1457407575476801641>

For inbound channel messages (Discord/Telegram/WhatsApp/etc): if the message is accepted/routed to an agent session, OpenClaw currently always enqueues an agent run, which means it will attempt an LLM call. There isn’t a built-in “persist to transcript/history but don’t run inference” switch on a per-message basis.

What does exist today (no model call):

  • chat.inject (Gateway WebSocket) — this appends an assistant note directly into the session transcript and broadcasts a UI update (no agent run, no channel delivery, no LLM request). It’s what Control UI / WebChat use for “just write into the transcript”.
  • Docs: https://docs.openclaw.ai/web/control-ui (see the chat.inject bullet)

Caveat: chat.inject writes an assistant entry (not a “user/inbound” role message). If you need true “inbound/user” entries without a run, that’s not exposed right now.

If your use case requires “store inbound user message verbatim, but do not run”, I’d treat it as a feature request (something like chat.append { role: user|assistant, run: false } or an inbound routing mode “logOnly”). Best next step is filing a GitHub issue with your exact workflow + which channel you’re using:
https://github.com/openclaw/openclaw/issues

gritty geyser
#

With discord, I want to able to skip messages (require mention behaviour with messages without mention, but with other conditions, more general, for example being able to modify the should skip variable, to skip message based on a general rule).

For example, on discord, requireMention is false, but the bot only activates with a probability p, and thus not doing a LLM request for every message

fresh hawkBOT
# gritty geyser With discord, I want to able to skip messages (require mention behaviour with me...

On Discord specifically, the only built-in way to skip messages before an agent run (so: no LLM call) is mention gating (plus allowlists / groupPolicy).

So if requireMention: false, OpenClaw treats that channel as always-on and it will enqueue a run for every message (even if the model later decides to output NO_REPLY).

What you can do today (no LLM call for most messages)

  1. Turn mention gating back on at the guild/channel level:
channels: {
discord: {
guilds: {
"123...": {
requireMention: true,
channels: {
"general": { allow: true, requireMention: true },
},
#
},
},
},
}
  1. If you want “other conditions” besides a literal @mention, use mentionPatterns (regex). These patterns count as a “mention” and will trigger the bot even without @botname:
agents: {
list: [{
id: "main",
groupChat: {
mentionPatterns: [
"^!claw\\b", // prefix trigger
"\\bopenclaw\\b", // keyword trigger
#
],
},
}],
}

That gets you: “skip most messages (no run), but still activate on my custom triggers”.

What you can’t do (without code changes / a proxy)

  • A general “shouldSkip” rule you can customize (e.g. activate with probability p, or arbitrary predicates) does not exist in config right now.
  • Also: if a message is skipped by mention gating, it’s dropped early (so it won’t be persisted to the session transcript/history either).

If you want “random sampling” and “still persist skipped messages”, that’s basically a feature request (something like a configurable message gate + a “persist-only” append API). I’d open a GitHub issue with this exact Discord example:
https://github.com/openclaw/openclaw/issues

gritty geyser
#

So, for example, the activate with probability p it's possible or not

fresh hawkBOT
# gritty geyser So, for example, the activate with probability p it's possible or not

No — “activate with probability p” is not supported as a config option today.

On Discord, the only pre-run gating that prevents an agent run (so no LLM call) is basically:

  • channel/guild allowlists (guilds.*.channels.*.allow)
  • requireMention (plus mentionPatterns as “custom triggers”)

If requireMention: false, OpenClaw will treat the channel as always-on and will enqueue a run for each message (even if the model later replies NO_REPLY).

Workaround: set requireMention: true and add a low-friction trigger via mentionPatterns (e.g. ^!claw\\b). If you truly want probabilistic sampling + still persisting skipped messages, that would need a code change / feature request.

gritty geyser
#

Tell me what code to change to make a patch

fresh hawkBOT
# gritty geyser Tell me what code to change to make a patch

The “skip before any LLM call” decision for Discord happens very early in:

  • src/discord/monitor/message-handler.preflight.ts

That function returns null to drop a message before it ever becomes a session turn / agent run.

Minimal patch plan: add an “activationProbability p” gate (0..1)

1) Add config fields (so you can set p per guild/channel)

Edit:

  • src/config/types.discord.ts

Add e.g. to both of these types:

  • DiscordGuildEntry
  • DiscordGuildChannelConfig
#
/** 0..1. If set < 1, only this fraction of messages will trigger a run. */
activationProbability?: number;

(You can choose the exact name; activationProbability is clear.)

2) Plumb the value through the resolved allowlist objects

Edit:

  • src/discord/monitor/allow-list.ts

Add the same optional field to the resolved types:

  • DiscordGuildEntryResolved
  • DiscordChannelConfigResolved
#

…and make sure it gets copied through wherever the channel/guild entries are resolved (search in that file for where it builds the resolved config object; you’ll see it already copies requireMention, skills, etc).

3) Enforce the probability gate in preflight (this is the actual “skip”)

Edit:

  • src/discord/monitor/message-handler.preflight.ts

A good place is after all allowlist checks + mention gating checks (i.e. after the existing mentionGate logic), but before the function returns the final preflight object.

Pseudo-code:

const p =
channelConfig?.activationProbability ??
guildInfo?.activationProbability ??
1;
#

if (typeof p === "number" && p >= 0 && p < 1) {
// Option A: true random sampling
if (Math.random() >= p) {
// (optional) recordPendingHistoryEntryIfEnabled(...) like the mention-skip path does
return null;
}

// Option B (better): stable sampling based on message id (so restarts don’t change behavior)
// hash(message.id) -> u in [0,1), skip if u >= p
}

If you specifically want “probability sampling only when requireMention: false”, then gate it like: