Skip to content

docs: clarify DefaultSessionFilter handling in documentation - #10143

Open
fudengming wants to merge 1 commit into
AstrBotDevs:masterfrom
fudengming:master
Open

fudengming wants to merge 1 commit into
AstrBotDevs:masterfrom
fudengming:master

Conversation

@fudengming

@fudengming fudengming commented Sep 19, 2026

Copy link
Copy Markdown

In #1326, the return value of DefaultSessionFilter changed from event.get_sender_id() to event.unified_msg_origin, while the documentation still says sender_id is returned.

Modifications / 改动点

Only documentation.

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

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/zhdocs/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.txtpyproject.toml 文件相应位置。

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

Summary by Sourcery

Clarify how default and custom session filters determine session boundaries.

Enhancements:

  • Clarify session identifier defaults and custom filtering behavior in the English and Chinese session-control guides.

Documentation:

  • Update session-control documentation to describe unified_msg_origin as the default identifier and explain per-user session filtering within groups and across chats.

In AstrBotDevs#1326, the return value of `DefaultSessionFilter` changed from `event.get_sender_id()` to `event.unified_msg_origin`, while the documentation still says `sender_id` is returned.

@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 2 issues

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

## Individual Comments

### Comment 1
<location path="docs/en/dev/star/guides/session-control.md" line_range="125" />
<code_context>
-        return (
-            event.get_group_id() if event.get_group_id() else event.unified_msg_origin
-        )
+        return f"{event.unified_msg_origin}:{event.get_sender_id()}"


</code_context>
<issue_to_address>
**issue:** The example combines `unified_msg_origin` with `get_sender_id()`, so the resulting key still contains the group/session identifier and users from different groups can never share one session. This contradicts the preceding description that the custom filter can combine users from different groups into a single session.

**Triggers:** When a developer follows this example to create a session shared by users in different groups.

**Suggested fix:** Use a grouping key that omits the group-specific portion, such as the sender ID for cross-group per-user sessions, or show an explicit shared key for the users that should be grouped.

```suggestion
        return event.get_sender_id()
```
</issue_to_address>

### Comment 2
<location path="docs/zh/dev/star/guides/session-control.md" line_range="102" />
<code_context>
 ## 自定义会话 ID 算子

-默认情况下,AstrBot 会话控制器会将基于 `sender_id` (发送人的 ID)作为识别不同会话的标识,如果想将一整个群作为一个会话,则需要自定义会话 ID 算子。
+默认情况下,AstrBot 会话控制器会将基于 `unified_msg_origin` (会话 ID)作为识别不同会话的标识,如果只想将一个群的一个或一些用户又或不同群的不同用户作为一个会话,则需要自定义会话 ID 算子。

 ```py
</code_context>
<issue_to_address>
**issue:** The parallel documentation page `docs/zh/dev/star/plugin.md` still states that the default filter returns `sender_id` and shows the old group-wide filter, so Chinese users consulting that page continue to receive the behavior that this change is intended to correct.

**Triggers:** When users read the session-control material in `docs/zh/dev/star/plugin.md` instead of the updated guide.

**Suggested fix:** Update the duplicated session-filter section in `docs/zh/dev/star/plugin.md` to match the new default and custom-filter behavior, or replace it with a link to the canonical guide.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: docs/en/dev/star/guides/session-control.md:125, docs/zh/dev/star/guides/session-control.md:102


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

return (
event.get_group_id() if event.get_group_id() else event.unified_msg_origin
)
return f"{event.unified_msg_origin}:{event.get_sender_id()}"

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.

issue: The example combines unified_msg_origin with get_sender_id(), so the resulting key still contains the group/session identifier and users from different groups can never share one session. This contradicts the preceding description that the custom filter can combine users from different groups into a single session.

Triggers: When a developer follows this example to create a session shared by users in different groups.

Suggested fix: Use a grouping key that omits the group-specific portion, such as the sender ID for cross-group per-user sessions, or show an explicit shared key for the users that should be grouped.

Suggested change
return f"{event.unified_msg_origin}:{event.get_sender_id()}"
return event.get_sender_id()

## 自定义会话 ID 算子

默认情况下,AstrBot 会话控制器会将基于 `sender_id` (发送人的 ID)作为识别不同会话的标识,如果想将一整个群作为一个会话,则需要自定义会话 ID 算子。
默认情况下,AstrBot 会话控制器会将基于 `unified_msg_origin` (会话 ID)作为识别不同会话的标识,如果只想将一个群的一个或一些用户又或不同群的不同用户作为一个会话,则需要自定义会话 ID 算子。

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.

issue: The parallel documentation page docs/zh/dev/star/plugin.md still states that the default filter returns sender_id and shows the old group-wide filter, so Chinese users consulting that page continue to receive the behavior that this change is intended to correct.

Triggers: When users read the session-control material in docs/zh/dev/star/plugin.md instead of the updated guide.

Suggested fix: Update the duplicated session-filter section in docs/zh/dev/star/plugin.md to match the new default and custom-filter behavior, or replace it with a link to the canonical guide.

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