DSH / Atlas
2026-11-17implementedfeature

Live subagent model-selection setting

实时读取的 subagent 模型选择设置

[User-authorized subagent model routes](2026-08-24-user-authorized-subagent-model-routes.md) snapshotted the Host allowlist into each fresh top-level Session as `subagent/model-selection-policy`. A user who enabled the setting, added a route, or revoked one in the middle of a Session saw no effect until a new Session started; restored Sessions kept whatever list their creation recorded. The setting's observable meani

English

Problem

User-authorized subagent model routes snapshotted the Host allowlist into each fresh top-level Session as subagent/model-selection-policy. A user who enabled the setting, added a route, or revoked one in the middle of a Session saw no effect until a new Session started; restored Sessions kept whatever list their creation recorded. The setting's observable meaning depended on when each Session was created, which the settings page could not explain.

Decision

SubagentModelSelectionConfig.allowedRoutes() reads the volatile enabled value at each call and returns undefined immediately when selection is disabled; otherwise it validates allowedModels and returns a detached route list. The subagent executor and list_subagent_models call it through ctx.get('subagentModelSelection') for explicit route selection by model-selectable tools and for every discovery call, so an edit applies to the next call in every running, restored, and child Session. When the service is absent or the setting is disabled, explicit selection permits only the current parent route, as before.

No Session event is appended and no projection is registered. The subagent/model-selection-policy declaration remains so released Session logs still validate, but no code reads it; a Session that recorded a policy follows the current setting. An enabled setting with an empty, malformed, or repeated route list fails each call that reads it with INVALID_MODEL_SELECTION_SETTINGS rather than rejecting Agent creation. Ordinary delegation and tools with model selection disabled do not read the list.

Alternatives considered

Keep the creation-time snapshot. Rejected because the user-visible setting is a standing authorization, and an edit that silently skips every open Session reads as a broken control. The earlier note's concern that an edit changes a running Session's capabilities is the requested behavior.

Record a new policy event whenever the setting changes. Rejected because it would append to every live Session on each settings save, still miss restored Sessions until they load, and leave two sources that could disagree. The allowlist is not model-visible input: the tool schemas are fixed, and only a list_subagent_models result or a delegation error reaches the model, and both are logged as tool results.

Honor a recorded policy when present and fall back to the setting. Rejected because an old Session would then ignore later edits, recreating the inconsistency for exactly the Sessions users resume most.

Consequences

  • Revoking a route takes effect at the next call, including for children of a running parent; a route that was allowed earlier in the transcript can now be rejected with MODEL_ROUTE_NOT_ALLOWED.
  • Replaying a Session no longer reproduces its authorization from the log alone; the tool results in the log still show what the model saw.
  • Agent creation no longer depends on the setting service, so an invalid setting cannot block Sessions without delegation tools.
  • Unit tests in packages/subagent/tool-subagent/tests/model-selection-settings.spec.ts pin live reads, mid-Session edits in parent and child Sessions, and that a recorded policy is ignored.

中文

Problem

用户授权的 subagent 模型路由把 Host 允许列表快照到每个新顶层 Session 的 subagent/model-selection-policy 中。用户在 Session 进行中启用设置、添加路由或撤销路由后,要到新 Session 开始才会生效;恢复的 Session 保留其创建时记录的列表。设置的可见含义取决于每个 Session 的创建时间,设置页无法解释这一点。

Decision

SubagentModelSelectionConfig.allowedRoutes() 在每次调用时读取 volatile 的 enabled;选择关闭时立即返回 undefined,否则校验 allowedModels 并返回独立的路由列表。subagent 执行器和 list_subagent_models 在允许模型选择的工具显式选择路由时、每次发现调用时通过 ctx.get('subagentModelSelection') 调用它,因此设置编辑会对所有运行中、已恢复和子 Session 的下一次调用生效。服务缺失或设置关闭时,显式选择与之前一样只允许当前父级路由。

不追加 Session 事件,也不注册投影。subagent/model-selection-policy 声明保留,使已发布的 Session 日志仍能通过校验,但没有代码读取它;记录过策略的 Session 遵循当前设置。启用但路由列表为空、格式无效或重复时,读取该设置的每次调用都会以 INVALID_MODEL_SELECTION_SETTINGS 失败,而不是使 Agent 创建失败。普通委派和关闭模型选择的工具不读取该列表。

Alternatives considered

保留创建时快照。 不采用,因为用户可见的设置是持续生效的授权,编辑后静默跳过所有已打开的 Session,看起来就是控件失效。旧 Agent Note 担心编辑会改变运行中 Session 的能力,而这正是所需行为。

设置变更时记录新的策略事件。 不采用,因为每次保存设置都要向所有在线 Session 追加事件,已恢复的 Session 在加载前仍会遗漏,并留下两个可能不一致的来源。允许列表不是模型可见输入:工具 schema 固定,只有 list_subagent_models 结果或委派错误会到达模型,两者都作为工具结果记录在日志中。

存在已记录策略时沿用它,否则回退到设置。 不采用,因为旧 Session 会因此忽略之后的编辑,恰好在用户最常恢复的 Session 上重现不一致。

Consequences

  • 撤销路由在下一次调用时生效,包括运行中父级的子级;transcript 早先允许的路由现在可能以 MODEL_ROUTE_NOT_ALLOWED 被拒绝。
  • 重放 Session 时不能仅凭日志重现其授权;日志中的工具结果仍显示模型看到的内容。
  • Agent 创建不再依赖设置服务,因此无效设置不会阻塞没有委派工具的 Session。
  • packages/subagent/tool-subagent/tests/model-selection-settings.spec.ts 中的单元测试固定实时读取、父子 Session 中途编辑生效,以及忽略已记录策略。