Skip to content

feat: batch background notifications - #9

Merged
tt-a1i merged 1 commit into
mainfrom
feat/batch-background-notifications
Aug 12, 2026
Merged

feat: batch background notifications#9
tt-a1i merged 1 commit into
mainfrom
feat/batch-background-notifications

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • batch /cron jobs due in one polling tick into one structured follow-up and one triggered model turn
  • coalesce idle background-terminal settlements in one fixed 200 ms window while preserving the existing quiet busy-backlog path
  • retain exactly-once consumption, atomic cron retry, immediate bg_watch, shutdown cleanup, and truthful multi-terminal rendering

Why

Near-simultaneous build, test, lint, and package completions could wake the model once per process while idle. Multiple cron jobs due in one tick likewise queued separate triggered turns. One bounded batch gives the model a complete decision set with less context fragmentation and fewer model turns.

Safety boundaries

  • the background window is fixed, not sliding, so delivery cannot be postponed indefinitely
  • bg_start reserves against running, pending, and concurrent starts so the retractable exactly-once backlog stays bounded without evicting identities
  • a busy race retains results for agent_settled and delivers them as nextTurn without forcing another response
  • timer cancellation uses an opaque token, making already-queued stale callbacks harmless
  • bg_status / bg_kill consumption and the id-keyed delivery map remain authoritative
  • bg_watch uses its existing independent immediate message path
  • cron delivery is atomic: if sendMessage throws, no due job advances
  • no scheduler persistence, model scheduling tool, child capability, or new parent wake mechanism

Test plan

  • TDD regressions for cron same-tick batching and atomic retry
  • TDD regressions for fixed idle window, busy race, stale timer/shutdown cleanup, and multi-result rendering
  • focused batching tests: 28/28
  • background-terminal and cron suites: 85/85
  • full Node suite: 605/605
  • Vitest suite: 29/29
  • Biome format and lint
  • TypeScript / Effect typecheck (existing unrelated Effect warnings only)
  • git diff --check
  • npm pack/install and packed Pi extension load: 121 files; tests excluded

Closes #8

@tt-a1i
tt-a1i merged commit 476eb1b into main Aug 12, 2026
4 checks passed
@tt-a1i
tt-a1i deleted the feat/batch-background-notifications branch August 12, 2026 14:16
agnitum2009 pushed a commit to agnitum2009/openpi that referenced this pull request Aug 13, 2026
Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
agnitum2009 pushed a commit to agnitum2009/openpi that referenced this pull request Aug 14, 2026
两条不相交历史(lazyload 开发库独立根)。分支 296 提交为演化主线,
内容取代 origin/main 的 PR openpi-dev#3/openpi-dev#5/openpi-dev#7/openpi-dev#9(Redis 可选依赖、Biome/Bun
对齐、任务对账、批量通知——分支已含演化版:shared/task-reconcile、
result-delivery、biome/bun 工具链)。

- 冲突与内容一律取分支侧;合并树 == 分支树(read-tree 落地后
  diff 为空校验通过;merge 自动解析曾引入 main 侧旧位置
  subagents/src/agent-types.ts 残留,已随精确落地清除——该模块
  在分支 c7017af DDD 收敛时迁至 shared/)
- 本地 main 未推送的 2 个提交(commit-task-sync v2 + obsidian KB)
  存档于 archive/local-main-unpushed;vault 内容按 d0e64d4 决策不并入
- 分支关键内容:工具载荷 40.6k→~36.0k tok(端到端 -10.5%)、加载组
  预设、B 方案第三方描述补丁、显示残留根治(model-info tok/s、
  session-liveness busy 闸门 + 子会话守卫)、总线漂移守卫、
  agent-types 诊断分级
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.

Batch near-simultaneous background and cron notifications

1 participant