DeepSeek Harness (DSH) 采用插件化架构。在构建多代理系统时,主代理通常调用昂贵的官方 API,而子代理如果未配置,会继续走官方接口,增加成本并带来隐私泄露风险。dsh-llama-responses 作为一个适配器插件,解决了这个问题,它通过 OpenAI Responses 协议,将子代理的请求路由到本地运行的 llama.cpp 服务。
插件概览¶
- 名称: dsh-llama-responses
- 所有者: SnowRikka
- 类别: 模型推理
- 许可证: MIT
- 核心功能:
- 多轮记忆
- function_call 流式
- function_call_output 回传
- 子代理委派 (spawn/可继续后台, fork/one-shot 前台)
- 追问排队 (send_message)
- 状态查询 (list_agents)
- 中断控制 (interrupt_agent)
- 结算通知 (report)
- Skill 发现与加载
安装¶
使用官方插件命令安装:
dsh plugin --profile web add git+https://github.com/SnowRikka/dsh-llama-responses.git
在 npm 发布前,也可以通过软链方式安装(便于修改源码):
git clone https://github.com/SnowRikka/dsh-llama-responses.git ~/dsh-llama-responses
ln -sfn ~/dsh-llama-responses ~/.dsh/profiles/web/node_modules/dsh-llama-responses
使用前置条件¶
- 本地模型服务已运行: 确保 llama.cpp 的
llama-server正在运行,监听本地端口(如 8080)。 - 关键配置步骤: 每次启动 DeepSeek Harness 后,必须先手动选择一次本地的 qwen3.8-27b 并提问一次,然后将主代理切回 DeepSeek V4 模型。不做这一步,子代理不会正常路由到本地模型。
启用子代理功能¶
本插件挂载在 DSH 的子代理体系上。默认情况下,web profile 的子代理工具是禁用的,需要手动启用。
在 ~/.dsh/profiles/web/cordis.patch.yml 中加入以下配置:
- id: tool-subagent-control # send_message / interrupt_agent
disabled: false
- id: tool-subagent-list-agents # list_agents
disabled: false
- id: tool-subagent # 委派工具(可继续后台子代理)
disabled: false
- id: tool-subagent-fork # 委派工具(one-shot,已重定向 spawn=无父对话)
disabled: false
启用后,模型将获得 subagent、subagent_fork、send_message、interrupt_agent、list_agents 五个工具。
启用本地模型路由¶
1. 配置适配器¶
在 ~/.dsh/profiles/<profile>/cordis.patch.yml 中注册适配器:
- insert:
- id: llm-responses-local
name: dsh-llama-responses
config:
baseURL: http://127.0.0.1:8080/v1
providerName: llama-responses
apiKeyEnv: DSH_LOCAL_LLM_KEY
models:
- id: qwen3.8-27b
name: Qwen3.8-27B IQ4_XS (local)
contextWindow: 163840
defaultContextWindow: 163840
defaultMaxTokens: 8192
2. 配置子代理使用本地模型¶
在 patch 中指定子代理的 provider 为 llama-responses:
- id: tool-subagent
config:
provider: spawn
toolName: subagent
backgroundMode: continuable
agentOptions:
provider: llama-responses
model: qwen3.8-27b
maxTokens: 8192
3. 环境变量¶
设置本地模型鉴权占位符:
export DSH_LOCAL_LLM_KEY=local-no-auth
子代理隔离设计¶
这是本插件的重要设计特性。所有子代理不继承父对话,包括父会话已完成的历史内容。subagent_fork 工具已通过 patch 重定向,确保完全隔离。父代理若需传递背景,必须显式写在委派指令中。
协议细节¶
插件实现了 OpenAI Responses 协议的适配。在对接 llama.cpp 时,需注意以下细节:
- 历史消息格式: 历史消息条目必须带顶层
type: 'message',assistant 内容使用output_text。 - 工具调用: 工具定义使用扁平格式
{type: 'function', name, description, parameters}。 - 结果回传: 工具结果回传使用
{type: 'function_call_output', call_id, output}。 - SSE 事件: 监听
response.output_text.delta、response.function_call_arguments.delta、response.output_item.done、response.completed。