Skip to content

fix: agent-authored message buttons reach the agent on every channel - #201764

Merged
obviyus merged 9 commits into
mainfrom
fix-agent-control-taps
Nov 19, 2026
Merged

obviyus merged 9 commits into
mainfrom
fix-agent-control-taps

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A button the agent sends with the message tool (presentation button with action: { type: "callback", value }, or a legacy value) has no recorded owner. When no plugin claims the tap, each channel guesses:

  • Slack: the agent gets a Slack interaction: {json…} system event instead of the value.
  • Discord (registry path): the agent gets only Clicked "<label>"; the callback value is lost.
  • Teams: the agent gets the raw card JSON {"value":…,"label":…}.
  • Telegram: v2026.11.5 and main already deliver message-tool buttons through a Telegram-private patch (tgac1, backported to stable as 9afcc1b7b29a), so the plain send/edit path works on stable (E2E below). That patch is set only by Telegram's prepareSendPayload hook and its edit path. Paths that skip it still render the plugin envelope tgcb1: and expire with "This action is no longer available.": the queue-persistence/forceCoreDelivery path, tool-authored source replies and legacy interactive. Builds before v2026.11.5 expire every typed agent button. Legacy slash values run as commands.

The main user-visible fixes are the other channels; on Telegram this PR replaces the private patch with the core owner and covers the paths it missed.

  • Feishu / Mattermost / LINE: legacy values pass through without an owner.

Root cause

MessagePresentationAction { type: "callback" } is "opaque callback value interpreted by the target channel/plugin" (src/interactive/payload.ts:78-82), and the SDK dispatcher returns only { matched: false } for an unclaimed tap (src/plugins/interactive.ts:63-65). Nothing records that the agent owns the control, so each channel picks its own fallback. Telegram patched this privately with channelData.telegram.typedCallbackOwner, which was set on only two producer paths (extensions/telegram/src/channel-actions.ts:215-249, button-types.ts:270-282).

Solution

One core owner records ownership inside the value:

  • src/interactive/agent-control.ts (new, core-private codec): stampAgentControls() prefixes every callback value that a message action authors with a 2-byte mark (::), unconditionally; the decoder removes exactly one mark, so every authored value round-trips (::pick:a → callback_data: ::pick:a). A leading : is an empty namespace, and the plugin registry refuses empty namespaces (interactive-registry.ts:58-68), so a plugin can never claim a value by its mark.
  • Marking happens where controls leave core for a channel, which a delivery reaches exactly once (not at the runner entry, whose params can re-enter through the runner's own Gateway message.action hop):
    • dispatchChannelMessageAction: the plugin-action leaf, for runner actions and direct Gateway message.action callers.
    • executeSendAction core branch: right before sendMessage persists the payload to the outbound queue, so recovered sends keep the mark. Queue recovery delivers the stored payload without passing a leaf again.
    • extractToolAuthoredSourceReplyPayload: tool-authored source replies, which are delivered by the reply pipeline, not by either leaf above.
  • dispatchPluginInteractiveHandler strips the mark before namespace matching and passes the plain value to the handler. The result type is unchanged.
  • Additive SDK exports on openclaw/plugin-sdk/interactive-runtime: agentControlText(data) returns callback_data: <value> for a marked value and undefined otherwise; stampAgentControls(payload) marks a payload's callback controls (Telegram uses it once, for sends queued by v2026.11.5).
  • Channels: an unclaimed tap → agentControlText(data) ?? <current behavior>.
    • Telegram: marked values travel raw in callback_data (62 bytes for the agent's value; the old tgac1: envelope left 52). Unmarked typed values keep the tgcb1 envelope, and an unclaimed one still answers "This action is no longer available." (fix(telegram): preserve callback action ownership #116383 semantics).
    • Slack, LINE, Teams, Feishu (legacy quick envelope), Mattermost (legacy signed context), Discord (registry path): decode the mark so it never reaches the agent.

The mark is part of the value, so every encoder, the delivery queue and a Gateway restart keep it without channel cooperation. No state, config, schema, timers or flags.

What was deleted

  • Telegram: TELEGRAM_AGENT_CALLBACK_PREFIX (tgac1:), TelegramTypedCallbackOwner, the owner parameter, hasTelegramAgentCallbackPrefix / parseTelegramAgentCallbackData, typedCallbackOwner in TelegramButtonBuildOptions, the prepareSendPayload mark and its interactive-fallback reader, and the router's tgac1 branches.
  • tgac1 shipped in v2026.11.5 (backport 9afcc1b7b29a), so a read-only tgac1 decoder stays in the Telegram router for buttons already in chats (plugin-first on the inner value, then callback_data: <value>). Outgoing agent buttons no longer use it; remove the reader once those messages have aged out. Sends still queued by v2026.11.5 carry channelData.telegram.typedCallbackOwner: "agent"; Telegram's canonicalize step marks those with the core codec (remove once such queue rows have drained).

Accepted edges (named, not coded)

  • Typed agent buttons delivered as tgcb1: by stables before v2026.11.5 are indistinguishable from plugin buttons: they keep their current behavior (unclaimed → unavailable). The agent can resend.
  • A plugin installed later can claim older agent buttons in its namespace (plugin-first is kept on the inner value).
  • Values starting with / now arrive as callback_data: /… instead of running as commands. Use action.type: "command" for command buttons (docs updated).
  • Marking closes a spoof: a legacy raw value could previously mint tgcmd: or approval-looking data on Telegram.
  • Native passthrough (raw Telegram reply_markup, Slack blocks, Discord components) is not marked and keeps its current owner. Discord native components/forms keep the registry and agentComponents.ttlMs.
  • Discord presentation buttons still use the 30-minute registry TTL. Stateless Discord controls are the next PR.
  • Slack delivers the tap as a session system event (now the plain callback_data: <value> text), not a user message.
  • Repeat taps produce repeat turns, the same as typing twice. Telegram still clears the keyboard on tap.
  • Third-party channel plugins that forward raw callback values show the 2-byte mark to the agent until they adopt agentControlText.
  • Teams/Mattermost value size is unbounded (needs a separate decision).
  • Taps route to the conversation's session (unchanged for Telegram, Slack, Teams, LINE, Mattermost).

Plugin SDK impact

  • Additive: agentControlText and stampAgentControls on plugin-sdk/interactive-runtime (the focused presentation subpath; plugin-runtime is a deprecated broad barrel). No type change; MessagePresentationAction and the dispatcher result are unchanged.
  • Behavior: message-action callback values reach channel adapters with a leading ::, and plugin interactive handlers receive the value without it.
  • ClawHub static usage (plugin-sdk-impact, 2026-11-19, 2,675 eligible releases, coverage incomplete: 423 partial, 1 failed): api.registerInteractiveHandler 10 plugins, plugin-runtime#dispatchPluginInteractiveHandler 3, #createChannelInteractiveDispatcher 2, #registerPluginInteractiveHandler 1. Handlers keep receiving the same namespace/payload; channel plugins that forward raw values see the mark (degradation, not a break). Bundled source scan not run.

Tests (red on base 2d9c5d679497, green on head)

Wire bytes come from a real send through runMessageAction → the Telegram plugin → a loopback Bot API (test/telegram-agent-control-taps.integration.test.ts); the Telegram tap tests feed those exact bytes through the real callback router.

Test Base Head
test/telegram-agent-control-taps.integration.test.ts send on the core-forced path (forceCoreDelivery, what queue persistence uses; skips prepareSendPayload) + edit → callback_data ✗ (tgcb1:/tgac1: envelopes) ✓ ::/pick a|1, ::pick:b, 64-byte legacy
bot.agent-callbacks: unclaimed agent tap → callback_data: /pick a|1, no mark ✗ ✓
bot.agent-callbacks: plugin claims inner value first ✗ ✓
bot.agent-callbacks: mention-gated group tap delivered ✗ ✓
bot.agent-callbacks: agent control with inline buttons off → unavailable ✗ ✓
bot.agent-callbacks: tgac1 button already sent by v2026.11.5 → callback_data: pick:beta ✓ (guard) ✓
bot.agent-callbacks: unauthorized tapper ignored; unclaimed tgcb1 → unavailable ✓ (guard) ✓
message-action-runner.plugin-dispatch: runner → plugin marked once; authored ::a → ::::a ✗ ✓
message-action-gateway: runner → Gateway message.action hop forwards controls unmarked (the Gateway leaf marks once) ✓ (guard) ✓
outbound-send-service: core send marks once before queue persistence ✗ ✓
message-action-dispatch.registry: direct Gateway message action marked once; authored ::pick:a round-trips ✗ ✓
interactive-fallback: send queued by v2026.11.5 with typedCallbackOwner → ::pick:a ✗ ✓
embedded-agent-messaging-extraction.tool-authored: source reply marked once (:pick:a → :::pick:a) ✗ ✓
src/plugins/interactive.test.ts: decode removes exactly one mark (::::pick:a → callback_data: ::pick:a) ✗ ✓
src/plugins/interactive.test.ts dispatcher matches by value, not mark ✗ ✓
embedded-agent-messaging-extraction.tool-authored source reply marked ✗ ✓
Slack interactions.lifecycle, LINE bot-message-context, Teams monitor-handler.adaptive-card, Feishu bot.card-action, Mattermost monitor-interactions.question + interactions ✗ each ✓ each

Consumer suites rerun on head: Telegram, Slack events, LINE, Teams, Feishu, Mattermost, Discord monitor, src/infra/outbound (107 files), src/interactive. message-action-runner.plugin-dispatch updated for the marked value. extensions/mattermost/src/mattermost/slash-http.boundary.test.ts fails identically on base (inherited, untouched).

Gates: pnpm tsgo:core, pnpm check:test-types, oxlint/oxfmt on changed files, rg for removed symbols (only the historical config/test-lines-allocations/196217-* record mentions tgac1).

E2E (Telegram Test Server, real user via TDLib, isolated scratch Gateway from source, real model gpt-5.5)

The agent was asked to send "Pick one " with Alpha/Beta callback buttons through the message tool and to reply GOT <value> after a tap; the userbot tapped Beta.

Run Rendered callback_data (Beta) Agent received / replied
Base v2026.11.5 tgac1:17dsn:pick:beta GOT pick:beta
Head a960e5e7ac4c, authored value ::pick:beta ::::pick:beta GOT ::pick:beta (exact round trip, one mark removed)
Head a960e5e7ac4c, Gateway restarted after the turn (121 s), then the original message's button tapped ::pick:beta GOT pick:beta

Re-run on the final Telegram code (heads 8d5d953 / 9a18b4c; the last commit touches only Discord):

Run Agent received / replied
Plain Beta tap (pick:beta) GOT pick:beta
Authored value ::x GOT ::x (exact round trip)
Scratch Gateway restarted between send and tap (9a18b4c) GOT pick:beta

Note: v2026.11.5 already carries the tgac1 backport, so the plain message-tool send/edit path on Telegram is not red on stable. On Telegram, this PR replaces that private patch with the core owner (no regression, now also covering the paths that skip prepareSendPayload). The user-visible base defects are on the other channels, proven by the handler tests above.

Sanitized E2E timelines (TDLib recorder, real user, real model gpt-5.5)

Base v2026.11.5 (e13cf15)

    193 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
    193 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
 126937 ms  message bot     Pick one 3E6C05F3  callback_data=[['tgac1:bcaw3:pick:alpha', 'tgac1:17dsn:pick:beta']]  (msg 013568)
 127389 ms  action       click completed Beta  (msg 013568)
 127944 ms  message bot     Working / Message: running
 129930 ms  edit    bot     Working / Last activity: Message
 132155 ms  delete  bot
 140750 ms  message bot     GOT pick:beta

Head a960e5e, authored Beta value ::pick:beta

    186 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (::pick:beta) callback buttons; reply GOT <value> on tap>
    187 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (::pick:beta) callback buttons; reply GOT <value> on tap>
  55704 ms  message bot     Pick one 69957FA7  callback_data=[['::pick:alpha', '::::pick:beta']]  (msg 184320)
  56063 ms  action       click completed Beta  (msg 184320)
  58691 ms  message bot     Working / ✉️ Message
  61747 ms  message bot     GOT ::pick:beta
  62921 ms  delete  bot

Head a960e5e, Gateway restarted between send and tap

    192 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
    192 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
  68815 ms  message bot     Pick one 5F394A3C  callback_data=[['::pick:alpha', '::pick:beta']]  (msg 378624)
  68815 ms  action       awaitReply completed  Pick one 5F394A3C
  70886 ms  message bot     Working / ✉️ Message running
  71983 ms  edit    bot     Working / ✉️ Message
  74975 ms  delete  bot
 480757 ms  action       click completed Beta  (msg 378624)
 510229 ms  message bot     GOT pick:beta
gateway action: restartGateway at 150002 ms, took 120775 ms, completed

Size

  • Production: +153 / −81 (net +72). Telegram −32 (includes the read-only tgac1 decoder and the v2026.11.5 queued-send reader); core codec, the three exactly-once leaves, dispatcher strip and SDK exports +89; six channel decoders +15. Not net negative: the line-cap ratchet required a sibling codec module and kept Telegram's existing resolveTelegramButtonsFromParams wrapper; shipped-stable compatibility (v2026.11.5 tgac1 buttons and queued sends) and exactly-once leaf marking were added in review. The series goes net negative in the same owner: Discord stateless controls retire the unused agent:/agentsel: handlers (133 lines), and Mattermost drops its duplicate tap delivery.
  • Tests/docs/test config: +287 net (old tgac1 tests deleted; test lines within the 400-line budget).

Local review

Local ClawSweeper review (gpt-6.1-sol) on 9a18b4c: patch is correct, 0 findings. Earlier rounds found and this PR fixed: the lossy idempotent mark (now marked exactly once where controls leave core), Telegram sends queued by v2026.11.5, and Discord legacy {label, value} buttons and selects falling into the command fallback before the agent decoder (test: extensions/discord/src/monitor/monitor.test.ts "delivers marked legacy presentation controls as agent callback data", red without the fix).

obviyus and others added 3 commits November 19, 2026 14:35
Core marks callback values that a message action (or a tool-authored source
reply) authors as owned by the conversation's agent. The mark travels inside
the value, so every channel encoder, queued delivery and restart keeps it.
The plugin dispatcher strips it before namespace matching, and channels decode
an unclaimed tap with the new agentControlText() SDK helper into
`callback_data: <value>`.

Telegram drops its private tgac1/typedCallbackOwner plumbing; marked values
travel raw. Slack, LINE, Teams, Feishu, Mattermost and Discord (registry path)
decode the mark so it never reaches the agent.

Co-authored-by: obviyus <[email protected]>
Stamp each message action's callback values exactly once so an authored
leading colon survives; the runner's own Gateway hop already carries marked
params. Telegram keeps a read-only tgac1 decoder for buttons that
v2026.11.5 already delivered.

Co-authored-by: obviyus <[email protected]>
Direct message.action callers bypass the runner and reach plugins through
dispatchChannelMessageAction, so that leaf marks their controls too. The
runner's own Gateway hop also lands there with marked params, so marking is
idempotent; a two-colon mark keeps that lossless for any authored value that
does not itself start with "::".

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram agents Agent runtime and tooling channel: feishu Channel integration: feishu size: L labels Nov 19, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The PR marks agent-authored callback values centrally and decodes unclaimed taps into agent input across bundled channels.

Example: An agent sends a typed Discord button labeled Beta with callback value pick:beta.

  • Before: The agent receives a click description without the callback value.
  • After: The agent receives callback_data: pick:beta.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful shared ownership repair with real Telegram evidence, but a definite Discord regression, an inaccurate public guarantee, and incomplete cross-channel and upgrade evidence prevent a pass.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users tap agent-authored choices but the agent receives an unavailable result, metadata, or a description that omits the selected value.
Reason: Shared callback ownership has clear user value, and maintainer authorship plus the recorded tradeoffs settle the proposed direction.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses real callback-routing gaps, but Discord legacy buttons bypass the decoder and the new documentation overstates channel support.

Priority: P2
Reviewed head: 0683e30b381b832abd5b68a051708a6af5444828

Before merge

  • Decode marked Discord legacy values before command fallback (P2) - Send a Discord presentation button { label: "Beta", value: "pick:beta" } with no matching plugin handler. The new producer stamps it as ::pick:beta, but buildDiscordButtonComponent leaves callbackDataKind unset for this supported legacy shape. The existing commandFallback therefore becomes ::pick:beta and wins before this new decoder runs. The agent receives the private marker instead of callback_data: pick:beta; previously it received the original plain value. Give marked callbacks precedence over the legacy command fallback and cover this legacy rendering-to-tap path.
  • Document the channel and lifetime limits that still apply (P2) - The new public contract promises typed callback delivery on every channel without expiry. A typed callback button still becomes non-clickable fallback content in Feishu (resolveFeishuCommandButtonValue rejects its action) and Mattermost (resolveMattermostPresentation drops non-question typed actions). Discord also resolves registry entries with a default 30-minute TTL before reaching this decoder. Narrow this wording to supported callback shapes and retained lifetimes; the PR body already explicitly defers stateless Discord controls, so implementing that separate feature is unnecessary.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Decode marked Discord legacy values before command fallback — extensions/discord/src/monitor/agent-components.ts:150-151
  • [P2] Document the channel and lifetime limits that still apply — docs/plugins/message-presentation.md:148-150

Tests

  • Missing end-to-end proof: Author: provide a redacted shipped non-Telegram send/tap/agent trace and a v2026.11.5-to-head upgrade exercising existing tgac1 buttons and queued payloads, recording the explicitly accepted outcomes and removing keys, IPs, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Core prepares message actions and tool-authored replies for channel renderers; channel tap handlers route supported interactions to plugins or the conversation agent.

flowchart LR
A[Message actions and replies] --> B[Shared callback marker]
B --> C[Channel renderer]
C --> D[User tap]
D --> E[Channel interaction routing]
E --> F[Registered plugin handler]
E --> G[Conversation agent]
Loading

Technical review

Best possible solution:

Keep the shared codec and shipped Telegram decoder, decode Discord legacy controls before command fallback, and document actual channel and lifetime limits.

Do we have a high-confidence way to reproduce the issue?

Current source establishes the original fallback inconsistencies and the introduced Discord legacy-button failure; supplied Telegram timelines demonstrate the changed shared path, but this review executed no target code.

Is this the best way to solve the issue?

A small shared codec fits the existing producer, dispatcher, and adapter owners; a new registry or stateless Discord redesign is unnecessary for this repair.

Full review comments:

  • [P2] Decode marked Discord legacy values before command fallback — extensions/discord/src/monitor/agent-components.ts:150-151
    Send a Discord presentation button { label: "Beta", value: "pick:beta" } with no matching plugin handler. The new producer stamps it as ::pick:beta, but buildDiscordButtonComponent leaves callbackDataKind unset for this supported legacy shape. The existing commandFallback therefore becomes ::pick:beta and wins before this new decoder runs. The agent receives the private marker instead of callback_data: pick:beta; previously it received the original plain value. Give marked callbacks precedence over the legacy command fallback and cover this legacy rendering-to-tap path.
    Confidence: 0.99
  • [P2] Document the channel and lifetime limits that still apply — docs/plugins/message-presentation.md:148-150
    The new public contract promises typed callback delivery on every channel without expiry. A typed callback button still becomes non-clickable fallback content in Feishu (resolveFeishuCommandButtonValue rejects its action) and Mattermost (resolveMattermostPresentation drops non-question typed actions). Discord also resolves registry entries with a default 30-minute TTL before reaching this decoder. Narrow this wording to supported callback shapes and retained lifetimes; the PR body already explicitly defers stateless Discord controls, so implementing that separate feature is unnecessary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dbf41b9173f6.

Provenance checked

  • Telegram agent ownership changes intended behavior with a stated reason (928c118: Distinguish agent-authored typed callbacks from retired plugin controls without changing shared contracts.)
  • Telegram plugin and native-command routing keeps the original intent (fix(telegram): preserve callback action ownership #116383: Prevent plugins from claiming native commands and give unclaimed typed plugin controls a visible terminal outcome.)
  • Shared plugin interactive dispatcher keeps the original intent (0b849a3: Centralize callback context construction and conversation-binding authorization across channel adapters.)
  • Typed presentation transport semantics keeps the original intent (d641126: Render typed actions only where channels can preserve their semantics; unsupported controls remain readable fallback text.)
  • LINE postback selections keeps the original intent (ead8876: Preserve callback tokens and separately supplied selections while keeping raw command input distinct.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced changes and current main: Reviewed the pinned merge-base-to-head changes; fetched main retains the prior callback implementation in the central owners and renderers inspected. (src/interactive/agent-control.ts:35, 0683e30b381b)
  • Discord legacy callback bypass: The renderer leaves callbackDataKind unset for legacy value buttons; commandFallback therefore contains the marked value and wins before agentControlText is evaluated. (extensions/discord/src/monitor/agent-components.ts:151, 0683e30b381b)
  • Unsupported typed callbacks remain intentional: Mattermost still rejects non-question typed actions, and Feishu's command-button resolver rejects typed callbacks; changing only their incoming legacy-value handlers does not create typed callback buttons. (extensions/mattermost/src/normalize.ts:93, 0683e30b381b)
  • Discord controls still expire: Discord registry entries retain the default 30-minute lifetime and are resolved before the new callback decoder runs. (extensions/discord/src/components-registry.ts:17, 0683e30b381b)
  • Full supplied behavior evidence inspected: Read the complete PR body, including previously omitted Telegram timelines showing pick:beta reaching the agent on this head and after restart; verified body SHA-256 6431817f041ea909769f54cc1cb77701310f09937e3f63666884f3ae23eec839. (0683e30b381b)
  • Maintainer-recorded tradeoffs: The maintainer-authored body explicitly accepts leading-:: ambiguity, old pending Telegram controls becoming unavailable, third-party adapters exposing the mark, and Discord's retained lifetime; these choices require no second direction approval. (0683e30b381b)

Likely related people:

  • Peter Steinberger: Raw commit 0b849a3 adds src/plugins/interactive.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0b849a316dca; files: src/plugins/interactive.ts)

PR surface

Source +48, Tests +218, Docs +9. Total +275 across 35 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 19 126 78 +48
Tests 14 294 76 +218
Docs 2 12 3 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 432 157 +275

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Callback wire overhead 2 bytes; Telegram authored values limited to 62 UTF-8 bytes Ownership now consumes transport value capacity, including legacy values that previously had the full Telegram budget.
Public SDK expansion 1 additive export: agentControlText Channel adapters can decode the new marker through the existing focused interactive-runtime subpath.

Labels

Label changes:

  • add P2: Callback-value handling affects specific interactive workflows while ordinary channel messaging remains available.
  • add merge-risk: 🚨 compatibility: The PR changes adapter-visible callback bytes and expands the public SDK; the maintainer-authored body accepts raw-marker exposure in unadapted third-party channels and changed handling of old queued Telegram controls.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Callback-value handling affects specific interactive workflows while ordinary channel messaging remains available.
  • merge-risk: 🚨 compatibility: The PR changes adapter-visible callback bytes and expands the public SDK; the maintainer-authored body accepts raw-marker exposure in unadapted third-party channels and changed handling of old queued Telegram controls.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 5:20 AM ET / 10:20 UTC.

v2026.11.5 persisted agent ownership in channelData.telegram.typedCallbackOwner
instead of the value. Sends still queued across the upgrade now get the core
mark when Telegram canonicalizes them, so their taps still reach the agent.
Also covers direct Gateway message actions at the plugin dispatch leaf.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Local review on 735a4ec290b8 reported one P2: an authored callback value that starts with :: is read as already marked. This is intentionally not fixed. One message action can pass a marking point twice (the runner forwards marked params over its own Gateway message.action hop, which also marks direct callers), so marking must be idempotent. Telling authored :: apart from an internal re-entry would need a new hop flag in the protocol, which this change avoids. The result is visible and recoverable: the tap still reaches the agent, without the leading ::. It is listed under accepted edges in the PR body.

@obviyus
obviyus marked this pull request as ready for review November 19, 2026 11:02
obviyus and others added 5 commits November 19, 2026 16:53
Spread real modules in the Mattermost interaction mocks, and run the Telegram
wire-bytes integration test on the core-forced path without the queue so it
needs no database-worker job.

Co-authored-by: obviyus <[email protected]>
Mark at the leaves a delivery reaches exactly once (plugin action dispatch,
the core send path before queue persistence, tool-authored source replies)
instead of at the runner entry, whose params can re-enter through the
Gateway message.action hop. Marking is now unconditional, so every authored
callback value round-trips exactly, including ones that start with "::".

Co-authored-by: obviyus <[email protected]>
A v2026.11.5 tgac1 button now continues as the core-marked value it stands
for, so the dispatcher's single mark strip returns its exact authored value,
including one that starts with "::".

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus merged commit cd2ae19 into main Nov 19, 2026
141 checks passed
@obviyus
obviyus deleted the fix-agent-control-taps branch November 19, 2026 17:19
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as cd2ae19. Buttons the agent sends with the message tool now carry a core-owned mark inside the button value. When no plugin claims a tap, every bundled channel (Telegram, Slack, Discord registry path, Teams, LINE, Feishu, Mattermost) delivers it to the agent as callback_data: <value>. Shipped v2026.11.5 tgac1 buttons and sends that v2026.11.5 left in the delivery queue keep working. Proof: tests through each channel's tap handler fail on base and pass on head; a real Telegram run delivered the agent-authored value ::x exactly and still delivered a tap made after a Gateway restart; local review came back with 0 findings; CI is green. Next: stateless Discord presentation controls (remove the 30-minute registry TTL) and typed buttons on Mattermost and Feishu.

obviyus added a commit that referenced this pull request Nov 20, 2026
…taps arrive once (#201973)

## Problem

Follow-up to #201764 (core marks agent-authored controls) for two channels:

- **Mattermost and Feishu drop typed callback buttons.** A `message` action button with `action: { type: "callback", value }` is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy `{ label, value }` buttons render.
- **Mattermost delivers every button click twice.** The interaction handler enqueues a `Mattermost button click: action="…"` system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

## Root cause

- `extensions/mattermost/src/normalize.ts` (`resolveMattermostPresentation`): any button with an `action` that is not an `ask_user` question returns `[]`.
- `extensions/feishu/src/presentation-card.ts` (`resolveFeishuCommandButtonValue`): any `action` other than `command` returns `undefined`, so the button degrades to a markdown label.
- `extensions/mattermost/src/mattermost/interactions.ts`: after the post update, the handler both calls `core.system.enqueueSystemEvent(…)` (resolving the session through a separate `resolveSessionKey` callback) and `dispatchButtonClick(…)`, which runs the normal inbound path.

## Solution

- Mattermost and Feishu render a typed callback button when a message action marked it for the agent (`agentControlText(value)` is defined). The existing tap paths already decode the mark (#201764): Mattermost through the signed `callback_data` context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
- Mattermost delivers a click once, through `dispatchButtonClick` (the inbound path with the sender's identity and session plan). The system-event block and the `resolveSessionKey` callback that only served it are deleted.

## What was deleted

- Mattermost's duplicate system-event delivery and its `resolveSessionKey` option (−44 lines).

## Accepted edges

- The agent no longer gets the `Mattermost button click: action="…" by … in channel …` system-event line; it gets the click once as an inbound message (`callback_data: <value>` for agent buttons, `[Button click: user @… selected "…"]` for legacy ones).
- Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

## Tests (red on base, green on head)

| Test | Base | Head |
|---|---|---|
| `mattermost/normalize.question.test.ts`: marked typed callback renders with `callback_data: ::pick:a`; unmarked typed callback does not | ✗ (no button) | ✓ |
| `mattermost/interactions.test.ts`: a click calls `dispatchButtonClick` exactly once and enqueues no system event | ✗ (system event enqueued) | ✓ |
| `feishu/presentation-card.test.ts`: marked typed callback renders a callback button with `q: ::pick:a`; unmarked stays `- Plugin` | ✗ (label only) | ✓ |

The tap side (mark → `callback_data: <value>`) is covered by the #201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (`slash-http.boundary.test.ts` excluded: it fails identically on main), `pnpm tsgo:extensions`, `pnpm check:test-types`, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

## E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

## Size

- Production: +8 / −45 (net **−37**).
- Tests: +38.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 20, 2026
## Problem

On Discord, a button or select that the agent sends through the `message` tool (`presentation` with `action: { type: "callback" }` or a legacy `value`) stops working 30 minutes after it is sent, and after any Gateway restart that loses the in-memory registry: the tap answers "This component has expired." The agent never sees it. Follow-up to #201764, which made these taps reach the agent on every channel while the Discord callback is still registered.

## Root cause

Discord presentation controls get a random `occomp:cid=<id>` custom id, and the meaning of the tap lives only in the component registry (`extensions/discord/src/components.builders.ts:55-84`, select at `:194-244`), which expires after `agentComponents.ttlMs` (default 30 minutes) and is lost when persistence is unavailable. The resolver then replies "This component has expired." (`extensions/discord/src/monitor/agent-components.ts`, `handleDiscordComponentEvent`). Core already marks agent-authored values (#201764), so the value alone is enough to route the tap; it was just not carried by the component.

## Solution

Agent-authored controls are stateless:

- **Send** (`shared-interactive.ts`, `components.builders.ts`): a core-marked callback button gets the custom id `agent:<index>:<marked value>`; a select whose options are all core-marked gets `agentsel:<index>` and keeps the marked values as option values. No registry entry is written. The index keeps ids unique per message (duplicate values, several selects). The send-action parser (`components.parse.ts`, `readDiscordComponentSpec`), which re-reads the generated spec on the `message` tool path, keeps `agent:`/`agentsel:` ids; other internal ids (approvals, questions) stay builder-only.
- **Tap** (`monitor/agent-components.system-controls.ts`): the existing `agent`/`agentsel` component handlers, which no code path produced anymore, now handle these ids:
  1. the normal sender checks for components (`resolveAuthorizedComponentInteraction`: DM policy, pairing, guild/channel allowlists, policy freshness);
  2. single use unless the button sets `reusable: true` (carried in the id as `agent:<index>r:`): the tap response disables the agent's buttons and selects (Discord renders them greyed out and rejects further taps) and keeps the text, media, URL buttons and other controls unchanged; the message can never become empty. This happens before any handler runs, so a plugin-handled tap is single use too; a handler that edits the source message replaces that update;
  3. plugin first on the value (the core dispatcher strips the mark); select handlers get the selected option labels in `values`, as registry selects did;
  4. the value reaches the conversation's session as `callback_data: <value>` through the same dispatch as registry-backed components.
- Native `components` and forms keep the registry and `agentComponents.ttlMs`.

## What was deleted

- The legacy `agent:`/`agentsel:` system-event handler body (`[Discord component: … clicked by …]`), `parseAgentComponentData`, `ensureAgentComponentInteractionAllowed`, and their tests. Nothing produced these ids.
- Registry writes for agent-authored presentation controls.

## Accepted edges

- If any agent button value in a presentation does not fit Discord's 100-character custom id (values over about 90 characters), all of that presentation's agent controls use the registry path, one consumption group as before, and expire as before. Not dropped, not silent.
- Buttons sent before this change keep their registry entries and expire as before.
- A tap goes to the conversation's session (the normal inbound route of the channel and sender), not to the session that sent the message. This matches Telegram, Mattermost and Feishu after #201764, and it is what the agent-controls design specifies ("stateless taps re-run normal inbound auth and resolve the conversation session"). Before, Discord routed to the sender's session through the registry entry, which is the state that expires. Controls sent into a channel from another session (for example, a cron run) now reach that channel's session.

## Local review

- `[P2]` reusable buttons, `[P2]` URL buttons kept, `[P2]` empty container, `[P2]` controls-only message stayed tappable: fixed, with tests (consumed controls are now disabled instead of removed).
- `[P2]` plugin-handled tap skipped consumption, `[P2]` mixed short and long values, `[P2]` stateless select lost `values` for plugin handlers: fixed, with tests (red on `71786b2`, green on head).
- `[P1]` send parser dropped the generated agent ids on the `message` tool path (the earlier tests bypassed the parser): fixed. The tests now render through `readDiscordComponentSpec`; without the parser fix 8 of 11 fail.
- `[P1]` sender session route: conversation-session routing approved by the maintainer, see accepted edges.

## Tests (red on base `cd2ae19272a3`, green on head)

`extensions/discord/src/monitor/monitor.agent-components.test.ts` renders a core-marked presentation through the real builders, clears the in-memory and persistent registry (restart or TTL expiry), and routes the tap to the registered control the way the Discord client resolves custom ids.

| Test | Base | Head |
|---|---|---|
| typed callback button after the registry is gone → `callback_data: pick:a`, controls removed, plugin offered `::pick:a` | ✗ "This component has expired." | ✓ |
| legacy value button after the registry is gone → `callback_data: /pick a` | ✗ "This component has expired." | ✓ |
| select choice after the registry is gone → `callback_data: size:m` | ✗ | ✓ |
| tapper outside the allowlist → "You are not authorized to use this button.", no dispatch | ✗ | ✓ |
| duplicate values and two selects in one message → distinct custom ids | ✓ (guard) | ✓ |

Gates: Discord extension suite, `pnpm tsgo:extensions`, `pnpm check:test-types`, oxlint and oxfmt on changed files.

- `monitor.agent-components.test.ts`: tapping an agent button disables it and keeps a URL button in the same row; a `reusable` agent button leaves the message unchanged and still delivers `callback_data: refresh`; a controls-only message has its control disabled, so a second tap cannot fire ; a plugin-claimed tap disables the control and the handler runs once; a select handler gets `values: ["Medium"]`; a presentation with one value too long for an id renders every agent control through the registry, in either order (added after local review).

## E2E

Not run live. Discord component clicks need a real user client: bots cannot click components, and the Discord E2E skill treats component clicks as manual (`.agents/skills/discord-e2e/features.md`). No computer-control node was available for a manual click. A maintainer can verify by sending a presentation button with the `message` tool, restarting the Gateway (or waiting 30 minutes), and tapping it.

## Size

- Production: +115 / −126 (net **−11**).
- Tests/docs: −185 net (legacy handler tests removed).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…penclaw#201764)

## Problem

A button the agent sends with the `message` tool (`presentation` button with `action: { type: "callback", value }`, or a legacy `value`) has no recorded owner. When no plugin claims the tap, each channel guesses:

- **Slack**: the agent gets a `Slack interaction: {json…}` system event instead of the value.
- **Discord** (registry path): the agent gets only `Clicked "<label>"`; the callback value is lost.
- **Teams**: the agent gets the raw card JSON `{"value":…,"label":…}`.
- **Telegram**: v2026.11.5 and main already deliver `message`-tool buttons through a Telegram-private patch (`tgac1`, backported to stable as `9afcc1b7b29a`), so the plain send/edit path works on stable (E2E below). That patch is set only by Telegram's `prepareSendPayload` hook and its edit path. Paths that skip it still render the plugin envelope `tgcb1:` and expire with "This action is no longer available.": the queue-persistence/`forceCoreDelivery` path, tool-authored source replies and legacy `interactive`. Builds before v2026.11.5 expire every typed agent button. Legacy slash values run as commands.

The main user-visible fixes are the other channels; on Telegram this PR replaces the private patch with the core owner and covers the paths it missed.
- **Feishu / Mattermost / LINE**: legacy values pass through without an owner.

## Root cause

`MessagePresentationAction { type: "callback" }` is "opaque callback value interpreted by the target channel/plugin" (`src/interactive/payload.ts:78-82`), and the SDK dispatcher returns only `{ matched: false }` for an unclaimed tap (`src/plugins/interactive.ts:63-65`). Nothing records that the agent owns the control, so each channel picks its own fallback. Telegram patched this privately with `channelData.telegram.typedCallbackOwner`, which was set on only two producer paths (`extensions/telegram/src/channel-actions.ts:215-249`, `button-types.ts:270-282`).

## Solution

One core owner records ownership **inside the value**:

- `src/interactive/agent-control.ts` (new, core-private codec): `stampAgentControls()` prefixes every callback value that a message action authors with a 2-byte mark (`::`), unconditionally; the decoder removes exactly one mark, so every authored value round-trips (`::pick:a` → `callback_data: ::pick:a`). A leading `:` is an empty namespace, and the plugin registry refuses empty namespaces (`interactive-registry.ts:58-68`), so a plugin can never claim a value by its mark.
- Marking happens where controls **leave core for a channel**, which a delivery reaches exactly once (not at the runner entry, whose params can re-enter through the runner's own Gateway `message.action` hop):
  - `dispatchChannelMessageAction`: the plugin-action leaf, for runner actions and direct Gateway `message.action` callers.
  - `executeSendAction` core branch: right before `sendMessage` persists the payload to the outbound queue, so recovered sends keep the mark. Queue recovery delivers the stored payload without passing a leaf again.
  - `extractToolAuthoredSourceReplyPayload`: tool-authored source replies, which are delivered by the reply pipeline, not by either leaf above.
- `dispatchPluginInteractiveHandler` strips the mark before namespace matching and passes the plain value to the handler. The result type is unchanged.
- Additive SDK exports on `openclaw/plugin-sdk/interactive-runtime`: `agentControlText(data)` returns `callback_data: <value>` for a marked value and `undefined` otherwise; `stampAgentControls(payload)` marks a payload's callback controls (Telegram uses it once, for sends queued by v2026.11.5).
- Channels: an unclaimed tap → `agentControlText(data) ?? <current behavior>`.
  - **Telegram**: marked values travel raw in `callback_data` (62 bytes for the agent's value; the old `tgac1:` envelope left 52). Unmarked typed values keep the `tgcb1` envelope, and an unclaimed one still answers "This action is no longer available." (openclaw#116383 semantics).
  - **Slack, LINE, Teams, Feishu (legacy quick envelope), Mattermost (legacy signed context), Discord (registry path)**: decode the mark so it never reaches the agent.

The mark is part of the value, so every encoder, the delivery queue and a Gateway restart keep it without channel cooperation. No state, config, schema, timers or flags.

## What was deleted

- Telegram: `TELEGRAM_AGENT_CALLBACK_PREFIX` (`tgac1:`), `TelegramTypedCallbackOwner`, the `owner` parameter, `hasTelegramAgentCallbackPrefix` / `parseTelegramAgentCallbackData`, `typedCallbackOwner` in `TelegramButtonBuildOptions`, the `prepareSendPayload` mark and its `interactive-fallback` reader, and the router's `tgac1` branches.
- `tgac1` shipped in v2026.11.5 (backport `9afcc1b7b29a`), so a read-only `tgac1` decoder stays in the Telegram router for buttons already in chats (plugin-first on the inner value, then `callback_data: <value>`). Outgoing agent buttons no longer use it; remove the reader once those messages have aged out. Sends still queued by v2026.11.5 carry `channelData.telegram.typedCallbackOwner: "agent"`; Telegram's canonicalize step marks those with the core codec (remove once such queue rows have drained).

## Accepted edges (named, not coded)

- Typed agent buttons delivered as `tgcb1:` by stables before v2026.11.5 are indistinguishable from plugin buttons: they keep their current behavior (unclaimed → unavailable). The agent can resend.
- A plugin installed later can claim older agent buttons in its namespace (plugin-first is kept on the inner value).
- Values starting with `/` now arrive as `callback_data: /…` instead of running as commands. Use `action.type: "command"` for command buttons (docs updated).
- Marking closes a spoof: a legacy raw value could previously mint `tgcmd:` or approval-looking data on Telegram.
- Native passthrough (raw Telegram `reply_markup`, Slack blocks, Discord `components`) is not marked and keeps its current owner. Discord native components/forms keep the registry and `agentComponents.ttlMs`.
- Discord presentation buttons still use the 30-minute registry TTL. Stateless Discord controls are the next PR.
- Slack delivers the tap as a session system event (now the plain `callback_data: <value>` text), not a user message.
- Repeat taps produce repeat turns, the same as typing twice. Telegram still clears the keyboard on tap.
- Third-party channel plugins that forward raw callback values show the 2-byte mark to the agent until they adopt `agentControlText`.
- Teams/Mattermost value size is unbounded (needs a separate decision).
- Taps route to the conversation's session (unchanged for Telegram, Slack, Teams, LINE, Mattermost).

## Plugin SDK impact

- Additive: `agentControlText` and `stampAgentControls` on `plugin-sdk/interactive-runtime` (the focused presentation subpath; `plugin-runtime` is a deprecated broad barrel). No type change; `MessagePresentationAction` and the dispatcher result are unchanged.
- Behavior: message-action callback values reach channel adapters with a leading `::`, and plugin interactive handlers receive the value without it.
- ClawHub static usage (plugin-sdk-impact, 2026-11-19, 2,675 eligible releases, coverage incomplete: 423 partial, 1 failed): `api.registerInteractiveHandler` 10 plugins, `plugin-runtime#dispatchPluginInteractiveHandler` 3, `#createChannelInteractiveDispatcher` 2, `#registerPluginInteractiveHandler` 1. Handlers keep receiving the same `namespace`/`payload`; channel plugins that forward raw values see the mark (degradation, not a break). Bundled source scan not run.

## Tests (red on base `80a1676e6269`, green on head)

Wire bytes come from a real send through `runMessageAction` → the Telegram plugin → a loopback Bot API (`test/telegram-agent-control-taps.integration.test.ts`); the Telegram tap tests feed those exact bytes through the real callback router.

| Test | Base | Head |
|---|---|---|
| `test/telegram-agent-control-taps.integration.test.ts` send on the core-forced path (`forceCoreDelivery`, what queue persistence uses; skips `prepareSendPayload`) + edit → `callback_data` | ✗ (`tgcb1:`/`tgac1:` envelopes) | ✓ `::/pick a\|1`, `::pick:b`, 64-byte legacy |
| `bot.agent-callbacks`: unclaimed agent tap → `callback_data: /pick a\|1`, no mark | ✗ | ✓ |
| `bot.agent-callbacks`: plugin claims inner value first | ✗ | ✓ |
| `bot.agent-callbacks`: mention-gated group tap delivered | ✗ | ✓ |
| `bot.agent-callbacks`: agent control with inline buttons off → unavailable | ✗ | ✓ |
| `bot.agent-callbacks`: `tgac1` button already sent by v2026.11.5 → `callback_data: pick:beta` | ✓ (guard) | ✓ |
| `bot.agent-callbacks`: unauthorized tapper ignored; unclaimed `tgcb1` → unavailable | ✓ (guard) | ✓ |
| `message-action-runner.plugin-dispatch`: runner → plugin marked once; authored `::a` → `::::a` | ✗ | ✓ |
| `message-action-gateway`: runner → Gateway `message.action` hop forwards controls unmarked (the Gateway leaf marks once) | ✓ (guard) | ✓ |
| `outbound-send-service`: core send marks once before queue persistence | ✗ | ✓ |
| `message-action-dispatch.registry`: direct Gateway message action marked once; authored `::pick:a` round-trips | ✗ | ✓ |
| `interactive-fallback`: send queued by v2026.11.5 with `typedCallbackOwner` → `::pick:a` | ✗ | ✓ |
| `embedded-agent-messaging-extraction.tool-authored`: source reply marked once (`:pick:a` → `:::pick:a`) | ✗ | ✓ |
| `src/plugins/interactive.test.ts`: decode removes exactly one mark (`::::pick:a` → `callback_data: ::pick:a`) | ✗ | ✓ |
| `src/plugins/interactive.test.ts` dispatcher matches by value, not mark | ✗ | ✓ |
| `embedded-agent-messaging-extraction.tool-authored` source reply marked | ✗ | ✓ |
| Slack `interactions.lifecycle`, LINE `bot-message-context`, Teams `monitor-handler.adaptive-card`, Feishu `bot.card-action`, Mattermost `monitor-interactions.question` + `interactions` | ✗ each | ✓ each |

Consumer suites rerun on head: Telegram, Slack events, LINE, Teams, Feishu, Mattermost, Discord monitor, `src/infra/outbound` (107 files), `src/interactive`. `message-action-runner.plugin-dispatch` updated for the marked value. `extensions/mattermost/src/mattermost/slash-http.boundary.test.ts` fails identically on base (inherited, untouched).

Gates: `pnpm tsgo:core`, `pnpm check:test-types`, oxlint/oxfmt on changed files, rg for removed symbols (only the historical `config/test-lines-allocations/196217-*` record mentions `tgac1`).

## E2E (Telegram Test Server, real user via TDLib, isolated scratch Gateway from source, real model `gpt-5.5`)

The agent was asked to send "Pick one <run>" with Alpha/Beta callback buttons through the `message` tool and to reply `GOT <value>` after a tap; the userbot tapped Beta.

| Run | Rendered `callback_data` (Beta) | Agent received / replied |
|---|---|---|
| Base v2026.11.5 | `tgac1:17dsn:pick:beta` | `GOT pick:beta` |
| Head `a960e5e7ac4c`, authored value `::pick:beta` | `::::pick:beta` | `GOT ::pick:beta` (exact round trip, one mark removed) |
| Head `a960e5e7ac4c`, Gateway restarted after the turn (121 s), then the original message's button tapped | `::pick:beta` | `GOT pick:beta` |

Re-run on the final Telegram code (heads `8d5d953` / `9a18b4c`; the last commit touches only Discord):

| Run | Agent received / replied |
|---|---|
| Plain Beta tap (`pick:beta`) | `GOT pick:beta` |
| Authored value `::x` | `GOT ::x` (exact round trip) |
| Scratch Gateway restarted between send and tap (`9a18b4c`) | `GOT pick:beta` |

Note: v2026.11.5 already carries the `tgac1` backport, so the plain message-tool send/edit path on Telegram is not red on stable. On Telegram, this PR replaces that private patch with the core owner (no regression, now also covering the paths that skip `prepareSendPayload`). The user-visible base defects are on the other channels, proven by the handler tests above.

<details><summary>Sanitized E2E timelines (TDLib recorder, real user, real model gpt-5.5)</summary>

#### Base v2026.11.5 (e13cf15)
```text
    193 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
    193 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
 126937 ms  message bot     Pick one 3E6C05F3  callback_data=[['tgac1:bcaw3:pick:alpha', 'tgac1:17dsn:pick:beta']]  (msg 013568)
 127389 ms  action       click completed Beta  (msg 013568)
 127944 ms  message bot     Working / Message: running
 129930 ms  edit    bot     Working / Last activity: Message
 132155 ms  delete  bot
 140750 ms  message bot     GOT pick:beta
```
#### Head a960e5e, authored Beta value `::pick:beta`
```text
    186 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (::pick:beta) callback buttons; reply GOT <value> on tap>
    187 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (::pick:beta) callback buttons; reply GOT <value> on tap>
  55704 ms  message bot     Pick one 69957FA7  callback_data=[['::pick:alpha', '::::pick:beta']]  (msg 184320)
  56063 ms  action       click completed Beta  (msg 184320)
  58691 ms  message bot     Working / ✉️ Message
  61747 ms  message bot     GOT ::pick:beta
  62921 ms  delete  bot
```
#### Head a960e5e, Gateway restarted between send and tap
```text
    192 ms  action       send completed  <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
    192 ms  message user    <prompt: send "Pick one <run>" with Alpha (pick:alpha) / Beta (pick:beta) callback buttons; reply GOT <value> on tap>
  68815 ms  message bot     Pick one 5F394A3C  callback_data=[['::pick:alpha', '::pick:beta']]  (msg 378624)
  68815 ms  action       awaitReply completed  Pick one 5F394A3C
  70886 ms  message bot     Working / ✉️ Message running
  71983 ms  edit    bot     Working / ✉️ Message
  74975 ms  delete  bot
 480757 ms  action       click completed Beta  (msg 378624)
 510229 ms  message bot     GOT pick:beta
gateway action: restartGateway at 150002 ms, took 120775 ms, completed
```

</details>

## Size

- Production: +153 / −81 (net **+72**). Telegram −32 (includes the read-only `tgac1` decoder and the v2026.11.5 queued-send reader); core codec, the three exactly-once leaves, dispatcher strip and SDK exports +89; six channel decoders +15. Not net negative: the line-cap ratchet required a sibling codec module and kept Telegram's existing `resolveTelegramButtonsFromParams` wrapper; shipped-stable compatibility (v2026.11.5 `tgac1` buttons and queued sends) and exactly-once leaf marking were added in review. The series goes net negative in the same owner: Discord stateless controls retire the unused `agent:`/`agentsel:` handlers (133 lines), and Mattermost drops its duplicate tap delivery.
- Tests/docs/test config: +287 net (old `tgac1` tests deleted; test lines within the 400-line budget).

## Local review

Local ClawSweeper review (gpt-6.1-sol) on `9a18b4c`: **patch is correct, 0 findings**. Earlier rounds found and this PR fixed: the lossy idempotent mark (now marked exactly once where controls leave core), Telegram sends queued by v2026.11.5, and Discord legacy `{label, value}` buttons and selects falling into the command fallback before the agent decoder (test: `extensions/discord/src/monitor/monitor.test.ts` "delivers marked legacy presentation controls as agent callback data", red without the fix).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…taps arrive once (openclaw#201973)

## Problem

Follow-up to openclaw#201764 (core marks agent-authored controls) for two channels:

- **Mattermost and Feishu drop typed callback buttons.** A `message` action button with `action: { type: "callback", value }` is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy `{ label, value }` buttons render.
- **Mattermost delivers every button click twice.** The interaction handler enqueues a `Mattermost button click: action="…"` system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

## Root cause

- `extensions/mattermost/src/normalize.ts` (`resolveMattermostPresentation`): any button with an `action` that is not an `ask_user` question returns `[]`.
- `extensions/feishu/src/presentation-card.ts` (`resolveFeishuCommandButtonValue`): any `action` other than `command` returns `undefined`, so the button degrades to a markdown label.
- `extensions/mattermost/src/mattermost/interactions.ts`: after the post update, the handler both calls `core.system.enqueueSystemEvent(…)` (resolving the session through a separate `resolveSessionKey` callback) and `dispatchButtonClick(…)`, which runs the normal inbound path.

## Solution

- Mattermost and Feishu render a typed callback button when a message action marked it for the agent (`agentControlText(value)` is defined). The existing tap paths already decode the mark (openclaw#201764): Mattermost through the signed `callback_data` context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
- Mattermost delivers a click once, through `dispatchButtonClick` (the inbound path with the sender's identity and session plan). The system-event block and the `resolveSessionKey` callback that only served it are deleted.

## What was deleted

- Mattermost's duplicate system-event delivery and its `resolveSessionKey` option (−44 lines).

## Accepted edges

- The agent no longer gets the `Mattermost button click: action="…" by … in channel …` system-event line; it gets the click once as an inbound message (`callback_data: <value>` for agent buttons, `[Button click: user @… selected "…"]` for legacy ones).
- Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

## Tests (red on base, green on head)

| Test | Base | Head |
|---|---|---|
| `mattermost/normalize.question.test.ts`: marked typed callback renders with `callback_data: ::pick:a`; unmarked typed callback does not | ✗ (no button) | ✓ |
| `mattermost/interactions.test.ts`: a click calls `dispatchButtonClick` exactly once and enqueues no system event | ✗ (system event enqueued) | ✓ |
| `feishu/presentation-card.test.ts`: marked typed callback renders a callback button with `q: ::pick:a`; unmarked stays `- Plugin` | ✗ (label only) | ✓ |

The tap side (mark → `callback_data: <value>`) is covered by the openclaw#201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (`slash-http.boundary.test.ts` excluded: it fails identically on main), `pnpm tsgo:extensions`, `pnpm check:test-types`, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

## E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

## Size

- Production: +8 / −45 (net **−37**).
- Tests: +38.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
)

## Problem

On Discord, a button or select that the agent sends through the `message` tool (`presentation` with `action: { type: "callback" }` or a legacy `value`) stops working 30 minutes after it is sent, and after any Gateway restart that loses the in-memory registry: the tap answers "This component has expired." The agent never sees it. Follow-up to openclaw#201764, which made these taps reach the agent on every channel while the Discord callback is still registered.

## Root cause

Discord presentation controls get a random `occomp:cid=<id>` custom id, and the meaning of the tap lives only in the component registry (`extensions/discord/src/components.builders.ts:55-84`, select at `:194-244`), which expires after `agentComponents.ttlMs` (default 30 minutes) and is lost when persistence is unavailable. The resolver then replies "This component has expired." (`extensions/discord/src/monitor/agent-components.ts`, `handleDiscordComponentEvent`). Core already marks agent-authored values (openclaw#201764), so the value alone is enough to route the tap; it was just not carried by the component.

## Solution

Agent-authored controls are stateless:

- **Send** (`shared-interactive.ts`, `components.builders.ts`): a core-marked callback button gets the custom id `agent:<index>:<marked value>`; a select whose options are all core-marked gets `agentsel:<index>` and keeps the marked values as option values. No registry entry is written. The index keeps ids unique per message (duplicate values, several selects). The send-action parser (`components.parse.ts`, `readDiscordComponentSpec`), which re-reads the generated spec on the `message` tool path, keeps `agent:`/`agentsel:` ids; other internal ids (approvals, questions) stay builder-only.
- **Tap** (`monitor/agent-components.system-controls.ts`): the existing `agent`/`agentsel` component handlers, which no code path produced anymore, now handle these ids:
  1. the normal sender checks for components (`resolveAuthorizedComponentInteraction`: DM policy, pairing, guild/channel allowlists, policy freshness);
  2. single use unless the button sets `reusable: true` (carried in the id as `agent:<index>r:`): the tap response disables the agent's buttons and selects (Discord renders them greyed out and rejects further taps) and keeps the text, media, URL buttons and other controls unchanged; the message can never become empty. This happens before any handler runs, so a plugin-handled tap is single use too; a handler that edits the source message replaces that update;
  3. plugin first on the value (the core dispatcher strips the mark); select handlers get the selected option labels in `values`, as registry selects did;
  4. the value reaches the conversation's session as `callback_data: <value>` through the same dispatch as registry-backed components.
- Native `components` and forms keep the registry and `agentComponents.ttlMs`.

## What was deleted

- The legacy `agent:`/`agentsel:` system-event handler body (`[Discord component: … clicked by …]`), `parseAgentComponentData`, `ensureAgentComponentInteractionAllowed`, and their tests. Nothing produced these ids.
- Registry writes for agent-authored presentation controls.

## Accepted edges

- If any agent button value in a presentation does not fit Discord's 100-character custom id (values over about 90 characters), all of that presentation's agent controls use the registry path, one consumption group as before, and expire as before. Not dropped, not silent.
- Buttons sent before this change keep their registry entries and expire as before.
- A tap goes to the conversation's session (the normal inbound route of the channel and sender), not to the session that sent the message. This matches Telegram, Mattermost and Feishu after openclaw#201764, and it is what the agent-controls design specifies ("stateless taps re-run normal inbound auth and resolve the conversation session"). Before, Discord routed to the sender's session through the registry entry, which is the state that expires. Controls sent into a channel from another session (for example, a cron run) now reach that channel's session.

## Local review

- `[P2]` reusable buttons, `[P2]` URL buttons kept, `[P2]` empty container, `[P2]` controls-only message stayed tappable: fixed, with tests (consumed controls are now disabled instead of removed).
- `[P2]` plugin-handled tap skipped consumption, `[P2]` mixed short and long values, `[P2]` stateless select lost `values` for plugin handlers: fixed, with tests (red on `71786b2`, green on head).
- `[P1]` send parser dropped the generated agent ids on the `message` tool path (the earlier tests bypassed the parser): fixed. The tests now render through `readDiscordComponentSpec`; without the parser fix 8 of 11 fail.
- `[P1]` sender session route: conversation-session routing approved by the maintainer, see accepted edges.

## Tests (red on base `2887e01d8fa9`, green on head)

`extensions/discord/src/monitor/monitor.agent-components.test.ts` renders a core-marked presentation through the real builders, clears the in-memory and persistent registry (restart or TTL expiry), and routes the tap to the registered control the way the Discord client resolves custom ids.

| Test | Base | Head |
|---|---|---|
| typed callback button after the registry is gone → `callback_data: pick:a`, controls removed, plugin offered `::pick:a` | ✗ "This component has expired." | ✓ |
| legacy value button after the registry is gone → `callback_data: /pick a` | ✗ "This component has expired." | ✓ |
| select choice after the registry is gone → `callback_data: size:m` | ✗ | ✓ |
| tapper outside the allowlist → "You are not authorized to use this button.", no dispatch | ✗ | ✓ |
| duplicate values and two selects in one message → distinct custom ids | ✓ (guard) | ✓ |

Gates: Discord extension suite, `pnpm tsgo:extensions`, `pnpm check:test-types`, oxlint and oxfmt on changed files.

- `monitor.agent-components.test.ts`: tapping an agent button disables it and keeps a URL button in the same row; a `reusable` agent button leaves the message unchanged and still delivers `callback_data: refresh`; a controls-only message has its control disabled, so a second tap cannot fire ; a plugin-claimed tap disables the control and the handler runs once; a select handler gets `values: ["Medium"]`; a presentation with one value too long for an id renders every agent control through the registry, in either order (added after local review).

## E2E

Not run live. Discord component clicks need a real user client: bots cannot click components, and the Discord E2E skill treats component clicks as manual (`.agents/skills/discord-e2e/features.md`). No computer-control node was available for a manual click. A maintainer can verify by sending a presentation button with the `message` tool, restarting the Gateway (or waiting 30 minutes), and tapping it.

## Size

- Production: +115 / −126 (net **−11**).
- Tests/docs: −185 net (legacy handler tests removed).

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…taps arrive once (#201973)

## Problem

Follow-up to #201764 (core marks agent-authored controls) for two channels:

- **Mattermost and Feishu drop typed callback buttons.** A `message` action button with `action: { type: "callback", value }` is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy `{ label, value }` buttons render.
- **Mattermost delivers every button click twice.** The interaction handler enqueues a `Mattermost button click: action="…"` system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

## Root cause

- `extensions/mattermost/src/normalize.ts` (`resolveMattermostPresentation`): any button with an `action` that is not an `ask_user` question returns `[]`.
- `extensions/feishu/src/presentation-card.ts` (`resolveFeishuCommandButtonValue`): any `action` other than `command` returns `undefined`, so the button degrades to a markdown label.
- `extensions/mattermost/src/mattermost/interactions.ts`: after the post update, the handler both calls `core.system.enqueueSystemEvent(…)` (resolving the session through a separate `resolveSessionKey` callback) and `dispatchButtonClick(…)`, which runs the normal inbound path.

## Solution

- Mattermost and Feishu render a typed callback button when a message action marked it for the agent (`agentControlText(value)` is defined). The existing tap paths already decode the mark (#201764): Mattermost through the signed `callback_data` context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
- Mattermost delivers a click once, through `dispatchButtonClick` (the inbound path with the sender's identity and session plan). The system-event block and the `resolveSessionKey` callback that only served it are deleted.

## What was deleted

- Mattermost's duplicate system-event delivery and its `resolveSessionKey` option (−44 lines).

## Accepted edges

- The agent no longer gets the `Mattermost button click: action="…" by … in channel …` system-event line; it gets the click once as an inbound message (`callback_data: <value>` for agent buttons, `[Button click: user @… selected "…"]` for legacy ones).
- Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

## Tests (red on base, green on head)

| Test | Base | Head |
|---|---|---|
| `mattermost/normalize.question.test.ts`: marked typed callback renders with `callback_data: ::pick:a`; unmarked typed callback does not | ✗ (no button) | ✓ |
| `mattermost/interactions.test.ts`: a click calls `dispatchButtonClick` exactly once and enqueues no system event | ✗ (system event enqueued) | ✓ |
| `feishu/presentation-card.test.ts`: marked typed callback renders a callback button with `q: ::pick:a`; unmarked stays `- Plugin` | ✗ (label only) | ✓ |

The tap side (mark → `callback_data: <value>`) is covered by the #201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (`slash-http.boundary.test.ts` excluded: it fails identically on main), `pnpm tsgo:extensions`, `pnpm check:test-types`, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

## E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

## Size

- Production: +8 / −45 (net **−37**).
- Tests: +38.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 66fc4d8)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 580696656a79f3b8ec9e7831e6e50726f0ca29cf)
(cherry picked from commit 2478713e7e82e228f4ea292448fd17799faa0654)
obviyus added a commit that referenced this pull request Nov 27, 2026
…alues be clicked (#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: #206228 (comment)
- Chromium screenshots: #206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…alues be clicked (openclaw#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes openclaw#206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since openclaw#201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: openclaw#206228 (comment)
- Chromium screenshots: openclaw#206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…alues be clicked (#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: #206228 (comment)
- Chromium screenshots: #206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit be5d9a0)
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…alues be clicked (#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: #206228 (comment)
- Chromium screenshots: #206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit be5d9a0)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant