Skip to content

docs: document isolated session impact on session_id and unified_msg_origin - #10538

Open
lingyun14beta wants to merge 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/docs-isolated-session-umo
Open

lingyun14beta wants to merge 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/docs-isolated-session-umo

Conversation

@lingyun14beta

@lingyun14beta lingyun14beta commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Enabling Isolate Conversation (platform_settings.unique_session) rewrites the
session_id of group messages to a platform-specific composite ID, so
unified_msg_origin changes with it. Plugins that store or query data per group
by either value address a different session once the setting is toggled, and the
current docs never mention this.

Continues #7947, which was closed by the stale-PR cleanup, rebased on current
master.

Modifications / 改动点

  • Warn about the rewrite in the message event guide, with the concrete before and
    after example and the event.get_group_id() recommendation (zh/en)
  • Correct the AstrBotMessage.session_id comment: it holds the raw adapter value;
    only the event's session_id copy is rewritten
  • State the mechanism in the platform_settings.unique_session reference page,
    which previously described only the conversational consequence (zh/en)
  • Note the consequence where a stored unified_msg_origin is used as a
    conversation or history key (send-message, ai; zh/en)
  • Mention that the composite separator is platform-specific (Lark uses %, not _)

9 files changed, 30 insertions(+), 3 deletions(-)

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。

  • 📚 I checked the affected WebUI instructions and screenshots in docs/zh and docs/en against the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog.
    / 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新 docs/zh 和 docs/en 的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Document the identifier changes and plugin considerations introduced by enabling isolated conversations.

Enhancements:

  • Document how Isolate Conversation rewrites group-message session identifiers and unified message origins on supported platforms.
  • Clarify the distinction between raw message session IDs and rewritten event session IDs, and recommend using event.get_group_id() for group-based storage and lookups.
  • Document platform-specific identifier formats and warn about stability and targeting implications when storing unified_msg_origin.

Documentation:

  • Update English and Chinese configuration, message-event, plugin, AI, and send-message documentation with isolated-session identifier behavior and usage guidance.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/en/dev/astrbot-config.md" line_range="166" />
<code_context>

 Whether to enable **Isolate Conversation**. Defaults to `false`. On supported platforms, each group member has a separate conversation context when enabled. Unsupported platforms retain their existing context. Access to `/new` and `/reset` is controlled by [command permissions](../use/command.md), which follow conversation isolation by default.

+The setting also rewrites the session identifier of group messages: `session_id` becomes a platform-specific composite ID (on QQ, `sender ID_group ID`), and `unified_msg_origin` changes along with it. Plugins that store or query data per group should use `event.get_group_id()` to get the raw group ID; see [Handling Message Events](./star/guides/listen-message-event).
+
 #### `platform_settings.rate_limit`
</code_context>
<issue_to_address>
**DingTalk IDs lack group**

When a plugin relies on the documented composite ID format for a DingTalk group message, dingTalk’s unique-session builder sets `session_id` to `event.get_sender_id()` only, so the ID has no group component; a plugin expecting the documented sender-and-group format parses or uses the wrong per-group key.

Document that DingTalk’s builder returns only the sender ID, and avoid promising a composite ID format for every supported platform.

Also at `docs/zh/dev/astrbot-config.md:166`, `docs/en/dev/star/guides/listen-message-event.md:46-47`, `docs/zh/dev/star/guides/listen-message-event.md:46-47`.
</issue_to_address>

### Comment 2
<location path="docs/en/dev/star/guides/send-message.md" line_range="42" />
<code_context>
 )
 ```

+> [!WARNING]
+> The example above uses `unified_msg_origin` as the conversation history storage key. When **Isolate Conversation** (`platform_settings.unique_session`) is enabled, the `unified_msg_origin` of group messages changes, so the same group resolves to a different conversation depending on the setting. Use `event.get_group_id()` when you need to target a group; see [Handling Message Events](./listen-message-event).
+
</code_context>
<issue_to_address>
**Group ID breaks message sending**

When a plugin passes `event.get_group_id()` directly to `Context.send_message` as the send target, `Context.send_message` passes the raw group ID to `MessageSesion.from_str`, which raises `ValueError` because the ID is not a `unified_msg_origin` or `MessageSession`; the message is not sent.

Clarify that `event.get_group_id()` is for group identification, not a `Context.send_message` target; use a `unified_msg_origin` or `MessageSession` to send.

Also at `docs/zh/dev/star/guides/send-message.md:42-43`, `docs/en/dev/star/guides/send-message.md:43`.
</issue_to_address>

### Comment 3
<location path="docs/en/dev/astrbot-config.md" line_range="166" />
<code_context>

 Whether to enable **Isolate Conversation**. Defaults to `false`. On supported platforms, each group member has a separate conversation context when enabled. Unsupported platforms retain their existing context. Access to `/new` and `/reset` is controlled by [command permissions](../use/command.md), which follow conversation isolation by default.

+The setting also rewrites the session identifier of group messages: `session_id` becomes a platform-specific composite ID (on QQ, `sender ID_group ID`), and `unified_msg_origin` changes along with it. Plugins that store or query data per group should use `event.get_group_id()` to get the raw group ID; see [Handling Message Events](./star/guides/listen-message-event).
+
 #### `platform_settings.rate_limit`
</code_context>
<issue_to_address>
**Session IDs stay unchanged**

When isolate Conversation is enabled on a platform without a registered unique-session builder, `build_unique_session_id` returns `None`, so `WakingCheckStage.process` leaves `event.session_id` unchanged and `unified_msg_origin` does not change; plugin authors expecting a changed key are misled.

Qualify the notices to say that session IDs change only on platforms with a unique-session builder.

Also at `docs/zh/dev/astrbot-config.md:166`, `docs/en/dev/star/guides/listen-message-event.md:46-47`, `docs/zh/dev/star/guides/listen-message-event.md:46-47`, `docs/en/dev/star/guides/ai.md:377`, `docs/zh/dev/star/guides/ai.md:375`, `docs/en/dev/star/guides/send-message.md:43`, `docs/zh/dev/star/guides/send-message.md:43`, `docs/zh/dev/star/plugin.md:134-135`.
</issue_to_address>

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: docs/en/dev/astrbot-config.md:166, docs/en/dev/star/guides/send-message.md:42, docs/en/dev/astrbot-config.md:166


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/en/dev/astrbot-config.md Outdated
Comment thread docs/en/dev/star/guides/send-message.md
Comment thread docs/en/dev/astrbot-config.md Outdated
…origin

When `platform_settings.unique_session` (Isolate Conversation) is enabled,
group messages get a platform-specific composite `session_id`, so
`unified_msg_origin` changes with it. Plugins that key per-group data on
either value silently address a different session once the setting flips.

- Warn about the rewrite in the message event guide and recommend
  `event.get_group_id()` for per-group storage (zh/en)
- Correct the `AstrBotMessage.session_id` comment: it holds the raw adapter
  value, only the event's copy is rewritten
- State the mechanism in the `platform_settings.unique_session` reference
  and point to the guide (zh/en)
- Note the consequence where a stored `unified_msg_origin` is used as a
  conversation or history key (send-message, ai; zh/en)
- List the per-platform formats and note that DingTalk returns the sender ID
  alone, and that unsupported platforms keep their `session_id` unchanged
- Clarify that `event.get_group_id()` is for identification only and is not
  a valid `Context.send_message` target
@lingyun14beta
lingyun14beta force-pushed the fix/docs-isolated-session-umo branch from e22b2be to db34146 Compare October 12, 2026 15:26

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant