Skip to content

feat(discovery): add opt-in scoped working contexts - #59

Merged
sunrioa merged 2 commits into
mainfrom
codex/feat-discovery-context
Nov 3, 2026
Merged

sunrioa merged 2 commits into
mainfrom
codex/feat-discovery-context

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Long-lived discovery workers can carry unrelated investigations and large notebook reads into later wakes. This adds an opt-in scoped context mode to test whether fresh working contexts and on-demand knowledge reads reduce that carryover.

  • Exploration and judgement start fresh Sessions after each successful cycle. Quick discovery inherits the configured mode on its next wake. Failed/interrupted cycles retain their original context, draft and delivery identities. Pre-upgrade quick pending work finishes on its legacy worker before the next wake adopts scoped mode.
  • Scoped workers read a bounded topic directory and pending feedback first. DiscoveryNotebook provides paginated topic evidence, feedback rules, handoffs, confirmed deliveries and original events. Resolved feedback prose stays available by ID.
  • Scoped DiscoveryContext returns recent conversation pages and a compact task directory; a task ID retrieves its full details. Continuation cursors and per-view content tokens keep oversized sources recoverable, including when time-derived topic state changes at a deferral deadline.
  • Durable worker roles preserve existing tool restrictions after rotation/restart. The feedback import also includes the owner's quote comments, excludes quoted source text, skips empty replies and preserves already imported feedback.

The existing two-stage flow, broad discovery scope, scheduling, task admission and provider retry policy are retained. Background Sessions use the existing model/permission inheritance rules.

Context: discovery discussion in apache/maka#6504.

Try the experiment

Default mode remains legacy. In the assistant conversation, explicitly request:

{"contextMode":"scoped"}

through InitiativeConfigure. This preserves the saved interval and enabled/paused state. Use {"contextMode":"legacy"} to return to long-lived contexts after any pending broad cycle settles. A pending quick wake keeps its pinned mode until it finishes.

Initial notebook material is capped at 6,000 catalog characters plus 3,000 feedback characters. Read tools default to 8,000 characters and allow up to 12,000 per page, with a 6,000-byte serialized-text cap to retain cursors below Runtime's archival threshold. Knowledge and old worker transcripts are retained; there is no automatic transcript deletion.

Verification

  • npm run build, npm run typecheck, lint, formatting and stale-dist checks passed.
  • Runtime Host suite: 3,095 passed / 0 failed / 13 platform skips with --test-concurrency=2.
  • Final native assistant integration tests: 112 passed / 0 failed.
  • Assistant suites: 293 passed / 0 failed, including 30 controlled scoped cycles, notebook/feedback continuity, pagination and original recovery, restart/failure recovery (including pre-upgrade pending operations), deadline-crossing pagination, exactly-once delivery, mode rollback and replaced/foreign worker rejection.
  • Windows inventory, ASF source/staged headers, protocol epoch guard and staged whitespace checks passed.

The first unrestricted-concurrency Host run timed out in the existing WorkHub steering/handoff case. It passed individually and in the complete lower-concurrency rerun without a source change to that path.

These tests use controlled models/local fixtures. They verify context and recovery plumbing; reduced attention drift, useful-discovery coverage and actual token/cache/cost effects remain to be measured with real models. No paid provider replay, private-history upload or Windows runtime/package test was performed for this PR.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

OpenAI Codex authored the implementation, regression tests and description. The implementation and review evidence are provided for the repository owner's merge decision.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
简体中文

长期复用的主动发现会话可能把无关调查和大量历史材料带入后续轮次。本 PR 增加默认关闭的 scoped 实验模式,用新工作上下文和按需读取来检验能否减少这种影响。

  • 每个成功周期结束后,下一轮探索和判断使用新的 Session;快速发现也在下一次唤醒时继承该模式。失败、修复和重启恢复继续使用原轮次身份,不重复创建调查或投递结果;旧版遗留的未完成快速发现轮次先在原 legacy Session 完成,下一轮才采用新模式。
  • 初始材料为有大小上限的主题目录和待处理反馈;主题证据、反馈规则、交给 Bot 的记录、真实送达及原始事件可以分页读取。已处理反馈的正文保留为按需回查的原文。
  • 实际对话从最近一页开始读取,更早消息可继续翻页。默认任务材料采用简短目录,指定任务 ID 才读取详情;超长来源可完整分页取回,并通过实际视图内容的版本 token 检查读取期间是否发生变化,包括跨过暂缓截止时间的状态变化。
  • 保留旧 Worker 的角色限制。同步修复引用评论反馈的导入:只采用用户正文和评论,不把引用原文当作用户要求,不导入空反馈,也不重写已经保存的旧反馈。

现有两阶段流程、广泛探索范围、周期配置、任务准入、权限继承和重试策略保持原有规则。

默认仍为 legacy。在助手对话中明确要求通过 InitiativeConfigure 设置 {"contextMode":"scoped"} 后启用;周期和启停状态不变。待当前未完成的广泛发现周期处理完毕后,可改回 {"contextMode":"legacy"}。快速发现已开始的轮次会保持原模式直到完成。

初始目录最多 6,000 字符,反馈最多 3,000 字符;分页读取默认 8,000 字符、单页最多 12,000 字符,同时把序列化正文限制在 6,000 字节内,为游标等元数据预留空间,避免被运行时再次归档。长期知识和旧执行记录保留,不自动删除。

验证结果:构建、全仓库类型检查、lint、格式和旧构建检查通过;完整 Runtime Host 回归 3,095 通过、0 失败、13 项平台跳过;最终原生助手集成测试 112 项通过,三套助手回归合计 293 项通过,覆盖 30 轮上下文隔离、反馈和送达连续性、分页与原文取回、旧版 pending 的失败和重启恢复、跨暂缓截止时间的分页、幂等投递、切回旧模式及身份隔离。Windows inventory、许可证头、协议检查和暂存差异检查通过。

首次高并发 Host 测试中,既有 WorkHub steering/handoff 用例超时;未修改该路径源码,单独复跑和降低并发后的完整回归均通过。

这些验证采用受控模型和本地夹具。注意力发散、有效发现覆盖和真实 token/缓存/成本效果,仍需后续真实模型对照实验;本 PR 未运行付费模型复跑、上传私人历史或执行 Windows 运行时/打包验证。

实现、测试和本文由 OpenAI Codex 协助完成,提交实现和审查证据供仓库所有者决定合并。

Separate per-cycle working history from durable discovery knowledge. Add bounded on-demand reads, preserve feedback and recovery identities, and retain legacy mode for comparison.

Generated-by: OpenAI Codex
Recover pre-upgrade quick pending work on its original legacy worker before adopting scoped mode. Bind notebook continuation tokens to the actual view so deadline changes reject stale offsets instead of dropping source text.

Generated-by: OpenAI Codex
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