Claude Cursor Skill

agent-model-switcher

批量查看和切换子 agent 的模型配置,用于统一调整多 agent 的 provider/model 设置。

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download aaaaqwq-agi-super-team-skills_agent-model-switcher-cdb04e8.zip · 2 KB
Part of aaaaqwq/agi-super-team — 46 skills

Install

skills CLI npx skills add https://github.com/aAAaqwq/AGI-Super-Team/tree/main/skills/agent-model-switcher
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install aaaaqwq-agi-super-team@llmmart
Git git clone https://github.com/aAAaqwq/AGI-Super-Team.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole aaaaqwq/agi-super-team collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Agent Model Switcher

批量切换所有子 agent 的模型配置。

用途

  • 批量更换所有子 agent 的 model
  • 同步所有 agent 的 models.json 配置
  • 查看所有 agent 当前的 model 配置

使用方式

1. 查看所有 agent 的 model 配置

python3 ~/clawd/skills/agent-model-switcher/switch_model.py list

2. 更换所有子 agent 的 model(不包括 main)

python3 ~/clawd/skills/agent-model-switcher/switch_model.py set <provider>/glm-5

3. 更换指定 agent 的 model

python3 ~/clawd/skills/agent-model-switcher/switch_model.py set <provider>/glm-5 --agents code,ops,quant

4. 同步所有 agent 的 models.json(从 main 复制)

python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models

5. 同步指定 agent 的 models.json

python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models --agents batch,law,xiaotu

参数说明

参数 说明
list 列出所有 agent 的 model 配置
set <model> 设置 agent 的 model
sync-models 从 main 复制 models.json 到其他 agent
--agents <names> 指定要操作的 agent(逗号分隔)
--include-main 包括 main agent(默认不包括)
--dry-run 只显示将要执行的操作,不实际执行

常用模型

别名 完整名称
glm5
glm47
opus46
sonnet46
kimi

示例

# 查看当前配置
python3 ~/clawd/skills/agent-model-switcher/switch_model.py list

# 全部子 agent 切换到 glm-5
python3 ~/clawd/skills/agent-model-switcher/switch_model.py set glm5

# 只切换 code 和 quant 到 opus-4-6
python3 ~/clawd/skills/agent-model-switcher/switch_model.py set opus46 --agents code,quant

# 同步 models.json 配置
python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models

注意事项

  1. 修改配置后,agent 需要重新启动或等待新 session 才能生效
  2. 同步 models.json 会覆盖目标 agent 的 models.json,确保 main 的配置是最新的
  3. 建议先用 --dry-run 查看将要执行的操作
Files (agi-super-team)
  • SKILL.md 2.4 KB
    ---
    name: agent-model-switcher
    description: 批量查看和切换子 agent 的模型配置,用于统一调整多 agent 的 provider/model 设置。
    ---
    
    # Agent Model Switcher
    
    批量切换所有子 agent 的模型配置。
    
    ## 用途
    
    - 批量更换所有子 agent 的 model
    - 同步所有 agent 的 models.json 配置
    - 查看所有 agent 当前的 model 配置
    
    ## 使用方式
    
    ### 1. 查看所有 agent 的 model 配置
    
    ```bash
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py list
    ```
    
    ### 2. 更换所有子 agent 的 model(不包括 main)
    
    ```bash
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py set <provider>/glm-5
    ```
    
    ### 3. 更换指定 agent 的 model
    
    ```bash
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py set <provider>/glm-5 --agents code,ops,quant
    ```
    
    ### 4. 同步所有 agent 的 models.json(从 main 复制)
    
    ```bash
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models
    ```
    
    ### 5. 同步指定 agent 的 models.json
    
    ```bash
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models --agents batch,law,xiaotu
    ```
    
    ## 参数说明
    
    | 参数 | 说明 |
    |------|------|
    | `list` | 列出所有 agent 的 model 配置 |
    | `set <model>` | 设置 agent 的 model |
    | `sync-models` | 从 main 复制 models.json 到其他 agent |
    | `--agents <names>` | 指定要操作的 agent(逗号分隔) |
    | `--include-main` | 包括 main agent(默认不包括) |
    | `--dry-run` | 只显示将要执行的操作,不实际执行 |
    
    ## 常用模型
    
    | 别名 | 完整名称 |
    |------|---------|
    | glm5 | <provider>/glm-5 |
    | glm47 | <provider>/glm-4.7 |
    | opus46 | <provider>/claude-opus-4-6 |
    | sonnet46 | <provider>/claude-sonnet-4-6 |
    | kimi | <provider>/kimi-k2.5 |
    
    ## 示例
    
    ```bash
    # 查看当前配置
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py list
    
    # 全部子 agent 切换到 glm-5
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py set glm5
    
    # 只切换 code 和 quant 到 opus-4-6
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py set opus46 --agents code,quant
    
    # 同步 models.json 配置
    python3 ~/clawd/skills/agent-model-switcher/switch_model.py sync-models
    ```
    
    ## 注意事项
    
    1. 修改配置后,agent 需要重新启动或等待新 session 才能生效
    2. 同步 models.json 会覆盖目标 agent 的 models.json,确保 main 的配置是最新的
    3. 建议先用 `--dry-run` 查看将要执行的操作
    
  • switch_model.py 5.7 KB
    #!/usr/bin/env python3
    """
    Agent Model Switcher - 批量管理 OpenClaw 子 agent 的模型配置
    """
    
    import argparse
    import json
    import os
    import shutil
    import sys
    from pathlib import Path
    
    # 配置路径
    AGENTS_DIR = Path.home() / ".openclaw" / "agents"
    
    # 模型别名
    MODEL_ALIASES = {
        "glm5": "<provider>/glm-model",
        "glm47": "<provider>/glm-model",
        "glm47-flash": "<provider>/glm-model",
        "glm47-flashx": "<provider>/glm-model",
        "opus46": "<provider>/model",
        "opus46-provider-b": "<provider>/claude-model",
        "sonnet46": "<provider>/model",
        "kimi": "<provider>/model",
        "m25": "minimax/MiniMax-M2.5",
        "m2": "minimax/MiniMax-M2",
    }
    
    # 排除的 agent(不需要单独配置的)
    EXCLUDED_AGENTS = {"telegram-agent"}
    
    
    def resolve_model(model: str) -> str:
        """解析模型别名"""
        return MODEL_ALIASES.get(model.lower(), model)
    
    
    def get_all_agents() -> list[str]:
        """获取所有 agent 名称"""
        agents = []
        for item in AGENTS_DIR.iterdir():
            if item.is_dir() and item.name not in EXCLUDED_AGENTS:
                agent_json = item / "agent" / "agent.json"
                if agent_json.exists():
                    agents.append(item.name)
        return sorted(agents)
    
    
    def get_agent_model(agent_name: str) -> str:
        """获取 agent 的当前 model"""
        agent_json = AGENTS_DIR / agent_name / "agent" / "agent.json"
        if agent_json.exists():
            with open(agent_json) as f:
                data = json.load(f)
                return data.get("model", "not set")
        return "no agent.json"
    
    
    def get_agent_zai_key(agent_name: str) -> str:
        """获取 agent 的 zai apiKey"""
        models_json = AGENTS_DIR / agent_name / "agent" / "models.json"
        if models_json.exists():
            with open(models_json) as f:
                data = json.load(f)
                key = data.get("providers", {}).get("zai", {}).get("apiKey", "not set")
                if key != "not set" and len(key) > 20:
                    return key[:20] + "..."
                return key
        return "no models.json"
    
    
    def list_agents():
        """列出所有 agent 的 model 配置"""
        agents = get_all_agents()
        print(f"{'Agent':<15} {'Model':<30} {'ZAI Key':<25}")
        print("-" * 70)
        for agent in agents:
            model = get_agent_model(agent)
            key = get_agent_zai_key(agent)
            print(f"{agent:<15} {model:<30} {key:<25}")
    
    
    def set_model(model: str, agents: list[str] = None, include_main: bool = False, dry_run: bool = False):
        """设置 agent 的 model"""
        model = resolve_model(model)
        if agents is None:
            agents = get_all_agents()
            if not include_main:
                agents = [a for a in agents if a != "main"]
        
        print(f"Setting model to: {model}")
        print(f"Agents: {', '.join(agents)}")
        print()
        
        for agent in agents:
            agent_json = AGENTS_DIR / agent / "agent" / "agent.json"
            if not agent_json.exists():
                print(f"  ⚠️  {agent}: no agent.json, skipping")
                continue
            
            if dry_run:
                print(f"  [DRY-RUN] {agent}: would set model to {model}")
                continue
            
            with open(agent_json) as f:
                data = json.load(f)
            
            old_model = data.get("model", "not set")
            data["model"] = model
            
            with open(agent_json, "w") as f:
                json.dump(data, f, indent=2, ensure_ascii=False)
            
            print(f"  ✅ {agent}: {old_model} → {model}")
    
    
    def sync_models(agents: list[str] = None, dry_run: bool = False):
        """从 main 复制 models.json 到其他 agent"""
        main_models = AGENTS_DIR / "main" / "agent" / "models.json"
        if not main_models.exists():
            print("Error: main/agent/models.json not found")
            return
        
        if agents is None:
            agents = get_all_agents()
            agents = [a for a in agents if a != "main"]
        
        print(f"Syncing models.json from main to: {', '.join(agents)}")
        print()
        
        for agent in agents:
            target_models = AGENTS_DIR / agent / "agent" / "models.json"
            
            if dry_run:
                print(f"  [DRY-RUN] {agent}: would copy models.json")
                continue
            
            shutil.copy(main_models, target_models)
            print(f"  ✅ {agent}: models.json synced")
    
    
    def main():
        parser = argparse.ArgumentParser(description="Agent Model Switcher")
        subparsers = parser.add_subparsers(dest="command", help="Commands")
        
        # list 命令
        subparsers.add_parser("list", help="List all agents' model config")
        
        # set 命令
        set_parser = subparsers.add_parser("set", help="Set agent model")
        set_parser.add_argument("model", help="Model to set (e.g., <provider>/glm-model or alias like glm5)")
        set_parser.add_argument("--agents", help="Comma-separated list of agents (default: all except main)")
        set_parser.add_argument("--include-main", action="store_true", help="Include main agent")
        set_parser.add_argument("--dry-run", action="store_true", help="Show what would be done")
        
        # sync-models 命令
        sync_parser = subparsers.add_parser("sync-models", help="Sync models.json from main to other agents")
        sync_parser.add_argument("--agents", help="Comma-separated list of agents (default: all except main)")
        sync_parser.add_argument("--dry-run", action="store_true", help="Show what would be done")
        
        args = parser.parse_args()
        
        if args.command == "list":
            list_agents()
        elif args.command == "set":
            agents = args.agents.split(",") if args.agents else None
            set_model(args.model, agents, args.include_main, args.dry_run)
        elif args.command == "sync-models":
            agents = args.agents.split(",") if args.agents else None
            sync_models(agents, args.dry_run)
        else:
            parser.print_help()
    
    
    if __name__ == "__main__":
        main()
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related