|
|
@@ -507,6 +507,17 @@ async def rollback_agent(
|
|
|
_WORKSPACE_CONV_TEMPLATES = {"workspace.assistant"}
|
|
|
|
|
|
|
|
|
+def _is_native_workspace(agent, config) -> bool:
|
|
|
+ """是否走原生 claude-code 车道:工作区对话型模板 **且** provider=claude-code。
|
|
|
+ native 车道是 `claude -p`(只认 claude 自己的模型);切到 qwen/ollama/openai 等
|
|
|
+ 必须退回 react 车道(text-provider+平台工具),否则会把 --model qwen-max 传给
|
|
|
+ claude-code、跑不起来。"""
|
|
|
+ if (agent.get("agent_template") or "") not in _WORKSPACE_CONV_TEMPLATES:
|
|
|
+ return False
|
|
|
+ provider = ((config or {}).get("model") or {}).get("provider") or ""
|
|
|
+ return provider == "claude-code"
|
|
|
+
|
|
|
+
|
|
|
def _require_workspace_dir(agent, req):
|
|
|
"""workspace 对话型 agent 必须带有效 context.work_dir,否则 400 拒绝(不回退空家目录)。"""
|
|
|
import os as _os
|
|
|
@@ -615,8 +626,10 @@ async def run_agent(
|
|
|
_inplace_dir = _ctx_wd if (_ctx_wd and _os.path.isdir(_ctx_wd)) else ""
|
|
|
if _inplace_dir:
|
|
|
work_dir = source_dir = _inplace_dir
|
|
|
- # 车道 B:工作区对话型模板走原生 claude-code(见 _execute_agent native 分支)。
|
|
|
- _native_ws = (agent.get("agent_template") or "") in _WORKSPACE_CONV_TEMPLATES
|
|
|
+ # 车道 B:工作区对话型模板 **且 provider=claude-code** 才走原生车道。native 车道是
|
|
|
+ # `claude -p`(只认 sonnet/opus/haiku);切成 qwen/ollama 等必须退回 react 车道
|
|
|
+ # (text-provider+平台工具,对非 agentic-CLI 模型本来就是对的模式)。
|
|
|
+ _native_ws = _is_native_workspace(agent, config)
|
|
|
|
|
|
# 注入顺序(MEMORY_DESIGN §2.2):本会话前情 → 相关历史(L3) → KB → 用户问题
|
|
|
enriched_input = req.input
|
|
|
@@ -780,7 +793,7 @@ async def run_agent_stream(
|
|
|
_inplace_dir = _ctx_wd if (_ctx_wd and _os.path.isdir(_ctx_wd)) else ""
|
|
|
if _inplace_dir:
|
|
|
work_dir = source_dir = _inplace_dir
|
|
|
- _native_ws = (agent.get("agent_template") or "") in _WORKSPACE_CONV_TEMPLATES
|
|
|
+ _native_ws = _is_native_workspace(agent, config)
|
|
|
|
|
|
# 会话记忆 P1:thread 解析(run 记录在下方流式分支创建,这里先拿 id)
|
|
|
from agentpaas.engine import thread_memory as _tm
|