feat(openclaw-plugin): thread senderId + userMode through turn recording#1529
Open
yeyitech wants to merge 1 commit intovolcengine:mainfrom
Open
feat(openclaw-plugin): thread senderId + userMode through turn recording#1529yeyitech wants to merge 1 commit intovolcengine:mainfrom
yeyitech wants to merge 1 commit intovolcengine:mainfrom
Conversation
Add an extractSenderId helper that normalises runtimeContext.senderId
(trim, reject non-strings / empty values) and a userMode config field
("single-user" | "multi-user", default "single-user").
When userMode is "multi-user" and senderId is present, the plugin now
forwards it as role_id on the recorded user turn so multi-participant
conversations can be attributed back to the correct speaker. Single-user
mode preserves existing behavior.
Note: OpenViking server-side ingestion of role_id is not yet wired up
(AddMessageRequest currently drops unknown fields); plugin-side forwarding
lands first so the multi-user story can be completed end-to-end under
the follow-up tracked in volcengine#1351.
Refs volcengine#1479
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lay down the plugin-side groundwork for multi-user OpenClaw conversations. Adds a
userModeconfig ("single-user"default,"multi-user") and a robustextractSenderIdhelper that pulls a normalised speaker id out ofruntimeContext. WhenuserMode === "multi-user"and asenderIdis present, the plugin records the turn with arole_idso per-speaker attribution becomes possible.Single-user mode is unchanged.
Changes
context-engine.tsextractSenderId(runtimeContext)helper — trims, rejects non-string / empty / whitespace-only values, returns{ found, senderId }.afterTurncomputesroleId = cfg.userMode === "multi-user" && sender.found ? sender.senderId : undefinedand passes it through toclient.addSessionMessage.assembleemits a diagnostic log when asenderIdis observed (no behavior change).client.ts—addSessionMessagegains a 7throleId?: stringparameter and emitsrole_idin the request body when non-empty.config.ts— new optionaluserMode: "single-user" | "multi-user"field with zod schema entry, allowlist registration, default, and UI description.__tests__/sender-id.test.ts— 9 unit tests: 6 forextractSenderId(happy path, whitespace trim, missing context, absent key, empty/whitespace string, non-string values) + 3 foruserModeschema (accepts both modes, defaults to single-user, rejects unknown values). All 9 pass.Server-side note (intentional scope split)
The OpenViking server's
AddMessageRequest(openviking/server/routers/sessions.py) does not currently declare arole_idfield, so Pydantic's defaultextra="ignore"silently drops it. This PR only lands the plugin-side forwarding so the multi-user story can be built up incrementally; server-side ingestion ofrole_idis the natural next step and fits under the broader multi-user tracking in #1351.Shipping plugin-side first is safe: the field is only sent when the operator explicitly opts into
userMode: "multi-user"and supplies asenderId, and the server tolerates the extra field today.Test plan
npm test -- --run sender-idinexamples/openclaw-plugin/— 9/9 pass.mainwere verified to be unrelated).role_idinto the server'sAddMessageRequest+ persistence layer.Refs #1479