Skip to content

feat: per-agent isolation for skills, mode, and evolution#50

Open
OctoClaws wants to merge 1 commit intoaiming-lab:mainfrom
OctoClaws:feature/per-agent-isolation
Open

feat: per-agent isolation for skills, mode, and evolution#50
OctoClaws wants to merge 1 commit intoaiming-lab:mainfrom
OctoClaws:feature/per-agent-isolation

Conversation

@OctoClaws
Copy link
Copy Markdown

Summary

Adds per-agent isolation to MetaClaw, enabling multi-agent deployments where each agent has independent skills, operating mode, and evolution pipeline.

Closes #49

Changes

1. extensions/metaclaw-openclaw/index.ts (+2 lines)

  • Propagates X-Agent-Id header from OpenClaw's ctx.agentId alongside existing X-Session-Id and X-Turn-Type

2. metaclaw/config.py (+10 lines)

  • Adds agents: dict field to MetaClawConfig for per-agent overrides
  • Supports mode, skills_dir, lora_output per agent

3. metaclaw/api_server.py (+133 lines, -25 lines)

  • Reads X-Agent-Id header in chat_completions endpoint
  • New _get_agent_skill_manager(agent_id) method:
    • Creates/caches per-agent SkillManager instances
    • Loads skills from {skills_dir}/{agent_id}/ + {skills_dir}/_shared/
    • Falls back to global skill_manager when no agents config
  • Per-agent mode routing: resolves skills_only vs rl per agent from config
  • All 4 skill evolution trigger sites pass agent_id for correct directory targeting
  • _inject_skills() and _inject_augmentation() accept optional skill_manager parameter

Config Example

agents:
  research-agent:
    mode: rl
  assistant-agent:
    mode: skills_only

Directory Structure

~/.metaclaw/skills/
β”œβ”€β”€ _shared/              # Shared across all agents
β”œβ”€β”€ research-agent/       # Auto-evolved skills for research-agent
└── assistant-agent/      # Auto-evolved skills for assistant-agent

Backward Compatibility

  • No X-Agent-Id header β†’ falls back to _default agent β†’ existing behavior
  • No agents config section β†’ all agents share global config β†’ existing behavior
  • Existing flat skills/ directory works as-is for single-agent setups

Add X-Agent-Id header propagation from OpenClaw plugin to MetaClaw proxy,
enabling per-agent isolation across multiple dimensions:

- Per-agent skill directories: each agent gets its own skill subdirectory
  under skills_dir/{agent_id}/, with a shared _shared/ directory merged in
- Per-agent mode routing: agents can independently use skills_only or rl
  mode via the new agents config section
- Per-agent skill evolution: SkillEvolver writes new skills to the correct
  agent's subdirectory
- Per-agent SkillManager cache: avoids recreating managers on every request

Config example (config.yaml):
  agents:
    agent-a:
      mode: skills_only
    agent-b:
      mode: rl

Backward compatible: if no X-Agent-Id header is sent or no agents config
exists, all behavior falls back to the existing single-agent mode.

Closes aiming-lab#49
@richard-peng-xia
Copy link
Copy Markdown
Contributor

Hi @OctoClaws,

Thanks for the PR! The overall design is solid. Two issues before we can merge:

  1. config_store.py not updated
    MetaClawConfig now has an agents field, but to_metaclaw_config() in config_store.py never reads the agents: block from config.yaml and passes it in. This means per-agent mode overrides in config will silently have no effect β€” MetaClawConfig.agents will always be an empty dict regardless of what the user configures. This needs to be fixed before merging.

  2. ctx.agentId is not exposed by the OpenClaw plugin SDK
    The extension reads ctx.agentId in the before_prompt_build handler, but this field doesn't exist in the current OpenClaw context type. At runtime it will always be undefined, so X-Agent-Id will never be sent and all agents will fall back to _default β€” meaning the isolation feature won't actually work end-to-end. Could you confirm whether OpenClaw already exposes agentId on the event context, or if a companion PR to OpenClaw is needed to add it first?

Happy to help review a follow-up once these are addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Per-agent isolation (skills, mode, LoRA, memory)

2 participants