Skip to content

fix(scheduler): 检查类定时任务默认复用同一会话 - #8270

Open
elfcv wants to merge 3 commits into
makecindy:mainfrom
elfcv:fix/schedule-check-reuse-session
Open

elfcv wants to merge 3 commits into
makecindy:mainfrom
elfcv:fix/schedule-check-reuse-session

Conversation

@elfcv

@elfcv elfcv commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

Agent 用 schedule_create 新建检查类定时任务(silentWhenIdle=true)时,原来默认每次触发都新建一个任务,没有变化的检查也会在侧栏刷出一串空对话。现在如果调用方既没绑定会话,也没设 persistentSession,工具层会把它补成持续会话,后续检查都复用同一个任务。

参考:DeepSeek Harness 的 Schedule 在创建时省略目标就默认 new_once(第一次投递时新建,之后一直复用),见其 docs/subsystems/schedule.zh.md「投递目标」一节。

变更类型

  • fix 缺陷修复

范围

UI 变化

不涉及。

  • 引用的设计规范:不涉及

怎么验证的

自动验证

cd packages/lizi-mcps && npx vitest run src/__tests__/cindy_schedulerMcpServer.test.ts
结果:73 passed(本文件约 0.8s)。把 create.ts 换回 main 的版本后,新增用例失败 1 条,另外 72 条通过。

cd packages/lizi-mcps && npx vitest run
结果:1256 passed,27 failed。失败全部在 botMemoryChain.test.ts、contactsTools.test.ts:better-sqlite3 原生模块未编译(本机安装用了 --ignore-scripts)。不改代码时在 main 上失败数相同(27 failed / 1255 passed)。

npx tsc --noEmit -p packages/lizi-mcps
结果:4 行报错,都是 cindy_schedulerMcpServer.test.ts 里的 InMemoryStorage 缺 hasUnfinishedRuns(cfb8f7d3f9 引入)。main 上一样,与本改动无关;该 package 没有 typecheck 脚本。

pnpm check:test-hygiene → PASS
pnpm check:dco → passed

测试价值(engineering-conventions §3.2):通过真实的 call_tool(schedule_create) 入口创建,读回持久化后的 persistentSession。最小失败输入是 { silentWhenIdle: true }。现有用例没有覆盖检查类的会话默认值;同时锁住显式 false、绑定任务和提醒类不受影响。用例并入已有文件,tier 为 unit。

手工验证

不涉及(没有启动 Desktop,也没有创建真实定时任务)。

未执行的验证

  • 没有在真机上观察侧栏是否只剩一条任务。
  • 没有跑 Desktop 的 scheduler-host 测试和整仓 pnpm test:unit:本 PR 只改工具层默认值,runner 走的是已有的 persistentSession 路径。

风险

风险分类

  • 其他:改了模型可见的工具说明(schedule_create 的 description)。

影响与回滚

  • 影响范围:只影响 Agent 经 cindy_scheduler.schedule_create 新建、且 silentWhenIdle=true、未绑定会话、未设 persistentSession 的任务。授权分类不变:未绑定的 agent 任务原本就算作启动独立 Agent。
  • 回滚 / 降级方式:revert 本提交即可;已建的任务保留各自已存的 persistentSession,用户可以在表单里改成「每次新建」。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名
  • 未提交凭证、令牌或授权文件
  • 已核对受影响的文档并同步
  • 已确认测试结果或说明未执行原因

schedule_create with silentWhenIdle=true and no binding used to start a
fresh task on every fire, filling the sidebar with empty no-change
conversations. When the caller leaves persistentSession unset and binds
no session, the tool layer now defaults it to true. Explicit false, bound
targets, reminders and script schedules are unchanged; engine and UI
defaults are unchanged.

Signed-off-by: elfcv <cnxpfcv@gmail.com>
@elfcv
elfcv requested a review from a team as a code owner October 31, 2026 19:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-31T20:38:59.458296Z
We couldn’t complete this review. Comment @codex review to try again.
3564888 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects a narrow path for creating scheduled Agent checks.

合并前应修复本机模型选择与新增持续会话默认值的冲突,避免有效的检查任务无法创建。

Findings

  1. P1 本机检查无法创建 ▶
Fix with agent prompt
### Issue 1
packages/lizi-mcps/src/scheduler/create.ts:228-234
调用方传入 `silentWhenIdle: true`、`modelAgentDeviceId: ''`,但省略 `persistentSession` 和 `modelAgentKind` 时,这里会自动开启持续会话。此前这种未绑定任务允许使用 `agentKind` 和本机模型;现在引擎却要求同时提供 `modelAgentKind` 和 `model`,即使已经提供 `model` 也会拒绝创建。

补默认值时需要同时处理这类本机模型选择,避免原本有效的请求报错,并添加对应的 MCP 回归用例。

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

本 PR 让 Agent 新建的未绑定检查默认复用同一会话,并同步工具说明、产品规则和 MCP 测试。

  • Silent, unbound Agent checks reuse one task by default.

Reviews (1) · Last reviewed commit: "fix(scheduler): reuse one conversation f..." · Reviewed by Greptile

elfcv added 2 commits November 1, 2026 03:08
…use-session

Signed-off-by: elfcv <cnxpfcv@gmail.com>

# Conflicts:
#	docs/product-rules/bot-routines.md
A persistent session with modelAgentDeviceId='' must also carry an
explicit Harness and model (engine validation). Do not default
persistentSession in that case, so such check requests keep working.

Signed-off-by: elfcv <cnxpfcv@gmail.com>
@MagicLizi

Copy link
Copy Markdown
Contributor

维护者确认请求:本 PR 修改规则文档 docs/product-rules/bot-routines.md,在「检查前置与静默输出」一节新增「检查类定时任务默认复用同一会话」的行为语义,属审查判据自身变更,需要维护者明确确认。请直接在 PR 上 Approve 确认;需要作者修改则 Request Changes 并写明要求。讨论 issue:#8273

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) labels Oct 31, 2026
@elfcv

elfcv commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants