Files
openclaw/extensions/line
Eden 8a141549f2 fix(line): keep group history recorded during a mention turn (#107367)
* fix(line): keep group history recorded during a mention turn

Group history cleanup ran a whole-key clear after each mention turn. Because
webhook dispatch is fire-and-forget, a plain (unmentioned) message can be
recorded while the agent is still handling a mention; the post-turn clear then
wiped the whole window, silently dropping that concurrent message from the
next turn's context.

Snapshot the identity keys the turn consumes up front and clear only those,
retaining anything recorded concurrently. The record path now stamps the LINE
message id so entries have a stable identity. Cleanup stays after the turn, so
a failed turn still leaves history intact for the retry. The snapshot/clear
helpers live in group-history.ts, next to the other group modules.

* test(line): cover group history retention when a mention turn fails

Assert that a mention turn whose processMessage throws leaves the group
history window intact (cleanup runs only after a successful turn), so the
retry still has the ambient context. Red/green verified: moving the cleanup
before the await fails this test.

* fix(line): capture consumed group history at the context read boundary

The consumed-key snapshot ran before media download and context
construction, while buildLineMessageContext copied the window later.
A plain message recorded between those awaits was included in the
turn's InboundHistory yet missing from the consumed set, so cleanup
retained it and the next mention received it twice.

Read the window and capture its identity keys in one synchronous step
in the handler (snapshotLineGroupHistory), then pass the materialized
inboundHistory into buildLineMessageContext instead of the live map.
The consumed set is now derived from the exact entries the turn reads,
so an entry is either in the context and cleared, or recorded later
and retained - there is no window where both can be true.

Regression tests park a mention turn inside context construction,
record an ambient message mid-window, and assert it stays out of that
turn's InboundHistory, survives cleanup, and is consumed exactly once
by the next mention. Red/green verified against the previous snapshot
placement.

* test(line): point history-window guardrail at group-history.ts

The group-history cleanup fix moved the createChannelHistoryWindow facade
call out of bot-message-context.ts (which now receives inboundHistory as a
parameter) into the new group-history.ts. Update the cross-channel
historyWindowFiles ledger to match, mirroring telegram's group-history-window.ts
entry already in the same list. Fixes the message-turn-guardrails 'keeps
migrated history users on the channel history window facade' assertion that
build-artifacts flagged.

* fix(line): reserve history across concurrent turns

Co-authored-by: Eden <146086744+edenfunf@users.noreply.github.com>

* test(line): complete webhook message fixtures

* test(line): use explicit token placeholders

* refactor(line): keep reservation type private

* refactor(line): render reservations through history facade

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-15 21:27:23 -07:00
..
2026-06-04 21:40:44 -04:00

OpenClaw LINE

Official OpenClaw channel plugin for LINE Bot API chats.

Install from OpenClaw:

openclaw plugin add @openclaw/line

Configure LINE channel credentials in OpenClaw, then connect the bot to the chats where agents should receive and send messages.