Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/sync_agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ def main():
continue
meta = ID_LABEL[ag_id]
workspace = ag.get('workspace', str(pathlib.Path.home() / f'.openclaw/workspace-{ag_id}'))
if 'allowAgents' in ag:
allow_agents = ag.get('allowAgents', []) or []
else:
allow_agents = ag.get('subagents', {}).get('allowAgents', [])
result.append({
'id': ag_id,
'label': meta['label'], 'role': meta['role'], 'duty': meta['duty'], 'emoji': meta['emoji'],
'model': normalize_model(ag.get('model', default_model), default_model),
'defaultModel': default_model,
'workspace': workspace,
'skills': get_skills(workspace),
'allowAgents': ag.get('subagents', {}).get('allowAgents', []),
'allowAgents': allow_agents,
})
seen_ids.add(ag_id)

Expand Down
41 changes: 41 additions & 0 deletions tests/test_sync_agent_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
import importlib.util
from pathlib import Path


def _load_sync_agent_config():
root = Path(__file__).resolve().parents[1]
script_path = root / "scripts" / "sync_agent_config.py"
spec = importlib.util.spec_from_file_location("sync_agent_config", script_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module


def test_sync_agent_config_accepts_allow_agents_key(tmp_path, monkeypatch):
sync_agent_config = _load_sync_agent_config()

cfg = {
"agents": {
"defaults": {"model": "openai/gpt-4o"},
"list": [
{
"id": "taizi",
"workspace": str(tmp_path / "ws-taizi"),
"allowAgents": ["zhongshu"]
}
]
}
}

cfg_path = tmp_path / "openclaw.json"
cfg_path.write_text(json.dumps(cfg, ensure_ascii=False))

monkeypatch.setattr(sync_agent_config, "OPENCLAW_CFG", cfg_path)
monkeypatch.setattr(sync_agent_config, "DATA", tmp_path / "data")

sync_agent_config.main()

out = json.loads((tmp_path / "data" / "agent_config.json").read_text())
taizi = next(agent for agent in out["agents"] if agent["id"] == "taizi")
assert taizi["allowAgents"] == ["zhongshu"]