Repository navigation
feat(discovery): add opt-in scoped working contexts - #59
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Long-lived discovery workers can carry unrelated investigations and large notebook reads into later wakes. This adds an opt-in
scopedcontext mode to test whether fresh working contexts and on-demand knowledge reads reduce that carryover.DiscoveryNotebookprovides paginated topic evidence, feedback rules, handoffs, confirmed deliveries and original events. Resolved feedback prose stays available by ID.DiscoveryContextreturns 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.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.--test-concurrency=2.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
OpenAI Codex authored the implementation, regression tests and description. The implementation and review evidence are provided for the repository owner's merge decision.
Checklist
Does this PR entail a change in behavior?
简体中文
长期复用的主动发现会话可能把无关调查和大量历史材料带入后续轮次。本 PR 增加默认关闭的
scoped实验模式,用新工作上下文和按需读取来检验能否减少这种影响。现有两阶段流程、广泛探索范围、周期配置、任务准入、权限继承和重试策略保持原有规则。
默认仍为
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 协助完成,提交实现和审查证据供仓库所有者决定合并。