mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
fix(scheduler): inject delivered output into receiver session with sliding window
Further refinements on top of #2795: - persist real session_id (notify_session_id) at task creation so group chats correctly map back to the user's actual conversation - mark scheduler turns with [SCHEDULED] (recognise legacy "Scheduled task" prefix too for backward-compatible pruning) - prune both DB and in-memory to scheduler_inject_max_per_session (default 3), only marker-tagged pairs are touched; regular user turns never deleted - send_message type gated by scheduler_inject_send_message (default false) — fixed reminder text rarely benefits follow-up Q&A Co-authored-by: huangrichao2020 <grdomai43881@gmail.com>
This commit is contained in:
@@ -38,3 +38,33 @@ description: 创建和管理定时任务
|
||||
<Frame>
|
||||
<img src="https://cdn.link-ai.tech/doc/20260202195402.png" width="800" />
|
||||
</Frame>
|
||||
|
||||
## 结果进入会话上下文
|
||||
|
||||
定时任务在隔离 session 中执行(内部规划与 tool 调用不污染用户会话),但**最终输出**会作为一对消息回写到接收者的真实会话,用户可以直接追问"刚才那条第二点展开说说"。
|
||||
|
||||
**默认策略**
|
||||
|
||||
- Agent 动态任务的输出进入上下文
|
||||
- 固定消息类任务默认不进入上下文(可通过配置打开)
|
||||
- 每个会话最多保留最近 **3 对** scheduler 消息,更早的自动清理;普通用户消息不受影响
|
||||
|
||||
**配置项**
|
||||
|
||||
| 配置项 | 默认值 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `scheduler_inject_to_session` | `true` | 总开关 |
|
||||
| `scheduler_inject_max_per_session` | `3` | 每会话保留 scheduler 消息对数上限 |
|
||||
| `scheduler_inject_send_message` | `false` | 是否同时注入固定消息类任务 |
|
||||
|
||||
```json
|
||||
{
|
||||
"scheduler_inject_to_session": true,
|
||||
"scheduler_inject_max_per_session": 3,
|
||||
"scheduler_inject_send_message": false
|
||||
}
|
||||
```
|
||||
|
||||
<Note>
|
||||
群聊场景(飞书 / 企微群机器人 / 钉钉等)下用户的真实 session_id 形如 `user_id:group_id`,与 receiver 不同。创建任务时会自动记录正确的 session_id;老的 `tasks.json` 缺该字段时回落到 receiver,行为与历史版本一致。
|
||||
</Note>
|
||||
|
||||
Reference in New Issue
Block a user