| refactor(harness): unify tool registration via AbilityManager.add_ability
Route all executable tool registration through a single
AbilityManager.add_ability(card, resource) entry point that keeps the
ability-manager card id and the resource-manager key consistent, branching
on ToolCard.stateless:
- stateful (default): rewrite card.id to "{name}_{agent_id}" and register
with refresh=True so each agent owns an exclusive entry. Fixes the
"Tool id is already registered with a different tool instance" crash when
multiple team members register their own instances of the same tool.
- stateless: keep the bare id and register with skip_if_exists=True so a
shared module-level singleton is registered once and reused across agents.
Details:
- ToolCard gains a stateless field; @tool gains a stateless passthrough.
- resource_mgr.add_tool gains skip_if_exists; refresh now logs a warning
when it drops a previous registration.
- AbilityManager learns its owner agent id (wired from BaseAgent /
DeepAgent.configure) and gains add_ability / remove_ability.
- The declarative path (apply_deep_agent_parts) and every rail
(sys_operation, subagent, skill_use, lsp, task_planning, agent_mode,
progressive_tool, mcp, ask_user, worktree, memory/external/coding) now
register through add_ability, dropping per-rail add_tool + ability
add/remove bookkeeping.
Tests migrated to the new API; adds add_ability unit coverage (stateful
qualify/refresh, stateless skip).
| 20 分钟前 |