feat(harness): background drain ingestion, auto-context snapshot cache, and configurable reasoning-effort policy - #28
Open
LiuStar656 wants to merge 3 commits into
Conversation
Turns are folded on the hot path then only counted and queued; the actual LLM memory work (appendTurn + auto-context rendering) runs on an unref'd timer with per-session serialization, count-triggered eager draining and exponential backoff. The system-prompt/assemble hook reads a synchronous snapshot cache refreshed by the drain instead of doing flush + retrieval inline, so hot-path assembly never blocks on StrataGate memory work. Empty or stale snapshots are skipped or carry an explicit staleness marker. Also adapts the plugin and runtime tests: assemble skips the memory context until the background drain has rendered a snapshot, and tests wait for the eager drain rather than an inline flush.
When the provider does not advertise off, force-off now falls back to the model default and warns once, instead of raising a desktop notification and failing the structured call. The effort field is optional in the resolved config (default 'auto') so existing plugin configs and tests stay valid.
Wires @deepseek-ai/dsh-settings: the effort policy (auto | force-off) is a user-editable switch on the plugin settings page, bound through the client settings section (register.inject carries hooks/setEffort/resetEffort) and mirrored into the model bridge on every change, so the current mode is read per structured call. Adds the dsh-settings peer/dev dependency and updates the lockfile; CHANGELOG gains the Unreleased entries for all three changes.
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.
feat(harness): background drain ingestion, auto-context snapshot cache, and configurable reasoning-effort policy
Problem
The DeepSeek Harness integration ingests memory synchronously: every completed
agent turn immediately runs StrataGate's LLM memory work (appendTurn, block
sealing, activated-memory retrieval) inline on the hot path, so conversation
assembly blocks on memory processing. The structured-call reasoning-effort
policy is also not user-configurable:
force-offraises a desktopnotification and fails the structured call on providers that do not advertise
off.Solution
Three commits, one concern each:
da9ea51— Background drain + snapshot cache (src/runtime.ts, src/index.ts, tests).Turns are folded on the hot path then only counted and queued; the actual
LLM memory work runs on an
unref()'d timer with per-sessionserialization, count-triggered eager draining (≥3 queued turns → 150 ms),
and exponential backoff on failure. The
system-prompt/assemblehook readsa synchronous snapshot cache refreshed by the drain instead of doing
flush + retrieval inline; an empty or stale snapshot is skipped, or carries
an explicit staleness marker.
flush()stays the explicit synchronouspoint; a public
refreshAutoContext(session)provides a deterministicrefresh for tests and admin flows.
08600b8— Effort degrade instead of failure (src/llm.ts, src/config.ts, tests).When the provider does not advertise
off,force-offnow falls back tothe model default with a single warning instead of failing the structured
call. The resolved config field is optional (default
auto), so existingplugin configs and tests stay valid.
a31d7c6— Effort policy setting (src/client.js, src/index.ts, package.json, CHANGELOG).New
@deepseek-ai/dsh-settingswiring: the effort policy (auto | force-off) is a user-editable switch on the plugin's settings page, boundthrough the client
settings.sectionregistration(
register.injectcarrieshooks/setEffort/resetEffort) and mirrored intothe model bridge on every change, so the current mode is read per structured
call. Adds the peer/dev dependency and lockfile update; CHANGELOG gains the
Unreleased entries.
Acceptance
npm run check --workspace stratagate-dsh— zero type errors.npm run test --workspace stratagate-dsh— 59/59 passing (8 files),including new background-drain/snapshot-cache tests and the adapted
plugin-composition test (assemble skips the memory context until the drain
has rendered a snapshot).
flush()still forces queued turns; config defaultsunchanged; upstream
multibatchprotocol and turn-stopping are preserved.中文说明
问题
DeepSeek Harness 集成的记忆摄取是同步的:每次回合结束都立即在热路径上运行
StrataGate 的 LLM 记忆处理(appendTurn、封存、激活记忆检索),对话组装会被
记忆工作阻塞;推理档位策略也不可配置,
force-off在模型不支持off时会发桌面通知并使结构化调用失败。
方案(三个 commit,各管一事)
da9ea51后台计数驱动摄取 + 快照缓存(src/runtime.ts、src/index.ts、测试)。回合在热路径只折叠入队并计数;真正的 LLM 记忆工作在
unref()定时器上执行,按会话串行,批量压力触发 eager drain(队列 ≥3 回合 → 150ms),失败指数退避。
system-prompt/assemble钩子改为读取后台 drain 渲染的同步快照缓存,空/过期快照直接跳过或带显式过时标记,热路径永不阻塞。
flush()仍是显式同步点;新增公开
refreshAutoContext(session)供测试与管理流程确定性刷新。08600b8降级代替失败(src/llm.ts、src/config.ts、测试)。提供方不支持
off时,force-off退回模型默认档位并告警一次,不再失败。resolved 配置字段改为可选(默认
auto),现有插件配置与测试无需改动。a31d7c6档位设置化(src/client.js、src/index.ts、package.json、CHANGELOG)。新接入
@deepseek-ai/dsh-settings:档位策略(auto | force-off)成为插件设置页的用户可编辑开关,经客户端
settings.section注册(
register.inject携带hooks/setEffort/resetEffort)注入记忆 UI,改动即时镜像到模型桥,每次结构化调用按当前档位执行。新增 peer/dev 依赖与 lockfile
更新;CHANGELOG 补充 Unreleased 条目。
验收
npm run check --workspace stratagate-dsh:零类型错误。npm run test --workspace stratagate-dsh:59/59 通过(8 个文件),含新增的后台 drain/快照缓存测试与适配后的插件组装测试
(assemble 在 drain 渲染出快照前跳过记忆上下文)。
flush()仍强制消费积压回合;配置默认值不变;保留上游 multibatch 协议与 turn-stopping 行为。