fix: MixinSession copy before override & add no-tools warning; refine subagent SOP

This commit is contained in:
Liang Jiaqing committed 2026-04-11 18:50:26 +08:00
1 parent 15c5e427ca
commit 4d7e87f7b8
2 files changed
+11 -16

No files matched your search

+2 -1
View File
@@ -532,6 +532,7 @@ class NativeClaudeSession(BaseSession):
if self.tools:
tools = [dict(t) for t in self.tools]; tools[-1]["cache_control"] = {"type": "ephemeral"}
payload["tools"] = tools
else: print("[ERROR] No tools provided for this session.")
payload['system'] = [{"type": "text", "text": "You are Claude Code, Anthropic's official CLI for Claude.", "cache_control": {"type": "ephemeral"}}]
if self.system:
if self.fake_cc_system_prompt: messages[0]["content"].insert(0, {"type": "text", "text": self.system})
@@ -792,8 +793,8 @@ class MixinSession:
groups = {is_native(s) for s in self._sessions}
assert len(groups) == 1, f"MixinSession: sessions must be in same group (Native or non-Native), got {[type(s).__name__ for s in self._sessions]}"
self.name = '|'.join(s.name for s in self._sessions)
import copy; self._sessions[0] = copy.copy(self._sessions[0])
self._orig_raw_asks = [s.raw_ask for s in self._sessions]
#import copy; self._sessions[0] = copy.copy(self._sessions[0])
self._sessions[0].raw_ask = self._raw_ask
self.default_model = getattr(self._sessions[0], 'default_model', None)
self._cur_idx, self._switched_at = 0, 0.0
+9 -15
View File
@@ -1,21 +1,15 @@
# Subagent 调用 SOP
## Task Mode 文件IO协议
## 文件IO协议
- 目录:`temp/{task_name}/`(相对代码根),主agent cwd在temp/时即 `./{task_name}/`
- 启动:`python agentmain.py --task {name} [--input "内容"] [--bg] [--llm_no N]`(cwd=代码根)
- `--input`:自动建目录+清旧output+写input.txt
- `--bg`:自举后台(Popen自身去掉--bg → print PID → exit)
- 流程:启动 → 轮询 output.txt(`[ROUND END]`=该轮完成)→ 写 reply.txt 继续 → 不写则10min退出
- 干预文件:`_stop`(当轮结束退出) | `_keyinfo`(写入即注入下轮prompt的key_info) | `_intervene`(写入内容作为下轮追加指令)
- output1/2/3.txt:reply后各轮输出(递增编号),同样append+`[ROUND END]`
- input.txt:目标+约束,可指定SOP名。**禁写具体步骤**。大量数据给路径禁塞入
- ⚠ `--input`走命令行,长文本/含引号会超时。超过一句话时:先写input.txt,启动时不带`--input`
- --bg启动瞬间返回,可同一code_run内sleep后poll;非--bg方式禁止合并启动+轮询
```python
pid = os.popen(f'python {agent_root}/agentmain.py --task {name} --input "{prompt}" --bg').read().strip()
```
- 目录:`temp/{task_name}/`(cwd在temp/时即`./{task_name}/`)
- 启动:`python agentmain.py --task {name} [--input "短文本"] [--bg] [--llm_no N]`(cwd=代码根)
- `--input`自动建目录+清旧output+写input.txt;长文本先手动写input.txt再启动(不带--input)
- `--bg`后台(print PID exit),可同一code_run内sleep后poll;非--bg禁合并启动+轮询
- input:目标+约束即可,subagent同等智能。**禁写步骤/过度描述**,大量数据给路径
- 通信:output.txt(append,`[ROUND END]`=轮完成) → 写reply.txt继续 → 不写10min退出。reply后输出为output1/2/3.txt(同格式)
- 干预文件:`_stop`(当轮结束退出) | `_keyinfo`(注入working memory) | `_intervene`(追加指令)
- **主agent空闲时应读output观察进度,必要时用干预文件纠偏,禁止无脑长时间sleep轮询**
## 场景1:测试模式 - 行为验证
**用途**:观察agent真实行为,修正RULES/L2/L3/SOP