Skip to content

tracking(assistant): migrate discovery and optimize the Rust Bot #6716

Open

Description

@sunrioa

Problem

Target: rust-preview. Initial source baseline: ee7e90605, inspected on 2026-11-09.

The personal-assistant architecture is discussed in #6504, and #6413 inventories capabilities for the Rust transition. The TypeScript experiments in Draft #6633 combine periodic discovery, event intake, shared discovery memory and investigation scheduling; #6510 supplies the source-change intake reference. Both PRs currently target main and are unmerged.

This issue tracks the concrete Rust follow-up: bring useful discovery behavior into the Rust runtime and reduce unnecessary Bot coordination work. Sustained TypeScript use exposed high model consumption, repeated context reconstruction and repeated investigation. Those observations motivate evaluation; they are not Rust performance measurements.

The current Rust Bot already has much of the required foundation. The remaining work needs an implementation checklist and common acceptance criteria rather than another independent orchestration system.

Desired outcome

Users can interact through the Bot while ordinary worker Sessions investigate and execute tasks. Periodic broad discovery and event-triggered investigation cooperate, retain useful knowledge and feedback, and report results through the same Bot path. Coordination stays responsive and affordable without reducing useful discovery merely by doing less work.

This is a proposed delivery tracker, not an approved roadmap. Each item should link its implementation PR and verification results here; evaluate experimental choices before selecting defaults.

Existing foundations to reuse

A. Discovery migration

  • A1 — Inputs and admission. Bring periodic broad discovery and enabled source-change intake into one admission path. Reuse Rust's scheduler, queue and execution ownership. Start from the experimental single-investigation-slot behavior, with pending events merged while an investigation runs. Preserve source authorization, enable/disable controls, event cursors, cooldowns and restart recovery; registering a source must not grant permission to read it.
  • A2 — Investigation context and shared records. Support fresh investigation Sessions with bounded continuation material. Retain findings, corrections, user feedback, research checkpoints and prior notification decisions with stable source references. Queries must preserve decision reasons and offer continuation when more material exists. Keep the records needed to resume work without copying all previous investigation history into every request.
  • A3 — Settlement, feedback and delivery. Persist investigation outcomes and result identity before acknowledging consumption. Reuse existing lifecycle and cancellation mechanisms, deduplicate recovery, and prevent superseded work from publishing stale results. Connect user feedback to the original reported finding, including quoted replies, so previously dismissed or corrected findings can inform later investigations.
  • A4 — Evaluate the investigation shape. Compare a single investigating worker with the existing exploration-then-judgement experiment. Treat a second model stage as a choice to justify through quality and cost measurements. Coalesce continuous activity and coordinate periodic checks so the same changing task is not repeatedly investigated without a useful change.

The migration should preserve useful breadth and depth. A longer investigation can be worthwhile; repeated reconstruction and control-only model calls are the first reduction targets. Some repeated investigation is acceptable. Avoid adding a complex duplicate-prevention framework before measurements justify it.

B. Bot optimization

  • B1 — Explicit completion and final publication. Follow Bot: a Turn that answers in plain text without SendUser or sleep leaves the answer out of Chat #6711 for required tool choice where supported and an explicit fallback where unsupported. Follow Bot: allow a final reply and Turn completion in one model step #6715 for publishing a final reply and completing the Turn in one model step. Preserve intermediate sends, silent completion, durable outbox deduplication, and new-message/steering handling.
  • B2 — Notify the Bot when a worker needs input. The current completion watcher waits for an ended invocation; the UI exposes waiting workers, but this wake path does not notify the Bot of pending questions or approvals. Deliver each actionable interaction once, recheck whether it is still pending, and reuse SessionPendingInteractions, SessionInteraction and SessionRespond. Existing parent authority and human-only escalation rules remain authoritative.
  • B3 — Carry usable results with completion notifications. Include the exact worker/invocation identity, outcome, and an appropriately sized view of the worker's already-recorded final output, with a read reference for the rest. Avoid an extra summarizer merely to construct the notification. Preserve the distinction between a worker's claim and verified task completion.
  • B4 — Make history lookup cheaper to consume. Evaluate a compact first-pass result view, followed by on-demand context expansion through the existing Recall facilities. Retain complete source access, explicit result budgets and continuation; do not introduce silent truncation. Account for existing tool-result archiving when measuring the benefit.
  • B5 — Tune context management for the Bot's role. Reuse existing compaction and checkpoints. Evaluate lower Bot working-context thresholds and summaries that retain user constraints, unfinished tasks, exact worker IDs, pending decisions, prior notifications and recovery references. Compare total cost and follow-up correctness, including summary generation, changed cache reuse and additional retrieval.
  • B6 — Coalesce completion events and preserve routing identity. Evaluate handling several already-ready worker completions in one Bot Turn. Keep individual event identities and consumption records, and avoid delaying user input or actionable blockers to form a batch. Preserve the result-to-worker links in Chat and carry explicit quoted-result identity into follow-up routing; recheck worker ownership and permissions before dispatch.
  • B7 — Profile and narrow watcher work. Measure idle and active behavior with many retained workers. If warranted, replace repeated scans of unchanged watches with targeted checks, while retaining startup recovery and reconciliation. Measure local CPU/database work separately from model calls; polling itself is not an LLM request.

C. Validation and completion

  • Use the same seeded tasks and source events for before/after comparisons. Cover ordinary chat, concurrent completions, pending questions/approvals, related follow-ups after an unrelated task, long-history retrieval, and sustained source activity.
  • Cover interruption and recovery around event admission, result persistence, outbox publication and Turn completion. Confirm no input is lost or falsely consumed, retries do not duplicate publication, and paused/superseded investigations cannot publish stale results.
  • Report useful discoveries, missed seeded findings, repeated notifications/investigations, and follow-up routing errors together with model calls, cached/uncached input, output, estimated cost and latency. Build on test(assistant): evaluate discovery for missed discoveries as well as repeats #6360; distinguish estimates from provider invoices and missing usage from zero usage.
  • Record the tested Rust SHA, environment, enabled sources, model selection and permissions. Link implementation PRs and results to this checklist. Validate platforms as each slice lands; do not carry TypeScript test results over as proof of Rust behavior.

Suggested order: B1–B3 first; then a minimal A1–A3 discovery slice; measure A4/B4/B5; evaluate B6 and profile B7. Validation accompanies each slice.

Alternatives or workarounds

Draft #6633 remains a runnable experimental reference while Rust implementation is developed. Its observations and regression scenarios can be reused, but its controllers, databases and migration logic do not need to be copied wholesale.

The Rust Bot can already delegate work, read history and arrange approved scheduled tasks. Those capabilities are the implementation foundation, while native discovery coordination and the optimizations above remain work to evaluate and track.

Architecture discussion stays in #6504, the wider capability inventory stays in #6413, and existing issues such as #6711/#6715 retain their own implementation discussions. This tracker links those efforts rather than replacing them.

AI assistance: OpenAI Codex assisted with source inspection and drafting.

简体中文

问题

目标分支:rust-preview。最初核对的源码基线为 ee7e90605,检查时间为 2026-11-09。

#6504 讨论个人助手架构,#6413 整理 Rust 迁移所需的能力。基于 TypeScript 的 Draft #6633 已将定期发现、事件接入、共享发现记忆和调查调度整合为实验;#6510 提供来源变化事件接入的参考。目前这两个 PR 均面向 main,尚未合并。

本 issue 追踪后续的 Rust 实现:迁移有价值的主动发现行为,并减少 Bot 协调过程中不必要的开销。持续使用 TypeScript 实验版本时,观察到了模型消耗偏高、重复恢复上下文和重复调查等现象。这些观察是开展验证的依据,不是 Rust 的性能实测结果。

Rust Bot 已具备许多必要基础。剩余工作需要一份实施清单和共同验收标准,复用现有机制推进。

期望结果

用户通过 Bot 交流,普通 worker Session 承担调查和执行。定期广域发现与事件触发的调查能够协作,保留有用认识和反馈,并通过统一的 Bot 路径汇报结果。协调保持及时,长期消耗可以承受,同时不能仅靠少做调查来降低费用。

这是一份拟议的实施追踪,并非已经批准的路线图。各项工作应在此关联实现 PR 和验证结果;实验选项经过评估后再确定默认行为。

复用已有基础

A. 主动发现迁移

  • A1 — 输入与接纳。 将定期广域发现和已启用的来源变化事件纳入同一接纳路径,复用 Rust 的调度器、队列及执行所有权。以实验中的单调查位行为为起点,调查进行时合并待处理事件。保留来源授权、启停控制、事件游标、冷却和重启恢复;注册来源不等于获得读取权限。
  • A2 — 调查上下文与共享记录。 支持使用新的调查 Session,携带有界的接续材料。保留发现、修正、用户反馈、调查进度和此前通知决策,以及稳定的原始来源引用。查询应完整保留决策理由,有更多材料时提供继续读取方式。保留能够接续工作的信息,无需每次请求都复制全部历史调查。
  • A3 — 收尾、反馈与投递。 确认消费前先持久化调查结果及结果身份。复用现有生命周期和取消机制,恢复时去重,阻止已被取代的调查发布过期结果。将用户反馈关联到原始发现,包括引用回复,使此前被否定或修正的发现能够影响后续调查。
  • A4 — 评估调查流程。 对比单个调查 worker 与现有“探索后判断”实验。是否保留第二次模型判断,由质量和成本数据决定。合并持续活动,协调定期检查,避免同一项持续变化的任务在没有有用变化时被反复调查。

迁移应保留有价值的发现广度和调查深度。有价值的调查花更长时间是可以接受的,优先减少重复恢复上下文和仅用于控制流程的模型调用。允许一定程度的重复调查,先用数据判断收益,再决定是否需要更复杂的防重复机制。

B. Bot 优化

  • B1 — 显式结束与最终发送。 根据 Bot: a Turn that answers in plain text without SendUser or sleep leaves the answer out of Chat #6711,在支持的供应商上强制工具调用,并为不支持的情况定义明确处理方式。根据 Bot: allow a final reply and Turn completion in one model step #6715,实现一次模型步骤内发送最终回复并结束 Turn。保留中间消息、静默结束、持久 outbox 去重,以及新输入和 steering 的处理。
  • B2 — worker 需要输入时通知 Bot。 当前完成 watcher 等待执行结束;界面能显示等待中的 worker,但这条唤醒路径不会通知 Bot 处理待答问题或审批。每个需要处理的交互通知一次,处理前重新确认其仍待处理,复用 SessionPendingInteractions、SessionInteraction 和 SessionRespond。继续以现有父级权限及必须人类处理的规则为准。
  • B3 — 完成通知携带可用结果。 附带准确的 worker/执行身份、结束状态,以及适当大小的已记录最终输出,剩余内容通过引用继续读取。构造通知时避免额外调用一个摘要模型。保留“worker 声称完成”与“任务已验证完成”的区别。
  • B4 — 降低历史读取成本。 评估先返回简洁定位信息、再通过已有 Recall 能力按需展开上下文的方式。保留完整来源访问、显式结果预算和继续读取能力,不静默截断。评估收益时考虑已有的工具结果归档。
  • B5 — 按 Bot 职责调整上下文管理。 复用现有压缩和检查点。评估较低的 Bot 工作上下文阈值;摘要重点保留用户约束、未完成任务、准确的 worker ID、待决事项、已发送通知和恢复引用。比较总费用和追问正确率,同时计算摘要生成、缓存复用变化及额外检索。
  • B6 — 合并完成事件并保留路由身份。 评估在一个 Bot Turn 中处理多个已经就绪的 worker 完成事件。保留各事件身份和消费记录,不为凑批次而延迟用户输入或需要及时处理的阻塞。保留对话中结果到 worker 的链接,将明确引用的结果身份带入追问路由;派发前继续检查 worker 归属和权限。
  • B7 — 实测并缩小 watcher 检查范围。 测量保留大量 worker 时的空闲和活动行为。如数据证明有必要,将对未变化 watch 的重复扫描改成定向检查,同时保留启动恢复与对账。分别衡量本地 CPU/数据库工作和模型调用;轮询本身不是 LLM 请求。

C. 验证与完成条件

  • 使用相同的预设任务和来源事件做前后对照。覆盖普通聊天、多个任务同时完成、待答问题/审批、插入无关任务后的相关追问、长历史检索和持续来源活动。
  • 覆盖事件接纳、结果持久化、outbox 发布及 Turn 结束前后的中断恢复。确认输入不丢失、不被错误标记为已消费,重试不重复发送,已暂停或被取代的调查不能发布过期结果。
  • 同时报告有用发现、预设发现漏报、重复通知/调查和追问误投,以及模型调用数、缓存/非缓存输入、输出、估算费用和延迟。衔接 test(assistant): evaluate discovery for missed discoveries as well as repeats #6360 的评估,区分估算与实际账单,不能把缺失用量算作零消耗。
  • 记录测试的 Rust SHA、环境、已启用来源、模型选择和权限。将实现 PR 和结果关联到清单,各阶段按所涉及的平台验证;不能将 TypeScript 测试结果直接作为 Rust 行为的证明。

建议顺序:先做 B1–B3;随后完成 A1–A3 的最小发现链路;实测 A4/B4/B5;再评估 B6,并测量 B7 是否值得优化。各阶段都同步验证。

替代方案或临时做法

在 Rust 实现推进期间,Draft #6633 可继续作为可运行的实验参考。可以复用其观察结果和回归场景,控制器、数据库和迁移逻辑无需整体照搬。

Rust Bot 已经能够委派任务、读取历史,以及安排经过批准的定时任务。这些能力是实现基础;原生发现协调和上述优化仍需要逐项评估、实现和追踪。

架构讨论继续留在 #6504,更广的能力清单留在 #6413,#6711/#6715 等已有 issue 保留各自的实现讨论。本追踪将它们关联起来。

AI 使用说明:OpenAI Codex 协助检查源码和起草本 issue。

Activity

  1. sunrioa commented on Nov 12, 2026

    @sunrioa
    ContributorAuthor

    Progress update on the Rust discovery migration. Three PRs are open for review against rust-preview.

    The desktop controls are available in #6730. The presentation of investigation progress and results still needs refinement. The A4 comparison of discovery quality and cost is also pending.

    During longer local testing, some investigation sessions appeared to stall while waiting for tools. I’m checking the execution logs to distinguish slow tool calls from cases where the session fails to resume after the tool returns. The Grep and Glob observations so far are tracked in #6807.

    简体中文

    更新一下 Rust 主动发现的迁移进展。目前有三个面向 rust-preview 的 PR 开放审查。

    #6730 已经可以在桌面端管理主动发现,调查进度和结果的展示还有改进空间。A4 的发现质量和成本对照也还待验证。

    在较长时间的本地试用中,有些调查会话看起来卡在了等待工具返回的阶段。我正在核对执行日志,区分工具本身耗时过长和工具返回后会话未能继续执行的情况。目前观察到的 Grep 和 Glob 问题记录在 #6807。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttrackingTracking or umbrella issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions