Repository navigation
fix: agent-authored message buttons reach the agent on every channel - #201764
Conversation
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]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThe 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Tests
Agent review detailsHow this fits togetherCore 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]
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dbf41b9173f6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +48, Tests +218, Docs +9. Total +275 across 35 files. Added test files: 1. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment 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]>
|
Local review on |
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]>
Co-authored-by: obviyus <[email protected]>
…llback data Co-authored-by: obviyus <[email protected]>
|
Landed as cd2ae19. Buttons the agent sends with the |
…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]>
## 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]>
…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]>
…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]>
) ## 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]>
…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)
…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]>
…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]>
…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)
…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]>
Problem
A button the agent sends with the
messagetool (presentationbutton withaction: { type: "callback", value }, or a legacyvalue) has no recorded owner. When no plugin claims the tap, each channel guesses:Slack interaction: {json…}system event instead of the value.Clicked "<label>"; the callback value is lost.{"value":…,"label":…}.message-tool buttons through a Telegram-private patch (tgac1, backported to stable as9afcc1b7b29a), so the plain send/edit path works on stable (E2E below). That patch is set only by Telegram'sprepareSendPayloadhook and its edit path. Paths that skip it still render the plugin envelopetgcb1:and expire with "This action is no longer available.": the queue-persistence/forceCoreDeliverypath, tool-authored source replies and legacyinteractive. 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.
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 withchannelData.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.message.actionhop):dispatchChannelMessageAction: the plugin-action leaf, for runner actions and direct Gatewaymessage.actioncallers.executeSendActioncore branch: right beforesendMessagepersists 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.dispatchPluginInteractiveHandlerstrips the mark before namespace matching and passes the plain value to the handler. The result type is unchanged.openclaw/plugin-sdk/interactive-runtime:agentControlText(data)returnscallback_data: <value>for a marked value andundefinedotherwise;stampAgentControls(payload)marks a payload's callback controls (Telegram uses it once, for sends queued by v2026.11.5).agentControlText(data) ?? <current behavior>.callback_data(62 bytes for the agent's value; the oldtgac1:envelope left 52). Unmarked typed values keep thetgcb1envelope, and an unclaimed one still answers "This action is no longer available." (fix(telegram): preserve callback action ownership #116383 semantics).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_AGENT_CALLBACK_PREFIX(tgac1:),TelegramTypedCallbackOwner, theownerparameter,hasTelegramAgentCallbackPrefix/parseTelegramAgentCallbackData,typedCallbackOwnerinTelegramButtonBuildOptions, theprepareSendPayloadmark and itsinteractive-fallbackreader, and the router'stgac1branches.tgac1shipped in v2026.11.5 (backport9afcc1b7b29a), so a read-onlytgac1decoder stays in the Telegram router for buttons already in chats (plugin-first on the inner value, thencallback_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 carrychannelData.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)
tgcb1:by stables before v2026.11.5 are indistinguishable from plugin buttons: they keep their current behavior (unclaimed → unavailable). The agent can resend./now arrive ascallback_data: /…instead of running as commands. Useaction.type: "command"for command buttons (docs updated).tgcmd:or approval-looking data on Telegram.reply_markup, Slack blocks, Discordcomponents) is not marked and keeps its current owner. Discord native components/forms keep the registry andagentComponents.ttlMs.callback_data: <value>text), not a user message.agentControlText.Plugin SDK impact
agentControlTextandstampAgentControlsonplugin-sdk/interactive-runtime(the focused presentation subpath;plugin-runtimeis a deprecated broad barrel). No type change;MessagePresentationActionand the dispatcher result are unchanged.::, and plugin interactive handlers receive the value without it.api.registerInteractiveHandler10 plugins,plugin-runtime#dispatchPluginInteractiveHandler3,#createChannelInteractiveDispatcher2,#registerPluginInteractiveHandler1. Handlers keep receiving the samenamespace/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/telegram-agent-control-taps.integration.test.tssend on the core-forced path (forceCoreDelivery, what queue persistence uses; skipsprepareSendPayload) + edit →callback_datatgcb1:/tgac1:envelopes)::/pick a|1,::pick:b, 64-byte legacybot.agent-callbacks: unclaimed agent tap →callback_data: /pick a|1, no markbot.agent-callbacks: plugin claims inner value firstbot.agent-callbacks: mention-gated group tap deliveredbot.agent-callbacks: agent control with inline buttons off → unavailablebot.agent-callbacks:tgac1button already sent by v2026.11.5 →callback_data: pick:betabot.agent-callbacks: unauthorized tapper ignored; unclaimedtgcb1→ unavailablemessage-action-runner.plugin-dispatch: runner → plugin marked once; authored::a→::::amessage-action-gateway: runner → Gatewaymessage.actionhop forwards controls unmarked (the Gateway leaf marks once)outbound-send-service: core send marks once before queue persistencemessage-action-dispatch.registry: direct Gateway message action marked once; authored::pick:around-tripsinteractive-fallback: send queued by v2026.11.5 withtypedCallbackOwner→::pick:aembedded-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.tsdispatcher matches by value, not markembedded-agent-messaging-extraction.tool-authoredsource reply markedinteractions.lifecycle, LINEbot-message-context, Teamsmonitor-handler.adaptive-card, Feishubot.card-action, Mattermostmonitor-interactions.question+interactionsConsumer suites rerun on head: Telegram, Slack events, LINE, Teams, Feishu, Mattermost, Discord monitor,
src/infra/outbound(107 files),src/interactive.message-action-runner.plugin-dispatchupdated for the marked value.extensions/mattermost/src/mattermost/slash-http.boundary.test.tsfails identically on base (inherited, untouched).Gates:
pnpm tsgo:core,pnpm check:test-types, oxlint/oxfmt on changed files, rg for removed symbols (only the historicalconfig/test-lines-allocations/196217-*record mentionstgac1).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
messagetool and to replyGOT <value>after a tap; the userbot tapped Beta.callback_data(Beta)tgac1:17dsn:pick:betaGOT pick:betaa960e5e7ac4c, authored value::pick:beta::::pick:betaGOT ::pick:beta(exact round trip, one mark removed)a960e5e7ac4c, Gateway restarted after the turn (121 s), then the original message's button tapped::pick:betaGOT pick:betaRe-run on the final Telegram code (heads
8d5d953/9a18b4c; the last commit touches only Discord):pick:beta)GOT pick:beta::xGOT ::x(exact round trip)9a18b4c)GOT pick:betaNote: v2026.11.5 already carries the
tgac1backport, 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 skipprepareSendPayload). 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)
Head a960e5e, authored Beta value
::pick:betaHead a960e5e, Gateway restarted between send and tap
Size
tgac1decoder 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 existingresolveTelegramButtonsFromParamswrapper; shipped-stable compatibility (v2026.11.5tgac1buttons 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 unusedagent:/agentsel:handlers (133 lines), and Mattermost drops its duplicate tap delivery.tgac1tests 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).