fix: stop passing toolFilter for structured-output subagents (fixes #14) - #17
Open
cyhano wants to merge 1 commit into
Open
fix: stop passing toolFilter for structured-output subagents (fixes #14)#17cyhano wants to merge 1 commit into
cyhano wants to merge 1 commit into
Conversation
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
Fixes #14 (
mnemon_recall/mnemon_remember/mnemon_related/mnemon_forget… 报memory subagent stopped with error)。Root cause
MnemonSubagentCoordinator.delegate()启动结构化输出(structured-output)子代理时,同时传了toolFilter: { allow: tools }和outputSchema。DSH 的
dsh-subagent-in-process-driver在startInProcessRun的setup里按以下顺序执行:applyChildComposition(childCtx, parent, { toolFilter })→tools.restrict({ allow: [...] })attachStructuredRuntime(childCtx, outputSchema)→ 往 child 的 own 工具层注册structured_output工具。structured_output是 child 自己层注册的工具,不在restrict的 allow 白名单里(allow 只匹配 child 的 inherited = global + ancestor 工具)。在 DSH 0.1.0-rc.6 下,子代理完成推理后拿不到structured_output的捕获结果,于是readResult里这段逻辑把stopReason强制置为"error":最终 dsh-mnemon 收到
stopReason: "error",抛出memory subagent stopped with error。Fix
当这些判断子代理需要结构化输出(本函数所有调用点都传了
outputSchema)时,不再传toolFilter,让 DSH 的结构化输出机制保持可达。工具隔离改由两层既有机制承担:
SUBAGENT_DELEGATION_CONTEXT)ANSWER_PERSONA/WRITE_PERSONA明确「不调用工具、不再委托」)Verification
pnpm run typecheck(tsc -p tsconfig.json --noEmit)通过。tsdown打包成功(lib/index.js254KB),产物中toolFilter: { allow已无残留。dsh --profile web --port 3081)上实测:standard preset 会话调用mnemon_recall(query="dsh 重启", limit=3)成功返回 3 条来自「dsh 运维与踩坑记录」空间(5b5eb1a4)的 insight(含 score/confidence/importance/entity 匹配),不再报memory subagent stopped with error。Notes
这是一个治标修复:它让 dsh-mnemon 在 DSH 0.1.0-rc.6 下恢复可用,但代价是判断子代理失去了
toolFilter的硬工具白名单(改由 delegation scope + persona 软约束)。治本修复应在 DSH 核心侧:dsh-subagent/dsh-subagent-in-process-driver的tools.restrict()应豁免「child 自己层注册的 structured-output 机器工具」(其注释已声明这一意图:That exemption is what a per-child capability filter has to keep intact,但当前实现未兑现)。若上游 DSH 修复了 restrict 豁免,可再恢复toolFilter。关联:closes #14