mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(messages): keep group visible replies automatic by default (#83498)
* fix(messages): keep group visible replies automatic by default * fix(messages): keep unauthorized slash turns quiet * fix(messages): return boolean from slash guard * test(messages): narrow visible reply fixtures * test(messages): align completion delivery default
This commit is contained in:
committed by
GitHub
parent
5a7d31108e
commit
1e5450f23e
@@ -40,6 +40,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
- Codex app-server: preserve network access for sandboxed Codex code-mode turns when the OpenClaw sandbox allows outbound egress. Fixes #83347. Thanks @YusukeIt0.
|
||||
- QA-Lab: keep the OTLP smoke decoder independent of removed OpenTelemetry generated-root internals.
|
||||
- Messages: default group/channel visible replies to automatic final delivery again, keeping `message_tool` opt-in for ambient/shared rooms and tool-reliable models.
|
||||
- Agents/code mode: preserve agent, session, run, and channel context in `before_tool_call` hooks for top-level `exec`/`wait` dispatches. Fixes #83387.
|
||||
- Replies: keep final payload delivery after live preview updates so channels can finalize or send the completed answer instead of losing preview-only drafts. (#83468)
|
||||
- Discord: deliver final replies in progress-mode preview streams instead of deduplicating the final visible message. (#83443) Thanks @compoodment.
|
||||
|
||||
@@ -176,9 +176,9 @@ The agent-specific `agents.list[].groupChat.unmentionedInbound` value overrides
|
||||
|
||||
## Visible reply modes
|
||||
|
||||
`messages.groupChat.visibleReplies: "message_tool"` is the recommended group and channel default. It lets the agent decide when to speak by calling the message tool. If the model returns final text without calling the tool, OpenClaw keeps that final text private and logs suppressed delivery metadata.
|
||||
`messages.groupChat.visibleReplies` defaults to `"automatic"` for normal group/channel user requests. Keep that default when you want final assistant text to post visibly without requiring an explicit message-tool call.
|
||||
|
||||
Use `messages.groupChat.visibleReplies: "automatic"` only when you want legacy behavior where normal group requests post final assistant text automatically.
|
||||
For ambient always-on rooms, `messages.groupChat.visibleReplies: "message_tool"` is still recommended, especially with latest-generation, tool-reliable models such as GPT 5.5. It lets the agent decide when to speak by calling the message tool. If the model returns final text without calling the tool, OpenClaw keeps that final text private and logs suppressed delivery metadata.
|
||||
|
||||
Room events stay strict even when other group requests use automatic replies. Unmentioned ambient room events still require `message(action=send)` for visible output.
|
||||
|
||||
@@ -198,7 +198,7 @@ If the room shows typing or token usage but no visible message:
|
||||
2. Confirm `requireMention: false` is set at the room level you expect.
|
||||
3. Check whether `messages.groupChat.unmentionedInbound` or the agent override is `"room_event"`.
|
||||
4. Inspect logs for suppressed final payload metadata or `didSendViaMessagingTool: false`.
|
||||
5. Use a model/runtime that reliably calls tools, or set `messages.groupChat.visibleReplies: "automatic"` for legacy final replies on normal group requests.
|
||||
5. For normal group requests, keep or restore `messages.groupChat.visibleReplies: "automatic"` if you want final replies posted automatically. For ambient rooms using `message_tool`, use a model/runtime that reliably calls tools.
|
||||
|
||||
If Telegram ambient rooms do not trigger at all, check BotFather privacy mode and verify the Gateway is receiving normal group messages.
|
||||
|
||||
|
||||
@@ -250,9 +250,9 @@ Once DMs are working, you can set up your Discord server as a full workspace whe
|
||||
<Step title="Allow responses without @mention">
|
||||
By default, your agent only responds in guild channels when @mentioned. For a private server, you probably want it to respond to every message.
|
||||
|
||||
In guild channels, visible Discord output should use the `message` tool by default, so the agent can lurk and only post when it decides a channel reply is useful. Ambient room events stay quiet unless the tool sends. See [Ambient room events](/channels/ambient-room-events) for the full lurk-mode config.
|
||||
In guild channels, normal replies post automatically by default. For shared always-on rooms, opt into `messages.groupChat.visibleReplies: "message_tool"` so the agent can lurk and only post when it decides a channel reply is useful. This works best with latest-generation, tool-reliable models such as GPT 5.5. Ambient room events stay quiet unless the tool sends. See [Ambient room events](/channels/ambient-room-events) for the full lurk-mode config.
|
||||
|
||||
This means the selected model should reliably call tools. If Discord shows typing and the logs show token usage but no posted message, check whether the turn was configured as an ambient room event or use the config below to restore legacy automatic final replies for normal group requests.
|
||||
If Discord shows typing and the logs show token usage but no posted message, check whether the turn was configured as an ambient room event or opted into message-tool visible replies.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Ask your agent">
|
||||
@@ -275,7 +275,7 @@ Once DMs are working, you can set up your Discord server as a full workspace whe
|
||||
}
|
||||
```
|
||||
|
||||
To restore legacy automatic final replies for group/channel rooms, set `messages.groupChat.visibleReplies: "automatic"`.
|
||||
To require message-tool sends for visible group/channel replies, set `messages.groupChat.visibleReplies: "message_tool"`.
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
@@ -86,7 +86,7 @@ Only the owner number (from `channels.whatsapp.allowFrom`, or the bot's own E.16
|
||||
- Heartbeats are intentionally skipped for groups to avoid noisy broadcasts.
|
||||
- Echo suppression uses the combined batch string; if you send identical text twice without mentions, only the first will get a response.
|
||||
- Session store entries will appear as `agent:<agentId>:whatsapp:group:<jid>` in the session store (`~/.openclaw/agents/<agentId>/sessions/sessions.json` by default); a missing entry just means the group hasn't triggered a run yet.
|
||||
- Typing indicators in groups follow `agents.defaults.typingMode`. When visible replies use the default message-tool-only mode, typing starts immediately by default so group members can see the agent is working even if no automatic final reply is posted. Explicit typing-mode config still wins.
|
||||
- Typing indicators in groups follow `agents.defaults.typingMode`. When visible replies are opted into message-tool-only mode, typing starts immediately by default so group members can see the agent is working even if no automatic final reply is posted. Explicit typing-mode config still wins.
|
||||
|
||||
## Related
|
||||
|
||||
|
||||
@@ -43,18 +43,9 @@ always-on group chatter -> user request, or room event when configured
|
||||
|
||||
## Visible replies
|
||||
|
||||
For group/channel rooms, OpenClaw defaults to `messages.groupChat.visibleReplies: "message_tool"`.
|
||||
`openclaw doctor --fix` writes this default into configured-channel configs that omit it.
|
||||
That means the agent still processes the turn and can update memory/session state, and it should speak visibly with `message(action=send)` when it has a room reply. If the model misses that tool and returns substantive final text, OpenClaw keeps that final text private instead of posting it to the room.
|
||||
For normal group/channel requests, OpenClaw defaults to `messages.groupChat.visibleReplies: "automatic"`. Final assistant text posts through the legacy visible reply path unless you opt the room into message-tool-only output.
|
||||
|
||||
This default depends on a model/runtime that reliably calls tools. If logs show
|
||||
assistant text but `didSendViaMessagingTool: false`, the model answered
|
||||
privately instead of calling the message tool. The room stays silent, and the
|
||||
gateway verbose log records the suppressed final payload metadata. That is not
|
||||
a Discord/Slack/Telegram send failure, but a tool-discipline signal. Use a
|
||||
tool-call-reliable model for group/channel sessions, or set
|
||||
`messages.groupChat.visibleReplies: "automatic"` when you want all visible group
|
||||
replies to use the legacy final-reply path.
|
||||
Use `messages.groupChat.visibleReplies: "message_tool"` when a shared room should let the agent decide when to speak by calling `message(action=send)`. This works best for group rooms backed by latest-generation, tool-reliable models such as GPT 5.5. If the model misses that tool and returns substantive final text, OpenClaw keeps that final text private instead of posting it to the room.
|
||||
|
||||
If the message tool is unavailable under the active tool policy, OpenClaw falls
|
||||
back to automatic visible replies instead of silently suppressing the response.
|
||||
@@ -82,13 +73,13 @@ The default is `unmentionedInbound: "user_request"`.
|
||||
|
||||
Mentioned messages, commands, abort requests, and DMs stay user requests.
|
||||
|
||||
To restore legacy automatic final replies for group/channel requests:
|
||||
To require visible output to go through the message tool for group/channel requests:
|
||||
|
||||
```json5
|
||||
{
|
||||
messages: {
|
||||
groupChat: {
|
||||
visibleReplies: "automatic",
|
||||
visibleReplies: "message_tool",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1381,7 +1381,7 @@ Primary reference: [Configuration reference - Slack](/gateway/config-channels#sl
|
||||
- channel allowlist (`channels.slack.channels`) — **keys must be channel IDs** (`C12345678`), not names (`#channel-name`). Name-based keys silently fail under `groupPolicy: "allowlist"` because channel routing is ID-first by default. To find an ID: right-click the channel in Slack → **Copy link** — the `C...` value at the end of the URL is the channel ID.
|
||||
- `requireMention`
|
||||
- per-channel `users` allowlist
|
||||
- `messages.groupChat.visibleReplies`: if it is `"message_tool"` and logs show assistant text with no `message(action=send)` call, the model missed the visible message-tool path. Final text stays private in this mode; inspect the gateway verbose log for suppressed payload metadata, or set it to `"automatic"` if you want every normal assistant final reply posted through the legacy path.
|
||||
- `messages.groupChat.visibleReplies`: normal group/channel requests default to `"automatic"`. If you opted into `"message_tool"` and logs show assistant text with no `message(action=send)` call, the model missed the visible message-tool path. Final text stays private in this mode; inspect the gateway verbose log for suppressed payload metadata, or set it to `"automatic"` if you want every normal assistant final reply posted through the legacy path.
|
||||
- `messages.groupChat.unmentionedInbound`: if it is `"room_event"`, unmentioned allowed channel chatter is ambient context and stays silent unless the agent calls the `message` tool. See [Ambient room events](/channels/ambient-room-events).
|
||||
|
||||
```json5
|
||||
|
||||
@@ -80,12 +80,12 @@ Full troubleshooting: [Telegram troubleshooting](/channels/telegram#troubleshoot
|
||||
|
||||
### Discord failure signatures
|
||||
|
||||
| Symptom | Fastest check | Fix |
|
||||
| ----------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Bot online but no guild replies | `openclaw channels status --probe` | Allow guild/channel and verify message content intent. |
|
||||
| Group messages ignored | Check logs for mention gating drops | Mention bot or set guild/channel `requireMention: false`. |
|
||||
| Typing/token usage but no Discord message | Check whether this is an ambient room event or a missed `message(action=send)` call | Inspect the gateway verbose log for suppressed final payload metadata, verify `messages.groupChat.unmentionedInbound`, read [Ambient room events](/channels/ambient-room-events), or set `messages.groupChat.visibleReplies: "automatic"` to use the legacy final-reply path for normal group requests. |
|
||||
| DM replies missing | `openclaw pairing list discord` | Approve DM pairing or adjust DM policy. |
|
||||
| Symptom | Fastest check | Fix |
|
||||
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Bot online but no guild replies | `openclaw channels status --probe` | Allow guild/channel and verify message content intent. |
|
||||
| Group messages ignored | Check logs for mention gating drops | Mention bot or set guild/channel `requireMention: false`. |
|
||||
| Typing/token usage but no Discord message | Check whether this is an ambient room event or an opted-in `message_tool` room where the model missed `message(action=send)` | Inspect the gateway verbose log for suppressed final payload metadata, verify `messages.groupChat.unmentionedInbound`, read [Ambient room events](/channels/ambient-room-events), or keep `messages.groupChat.visibleReplies: "automatic"` for normal group requests. |
|
||||
| DM replies missing | `openclaw pairing list discord` | Approve DM pairing or adjust DM policy. |
|
||||
|
||||
Full troubleshooting: [Discord troubleshooting](/channels/discord#troubleshooting)
|
||||
|
||||
|
||||
@@ -787,15 +787,15 @@ See the full channel index: [Channels](/channels).
|
||||
|
||||
Group messages default to **require mention** (metadata mention or safe regex patterns). Applies to WhatsApp, Telegram, Discord, Google Chat, and iMessage group chats.
|
||||
|
||||
Visible replies are controlled separately. Group/channel rooms default to `messages.groupChat.visibleReplies: "message_tool"`: OpenClaw still processes the turn and asks the agent to use `message(action=send)` for visible room output. If the model returns final text without calling the message tool, that final text stays private and the gateway verbose log records suppressed payload metadata. Set `"automatic"` when you want all visible group replies to use the legacy final-reply path. To apply the same tool-only visible-reply behavior to direct chats too, set `messages.visibleReplies: "message_tool"`; the Codex harness also uses that tool-only behavior as its unset direct-chat default.
|
||||
Visible replies are controlled separately. Normal group/channel requests default to `messages.groupChat.visibleReplies: "automatic"`: final assistant text posts through the legacy visible reply path. Set `"message_tool"` when a shared room should only post visible output after the agent calls `message(action=send)`. If the model returns final text without calling the message tool, that final text stays private and the gateway verbose log records suppressed payload metadata. To apply the same tool-only visible-reply behavior to direct chats too, set `messages.visibleReplies: "message_tool"`; the Codex harness also uses that tool-only behavior as its unset direct-chat default.
|
||||
|
||||
Tool-only visible replies require a model/runtime that reliably calls tools. If
|
||||
Tool-only visible replies require a model/runtime that reliably calls tools, and are recommended for shared ambient rooms on latest-generation models such as GPT 5.5. If
|
||||
the session log shows assistant text with `didSendViaMessagingTool: false`, the
|
||||
model produced private final text instead of calling the message tool. Switch
|
||||
to a stronger tool-calling model for that channel, inspect the gateway verbose
|
||||
log for the suppressed payload summary, or set
|
||||
`messages.groupChat.visibleReplies: "automatic"` to use legacy visible final
|
||||
replies for every group/channel request.
|
||||
`messages.groupChat.visibleReplies: "automatic"` to use visible final replies
|
||||
for every group/channel request.
|
||||
|
||||
If the message tool is unavailable under the active tool policy, OpenClaw falls back to automatic visible replies instead of silently suppressing the response. `openclaw doctor` warns about this mismatch.
|
||||
|
||||
@@ -814,7 +814,7 @@ The gateway hot-reloads `messages` config after the file is saved. Restart only
|
||||
groupChat: {
|
||||
historyLimit: 50,
|
||||
unmentionedInbound: "room_event", // always-on unmentioned room chatter becomes quiet context
|
||||
visibleReplies: "message_tool", // default; use "automatic" for legacy final replies
|
||||
visibleReplies: "message_tool", // opt-in; require message(action=send) for visible room replies
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
|
||||
@@ -51,7 +51,7 @@ Save to `~/.openclaw/openclaw.json` and you can DM the bot from that number.
|
||||
messages: {
|
||||
visibleReplies: "automatic",
|
||||
groupChat: {
|
||||
visibleReplies: "message_tool", // default; visible output requires message(action=send)
|
||||
visibleReplies: "message_tool", // opt-in; visible output requires message(action=send)
|
||||
unmentionedInbound: "room_event",
|
||||
},
|
||||
},
|
||||
@@ -111,7 +111,7 @@ Save to `~/.openclaw/openclaw.json` and you can DM the bot from that number.
|
||||
ackReactionScope: "group-mentions",
|
||||
groupChat: {
|
||||
historyLimit: 50,
|
||||
visibleReplies: "message_tool", // prefer message tool; final text falls back for normal requests
|
||||
visibleReplies: "message_tool", // opt in for shared rooms with tool-reliable models
|
||||
unmentionedInbound: "room_event",
|
||||
},
|
||||
queue: {
|
||||
|
||||
@@ -175,14 +175,14 @@ candidate contains redacted secret placeholders such as `***`.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Set up group chat mention gating">
|
||||
Group messages default to **require mention**. Configure trigger patterns per agent, and keep visible room replies on the default message-tool path unless you intentionally want every normal group reply to use the legacy automatic final-reply path:
|
||||
Group messages default to **require mention**. Configure trigger patterns per agent. Normal group/channel replies post automatically; opt into the message-tool path for shared rooms where the agent should decide when to speak:
|
||||
|
||||
```json5
|
||||
{
|
||||
messages: {
|
||||
visibleReplies: "automatic", // set "message_tool" to require message-tool sends everywhere
|
||||
groupChat: {
|
||||
visibleReplies: "message_tool", // default; visible output requires message(action=send)
|
||||
visibleReplies: "message_tool", // opt-in; visible output requires message(action=send)
|
||||
unmentionedInbound: "room_event", // unmentioned always-on group chatter is quiet context
|
||||
},
|
||||
},
|
||||
|
||||
@@ -257,7 +257,6 @@ That stages grounded durable candidates into the short-term dreaming store while
|
||||
- `routing.groupChat.historyLimit` → `messages.groupChat.historyLimit`
|
||||
- `routing.groupChat.mentionPatterns` → `messages.groupChat.mentionPatterns`
|
||||
- `channels.telegram.requireMention` → `channels.telegram.groups."*".requireMention`
|
||||
- configured-channel configs missing visible reply policy → `messages.groupChat.visibleReplies: "message_tool"`
|
||||
- `routing.queue` → `messages.queue`
|
||||
- `routing.bindings` → top-level `bindings`
|
||||
- `routing.agents`/`routing.defaultAgentId` → `agents.list` + `agents.list[].default`
|
||||
|
||||
@@ -68,28 +68,34 @@ describe("completion delivery policy", () => {
|
||||
).toBe(expected);
|
||||
});
|
||||
|
||||
it("requires message-tool delivery for group and channel completions by default", () => {
|
||||
it("allows automatic delivery for group and channel completions by default", () => {
|
||||
expect(
|
||||
completionRequiresMessageToolDelivery({
|
||||
cfg: {},
|
||||
requesterSessionKey: "agent:main:whatsapp:123@g.us",
|
||||
}),
|
||||
).toBe(true);
|
||||
).toBe(false);
|
||||
expect(
|
||||
completionRequiresMessageToolDelivery({
|
||||
cfg: {},
|
||||
requesterSessionKey: "agent:main:discord:guild-123:channel-456",
|
||||
}),
|
||||
).toBe(true);
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("honors automatic group visible-reply config", () => {
|
||||
it("honors group visible-reply config", () => {
|
||||
expect(
|
||||
completionRequiresMessageToolDelivery({
|
||||
cfg: { messages: { groupChat: { visibleReplies: "automatic" } } },
|
||||
requesterSessionKey: "agent:main:slack:channel:C123",
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
completionRequiresMessageToolDelivery({
|
||||
cfg: { messages: { groupChat: { visibleReplies: "message_tool" } } },
|
||||
requesterSessionKey: "agent:main:slack:channel:C123",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("requires message-tool delivery for direct completions only when globally configured", () => {
|
||||
|
||||
@@ -2917,7 +2917,11 @@ describe("dispatchReplyFromConfig", () => {
|
||||
|
||||
it("keeps message-tool-only delivery mode on duplicate inbound returns", async () => {
|
||||
setNoAbort();
|
||||
const cfg = emptyConfig;
|
||||
const cfg = {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
} satisfies OpenClawConfig;
|
||||
const ctx = buildTestCtx({
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
@@ -2941,7 +2945,12 @@ describe("dispatchReplyFromConfig", () => {
|
||||
|
||||
it("does not mark duplicate inbound returns as tool-only when message is unavailable", async () => {
|
||||
setNoAbort();
|
||||
const cfg = { tools: { allow: ["read"] } } as OpenClawConfig;
|
||||
const cfg = {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
tools: { allow: ["read"] },
|
||||
} as OpenClawConfig;
|
||||
const ctx = buildTestCtx({
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
@@ -5128,7 +5137,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
expect(dispatcher.sendFinalReply).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps group/channel final replies private when message-tool-only events miss the message tool", async () => {
|
||||
it("keeps opted-in group/channel final replies private when message-tool-only events miss the message tool", async () => {
|
||||
setNoAbort();
|
||||
const dispatcher = createDispatcher();
|
||||
const replyResolver = vi.fn(async (_ctx: MsgContext, opts?: GetReplyOptions) => {
|
||||
@@ -5143,7 +5152,11 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
CommandSource: undefined,
|
||||
SessionKey: "test:discord:channel:C1",
|
||||
}),
|
||||
cfg: emptyConfig,
|
||||
cfg: {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
},
|
||||
dispatcher,
|
||||
replyResolver,
|
||||
});
|
||||
@@ -5173,7 +5186,11 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
OriginatingTo: "channel:C1",
|
||||
SessionKey: "test:discord:channel:C1",
|
||||
}),
|
||||
cfg: emptyConfig,
|
||||
cfg: {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
},
|
||||
dispatcher,
|
||||
replyResolver,
|
||||
});
|
||||
@@ -5282,7 +5299,12 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
ChatType: "channel",
|
||||
SessionKey: "test:discord:channel:C1",
|
||||
}),
|
||||
cfg: { tools: { allow: ["read"] } } as OpenClawConfig,
|
||||
cfg: {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
tools: { allow: ["read"] },
|
||||
} as OpenClawConfig,
|
||||
dispatcher,
|
||||
replyResolver,
|
||||
});
|
||||
@@ -5309,6 +5331,9 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
SessionKey: "agent:main:discord:channel:C1",
|
||||
}),
|
||||
cfg: {
|
||||
messages: {
|
||||
groupChat: { visibleReplies: "message_tool" },
|
||||
},
|
||||
channels: {
|
||||
discord: {
|
||||
groups: {
|
||||
@@ -5379,7 +5404,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
expect(firstFinalReplyPayload(dispatcher)?.text).toBe("status reply");
|
||||
});
|
||||
|
||||
it("allows config to keep group/channel source delivery automatic", async () => {
|
||||
it("keeps default group/channel source delivery automatic", async () => {
|
||||
setNoAbort();
|
||||
const dispatcher = createDispatcher();
|
||||
const replyResolver = vi.fn(async (_ctx: MsgContext, opts?: GetReplyOptions) => {
|
||||
@@ -5393,7 +5418,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
||||
WasMentioned: true,
|
||||
SessionKey: "test:telegram:group:G1",
|
||||
}),
|
||||
cfg: automaticGroupReplyConfig,
|
||||
cfg: emptyConfig,
|
||||
dispatcher,
|
||||
replyResolver,
|
||||
});
|
||||
|
||||
@@ -771,11 +771,10 @@ export async function dispatchReplyFromConfig(
|
||||
const effectiveVisibleReplies = configuredVisibleReplies ?? harnessDefaultVisibleReplies;
|
||||
const prefersMessageToolDelivery =
|
||||
params.replyOptions?.sourceReplyDeliveryMode === "message_tool_only" ||
|
||||
ctx.InboundEventKind === "room_event" ||
|
||||
(params.replyOptions?.sourceReplyDeliveryMode === undefined &&
|
||||
!isExplicitSourceReplyCommand(ctx) &&
|
||||
(chatType === "group" || chatType === "channel"
|
||||
? effectiveVisibleReplies !== "automatic"
|
||||
: effectiveVisibleReplies === "message_tool"));
|
||||
effectiveVisibleReplies === "message_tool");
|
||||
const runtimeProfileAlsoAllow = prefersMessageToolDelivery ? ["message"] : [];
|
||||
const profilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(profile), [
|
||||
...(profileAlsoAllow ?? []),
|
||||
|
||||
@@ -30,12 +30,12 @@ function expectPolicyFields(
|
||||
}
|
||||
|
||||
describe("resolveSourceReplyDeliveryMode", () => {
|
||||
it("defaults groups and channels to message-tool-only delivery", () => {
|
||||
it("defaults source replies to automatic delivery outside ambient room events", () => {
|
||||
expect(resolveSourceReplyDeliveryMode({ cfg: emptyConfig, ctx: { ChatType: "channel" } })).toBe(
|
||||
"message_tool_only",
|
||||
"automatic",
|
||||
);
|
||||
expect(resolveSourceReplyDeliveryMode({ cfg: emptyConfig, ctx: { ChatType: "group" } })).toBe(
|
||||
"message_tool_only",
|
||||
"automatic",
|
||||
);
|
||||
expect(resolveSourceReplyDeliveryMode({ cfg: emptyConfig, ctx: { ChatType: "direct" } })).toBe(
|
||||
"automatic",
|
||||
@@ -131,6 +131,9 @@ describe("resolveSourceReplyDeliveryMode", () => {
|
||||
},
|
||||
}),
|
||||
).toBe("automatic");
|
||||
});
|
||||
|
||||
it("keeps unauthorized text slash command turns tool-only under the default group mode", () => {
|
||||
expect(
|
||||
resolveSourceReplyDeliveryMode({
|
||||
cfg: emptyConfig,
|
||||
@@ -177,10 +180,10 @@ describe("resolveSourceReplyDeliveryMode", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("does not make unauthorized text slash command turns visible in groups", () => {
|
||||
it("keeps unauthorized text slash command turns tool-only when groups opt into message-tool replies", () => {
|
||||
expect(
|
||||
resolveSourceReplyDeliveryMode({
|
||||
cfg: emptyConfig,
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: {
|
||||
ChatType: "group",
|
||||
CommandTurn: {
|
||||
@@ -197,7 +200,7 @@ describe("resolveSourceReplyDeliveryMode", () => {
|
||||
it("falls back to automatic when message-tool-only delivery cannot use the message tool", () => {
|
||||
expect(
|
||||
resolveSourceReplyDeliveryMode({
|
||||
cfg: emptyConfig,
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: { ChatType: "group" },
|
||||
messageToolAvailable: false,
|
||||
}),
|
||||
@@ -242,14 +245,14 @@ describe("resolveSourceReplyDeliveryMode", () => {
|
||||
it("keeps message-tool-only delivery when message tool availability is unknown", () => {
|
||||
expect(
|
||||
resolveSourceReplyDeliveryMode({
|
||||
cfg: emptyConfig,
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: { ChatType: "group" },
|
||||
messageToolAvailable: true,
|
||||
}),
|
||||
).toBe("message_tool_only");
|
||||
expect(
|
||||
resolveSourceReplyDeliveryMode({
|
||||
cfg: emptyConfig,
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: { ChatType: "channel" },
|
||||
}),
|
||||
).toBe("message_tool_only");
|
||||
@@ -277,13 +280,33 @@ describe("resolveSourceReplyVisibilityPolicy", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("suppresses automatic source delivery for default group turns without suppressing typing", () => {
|
||||
it("allows default group turns without suppressing typing", () => {
|
||||
expectPolicyFields(
|
||||
resolveSourceReplyVisibilityPolicy({
|
||||
cfg: emptyConfig,
|
||||
ctx: { ChatType: "group" },
|
||||
sendPolicy: "allow",
|
||||
}),
|
||||
{
|
||||
sourceReplyDeliveryMode: "automatic",
|
||||
sendPolicyDenied: false,
|
||||
suppressAutomaticSourceDelivery: false,
|
||||
suppressDelivery: false,
|
||||
suppressHookUserDelivery: false,
|
||||
suppressHookReplyLifecycle: false,
|
||||
suppressTyping: false,
|
||||
deliverySuppressionReason: "",
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("suppresses automatic source delivery for opted-in message-tool group turns without suppressing typing", () => {
|
||||
expectPolicyFields(
|
||||
resolveSourceReplyVisibilityPolicy({
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: { ChatType: "group" },
|
||||
sendPolicy: "allow",
|
||||
}),
|
||||
{
|
||||
sourceReplyDeliveryMode: "message_tool_only",
|
||||
sendPolicyDenied: false,
|
||||
@@ -368,7 +391,7 @@ describe("resolveSourceReplyVisibilityPolicy", () => {
|
||||
sendPolicy: "deny",
|
||||
}),
|
||||
{
|
||||
sourceReplyDeliveryMode: "message_tool_only",
|
||||
sourceReplyDeliveryMode: "automatic",
|
||||
sendPolicyDenied: true,
|
||||
suppressDelivery: true,
|
||||
suppressHookUserDelivery: true,
|
||||
@@ -417,7 +440,7 @@ describe("resolveSourceReplyVisibilityPolicy", () => {
|
||||
it("falls back to automatic when message-tool-only delivery cannot use the message tool", () => {
|
||||
expectPolicyFields(
|
||||
resolveSourceReplyVisibilityPolicy({
|
||||
cfg: emptyConfig,
|
||||
cfg: globalToolOnlyReplyConfig,
|
||||
ctx: { ChatType: "group" },
|
||||
sendPolicy: "allow",
|
||||
messageToolAvailable: false,
|
||||
|
||||
@@ -22,6 +22,15 @@ export function isExplicitSourceReplyCommand(ctx: SourceReplyDeliveryModeContext
|
||||
return isExplicitCommandTurn(resolveCommandTurnContext(ctx));
|
||||
}
|
||||
|
||||
function isUnauthorizedTextSlashCommand(ctx: SourceReplyDeliveryModeContext): boolean {
|
||||
const commandTurn = resolveCommandTurnContext(ctx);
|
||||
return (
|
||||
commandTurn.kind === "text-slash" &&
|
||||
!commandTurn.authorized &&
|
||||
(commandTurn.commandName !== undefined || commandTurn.body?.trim().startsWith("/") === true)
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveSourceReplyDeliveryMode(params: {
|
||||
cfg: OpenClawConfig;
|
||||
ctx: SourceReplyDeliveryModeContext;
|
||||
@@ -46,11 +55,17 @@ export function resolveSourceReplyDeliveryMode(params: {
|
||||
return "automatic";
|
||||
}
|
||||
const chatType = normalizeChatType(params.ctx.ChatType);
|
||||
if (
|
||||
(chatType === "group" || chatType === "channel") &&
|
||||
isUnauthorizedTextSlashCommand(params.ctx)
|
||||
) {
|
||||
return "message_tool_only";
|
||||
}
|
||||
let mode: SourceReplyDeliveryMode;
|
||||
if (chatType === "group" || chatType === "channel") {
|
||||
const configuredMode =
|
||||
params.cfg.messages?.groupChat?.visibleReplies ?? params.cfg.messages?.visibleReplies;
|
||||
mode = configuredMode === "automatic" ? "automatic" : "message_tool_only";
|
||||
mode = configuredMode === "message_tool" ? "message_tool_only" : "automatic";
|
||||
} else {
|
||||
const configuredMode = params.cfg.messages?.visibleReplies ?? params.defaultVisibleReplies;
|
||||
mode = configuredMode === "message_tool" ? "message_tool_only" : "automatic";
|
||||
|
||||
@@ -157,7 +157,7 @@ describe("normalizeCompatibilityConfigValues", () => {
|
||||
fs.rmSync(tempOauthDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("sets the group visible reply default for configured channels", () => {
|
||||
it("does not materialize a group visible reply default for configured channels", () => {
|
||||
const res = normalizeCompatibilityConfigValues({
|
||||
channels: {
|
||||
discord: {},
|
||||
@@ -171,10 +171,9 @@ describe("normalizeCompatibilityConfigValues", () => {
|
||||
|
||||
expect(res.config.messages?.groupChat).toEqual({
|
||||
mentionPatterns: ["@openclaw"],
|
||||
visibleReplies: "message_tool",
|
||||
});
|
||||
expect(res.changes).toContain(
|
||||
'Set messages.groupChat.visibleReplies to "message_tool" so group/channel replies use the message tool by default.',
|
||||
expect(res.changes.some((change) => change.includes("messages.groupChat.visibleReplies"))).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
normalizeLegacyRuntimeModelRefs,
|
||||
normalizeLegacyNanoBananaSkill,
|
||||
normalizeLegacyTalkConfig,
|
||||
normalizeMissingGroupVisibleRepliesDefault,
|
||||
seedMissingDefaultAccountsFromSingleAccountBase,
|
||||
} from "./legacy-config-core-normalizers.js";
|
||||
import { migrateLegacyWebFetchConfig } from "./legacy-web-fetch-migrate.js";
|
||||
@@ -43,7 +42,6 @@ export function normalizeBaseCompatibilityConfigValues(
|
||||
next = normalizeLegacyOpenAIModelProviderApi(next, changes);
|
||||
next = normalizeLegacyRuntimeModelRefs(next, changes);
|
||||
next = normalizeLegacyCrossContextMessageConfig(next, changes);
|
||||
next = normalizeMissingGroupVisibleRepliesDefault(next, changes);
|
||||
next = normalizeLegacyMediaProviderOptions(next, changes);
|
||||
next = normalizeLegacyOllamaNativeNumCtxParams(next, changes);
|
||||
return normalizeLegacyMistralModelMaxTokens(next, changes);
|
||||
|
||||
@@ -17,42 +17,6 @@ import { hasOwnKey, isRecord } from "./legacy-config-record-shared.js";
|
||||
import { isLegacyModelsAddCodexMetadataModel } from "./legacy-models-add-metadata.js";
|
||||
export { normalizeLegacyTalkConfig } from "./legacy-talk-config-normalizer.js";
|
||||
|
||||
function hasConfiguredChannels(cfg: OpenClawConfig): boolean {
|
||||
const channels = cfg.channels;
|
||||
if (!isRecord(channels)) {
|
||||
return false;
|
||||
}
|
||||
return Object.keys(channels).some((channelId) => channelId !== "defaults");
|
||||
}
|
||||
|
||||
export function normalizeMissingGroupVisibleRepliesDefault(
|
||||
cfg: OpenClawConfig,
|
||||
changes: string[],
|
||||
): OpenClawConfig {
|
||||
const messages = cfg.messages;
|
||||
if (
|
||||
!hasConfiguredChannels(cfg) ||
|
||||
messages?.visibleReplies !== undefined ||
|
||||
messages?.groupChat?.visibleReplies !== undefined
|
||||
) {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const nextMessages = messages ? { ...messages } : {};
|
||||
nextMessages.groupChat = {
|
||||
...messages?.groupChat,
|
||||
visibleReplies: "message_tool",
|
||||
};
|
||||
changes.push(
|
||||
'Set messages.groupChat.visibleReplies to "message_tool" so group/channel replies use the message tool by default.',
|
||||
);
|
||||
|
||||
return {
|
||||
...cfg,
|
||||
messages: nextMessages,
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeLegacyCommandsConfig(
|
||||
cfg: OpenClawConfig,
|
||||
changes: string[],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import {
|
||||
collectChannelBoundMessageToolPolicyWarnings,
|
||||
collectDoctorPreviewWarnings,
|
||||
@@ -435,7 +436,7 @@ describe("doctor preview warnings", () => {
|
||||
expect(warnings.join("\n")).not.toContain("stale plugin reference");
|
||||
});
|
||||
|
||||
it("warns softly when default group visible replies need an unavailable message tool", () => {
|
||||
it("does not warn when default group visible replies are automatic", () => {
|
||||
const warnings = collectVisibleReplyToolPolicyWarnings({
|
||||
channels: {
|
||||
slack: {},
|
||||
@@ -445,12 +446,7 @@ describe("doctor preview warnings", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const warning = expectSingleWarningContaining(
|
||||
warnings,
|
||||
'messages.groupChat.visibleReplies defaults to "message_tool"',
|
||||
);
|
||||
expect(warning).toContain("message tool is unavailable");
|
||||
expect(warning).toContain("falls back to automatic group/channel replies");
|
||||
expect(warnings).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("warns strongly when explicit group visible replies require an unavailable message tool", () => {
|
||||
@@ -491,10 +487,15 @@ describe("doctor preview warnings", () => {
|
||||
discord: {},
|
||||
telegram: {},
|
||||
},
|
||||
messages: {
|
||||
groupChat: {
|
||||
visibleReplies: "message_tool",
|
||||
},
|
||||
},
|
||||
tools: {
|
||||
profile: "coding" as const,
|
||||
},
|
||||
};
|
||||
} satisfies OpenClawConfig;
|
||||
|
||||
expect(collectVisibleReplyToolPolicyWarnings(cfg)).toStrictEqual([]);
|
||||
expect(collectChannelBoundMessageToolPolicyWarnings(cfg)).toStrictEqual([]);
|
||||
@@ -517,6 +518,11 @@ describe("doctor preview warnings", () => {
|
||||
channels: {
|
||||
discord: {},
|
||||
},
|
||||
messages: {
|
||||
groupChat: {
|
||||
visibleReplies: "message_tool",
|
||||
},
|
||||
},
|
||||
tools: {
|
||||
profile: "coding" as const,
|
||||
byProvider: {
|
||||
@@ -525,10 +531,10 @@ describe("doctor preview warnings", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
} satisfies OpenClawConfig;
|
||||
|
||||
expectWarningsContaining(collectVisibleReplyToolPolicyWarnings(cfg), [
|
||||
'messages.groupChat.visibleReplies defaults to "message_tool"',
|
||||
'messages.groupChat.visibleReplies is set to "message_tool"',
|
||||
]);
|
||||
expect(collectChannelBoundMessageToolPolicyWarnings(cfg)).toEqual([
|
||||
'- Agent "main" is routed from channel "discord", but the message tool is unavailable for that agent; explicit channel actions such as sendAttachment, upload-file, thread-reply, or reply can fail. Add "message" to the agent tool allowlist, add "group:messaging", or switch the agent to a profile that includes messaging tools.',
|
||||
@@ -552,6 +558,11 @@ describe("doctor preview warnings", () => {
|
||||
channels: {
|
||||
discord: {},
|
||||
},
|
||||
messages: {
|
||||
groupChat: {
|
||||
visibleReplies: "message_tool",
|
||||
},
|
||||
},
|
||||
tools: {
|
||||
profile: "coding" as const,
|
||||
byProvider: {
|
||||
@@ -560,7 +571,7 @@ describe("doctor preview warnings", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
} satisfies OpenClawConfig;
|
||||
|
||||
expect(collectVisibleReplyToolPolicyWarnings(cfg)).toStrictEqual([]);
|
||||
expect(collectChannelBoundMessageToolPolicyWarnings(cfg)).toStrictEqual([]);
|
||||
|
||||
@@ -221,7 +221,7 @@ function resolveSourceReplyMessageToolAvailability(params: {
|
||||
|
||||
function sourceReplyRuntimeMayAllowMessageTool(cfg: OpenClawConfig): boolean {
|
||||
const groupPolicy = resolveGroupVisibleReplyProvenance(cfg);
|
||||
if (hasChannels(cfg) && groupPolicy.value === "message_tool") {
|
||||
if (groupPolicy.value === "message_tool") {
|
||||
return true;
|
||||
}
|
||||
if (cfg.messages?.visibleReplies === "message_tool") {
|
||||
@@ -284,7 +284,7 @@ function resolveGroupVisibleReplyProvenance(cfg: OpenClawConfig): {
|
||||
return {
|
||||
path: "messages.groupChat.visibleReplies",
|
||||
provenance: "default",
|
||||
value: "message_tool",
|
||||
value: "automatic",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -299,23 +299,15 @@ export function collectVisibleReplyToolPolicyWarnings(cfg: OpenClawConfig): stri
|
||||
const groupPolicy = resolveGroupVisibleReplyProvenance(cfg);
|
||||
const warnings: string[] = [];
|
||||
if (groupPolicy.value === "message_tool") {
|
||||
if (groupPolicy.provenance === "default" && !hasChannels(cfg)) {
|
||||
return warnings;
|
||||
}
|
||||
const targets = collectMessageToolUnavailableTargets(cfg, { sourceReplyRuntimeGrant: true });
|
||||
if (targets.length === 0) {
|
||||
return warnings;
|
||||
}
|
||||
const targetSummary = formatTargets(targets);
|
||||
if (groupPolicy.provenance === "default") {
|
||||
warnings.push(
|
||||
`- messages.groupChat.visibleReplies defaults to "message_tool", but the message tool is unavailable for ${targetSummary}; OpenClaw falls back to automatic group/channel replies to avoid silent responses. Enable the message tool or set messages.groupChat.visibleReplies explicitly.`,
|
||||
);
|
||||
} else {
|
||||
warnings.push(
|
||||
`- ${groupPolicy.path} is set to "message_tool", but the message tool is unavailable for ${targetSummary}; OpenClaw falls back to automatic visible replies, so normal replies may post to the source chat. Enable the message tool or set ${groupPolicy.path} to "automatic".`,
|
||||
);
|
||||
}
|
||||
warnings.push(
|
||||
`- ${groupPolicy.path} is set to "message_tool", but the message tool is unavailable for ${formatTargets(
|
||||
targets,
|
||||
)}; OpenClaw falls back to automatic visible replies, so normal replies may post to the source chat. Enable the message tool or set ${groupPolicy.path} to "automatic".`,
|
||||
);
|
||||
}
|
||||
|
||||
const globalVisibleReplies = cfg.messages?.visibleReplies;
|
||||
|
||||
@@ -1815,7 +1815,7 @@ export const FIELD_HELP: Record<string, string> = {
|
||||
"messages.groupChat.unmentionedInbound":
|
||||
'Controls how unmentioned always-on group chatter is submitted. "user_request" treats it as a user request; "room_event" submits it as quiet context where visible output requires the message tool.',
|
||||
"messages.groupChat.visibleReplies":
|
||||
'Overrides visible source replies for group/channel conversations. Defaults to "message_tool" when no global visible reply policy is set. "message_tool" requires message(action=send) for room output and keeps normal final text private. "automatic" posts normal replies as before.',
|
||||
'Overrides visible source replies for group/channel conversations. Defaults to "automatic" when no global visible reply policy is set. "message_tool" requires message(action=send) for room output and keeps normal final text private. "automatic" posts normal replies as before.',
|
||||
"messages.queue":
|
||||
"Queue strategy for inbound messages that arrive while a session run is active. Use this to tune steering, deferred followups, batching, or interruption.",
|
||||
"messages.queue.mode":
|
||||
|
||||
@@ -13,7 +13,7 @@ export type GroupChatConfig = {
|
||||
* Controls how group/channel inbound events produce visible room replies. The
|
||||
* message-tool mode requires explicit message sends for visible room output;
|
||||
* final text stays private when the model misses the tool.
|
||||
* Default: "message_tool".
|
||||
* Default: "automatic".
|
||||
*/
|
||||
visibleReplies?: "automatic" | "message_tool";
|
||||
};
|
||||
@@ -106,9 +106,8 @@ export type MessagesConfig = {
|
||||
* group, and channel conversations. Group/channel events still default to
|
||||
* `groupChat.visibleReplies` when it is set.
|
||||
*
|
||||
* Default: "automatic" for direct chats, "message_tool" for groups/channels.
|
||||
* In group/channel rooms, "message_tool" keeps final text private unless the
|
||||
* model sends visibly through the message tool.
|
||||
* Default: "automatic". In group/channel rooms, "message_tool" keeps final
|
||||
* text private unless the model sends visibly through the message tool.
|
||||
*/
|
||||
visibleReplies?: "automatic" | "message_tool";
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user