缺陷 / 严重 / Agent 引擎
electron/harness/agent-loop/engine.ts (DEFAULT_CONFIG.contextWindow = 128_000)
electron/harness/agent-loop/engine.ts
Engine 的 DEFAULT_CONFIG.contextWindow 硬编码为 128_000,而各 Provider 实际支持的上下文窗口差异巨大:
DEFAULT_CONFIG.contextWindow
Engine 在初始化和 runStream 时从未调用 adapter.getContextWindow() 同步该值,导致:
adapter.getContextWindow()
compressionThreshold * contextWindow
这违反了 project_memory.md 中的硬性约束:
Engine context window must be synchronized with the LLM adapter's configured context window value
在 runStream 开始处同步:
runStream
private async executeRunStream(...) { // ... // 同步 adapter 的 contextWindow 到 Engine 配置 const adapterCtx = this.adapter.getContextWindow?.(); if (adapterCtx && adapterCtx > 0) { this.config.contextWindow = adapterCtx; } // ... }
同时在 setAdapter 热切换时也要同步。
setAdapter
文件: electron/harness/agent-loop/engine.ts
问题: Engine 的 DEFAULT_CONFIG.contextWindow 硬编码为 128_000,从未调用 adapter.getContextWindow() 同步,导致各 Provider(DeepSeek 64K / Agnes 1M / Ollama 4096)的压缩阈值计算错误。
修复方案:
syncContextWindow()
this.config.contextWindow
setAdapter()
executeRunStream()
验证: tsc --noEmit 类型检查通过。
tsc --noEmit
No dependencies set.
The note is not visible to the blocked user.
问题类型
缺陷 / 严重 / Agent 引擎
文件位置
electron/harness/agent-loop/engine.ts(DEFAULT_CONFIG.contextWindow = 128_000)问题描述
Engine 的
DEFAULT_CONFIG.contextWindow硬编码为 128_000,而各 Provider 实际支持的上下文窗口差异巨大:Engine 在初始化和 runStream 时从未调用
adapter.getContextWindow()同步该值,导致:compressionThreshold * contextWindow) 计算错误这违反了 project_memory.md 中的硬性约束:
建议修复
在
runStream开始处同步:同时在
setAdapter热切换时也要同步。修复说明
文件:
electron/harness/agent-loop/engine.ts问题: Engine 的
DEFAULT_CONFIG.contextWindow硬编码为 128_000,从未调用adapter.getContextWindow()同步,导致各 Provider(DeepSeek 64K / Agnes 1M / Ollama 4096)的压缩阈值计算错误。修复方案:
syncContextWindow()私有方法:从adapter.getContextWindow()读取并同步到this.config.contextWindowsetAdapter()热切换 adapter 时调用同步executeRunStream()开始处也调用同步(确保每次 run 基于当前 adapter 的上下文窗口)验证:
tsc --noEmit类型检查通过。