agentscope-ai / agentscope-ai/QwenPaw

feat: Semantic skill routing for large skill pools

Abierto
#3,091 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
35k
Forks
3.1k
Merge medio
1 d 13 h
PR fusionados (30 d)
228

Descripción

```markdown
## Problem

When users install 50+ skills and connect multiple MCP servers, CoPaw injects
all skill metadata into the LLM context. This causes:
- Context overflow with large skill pools
- Poor skill selection accuracy due to information overload
- Unnecessary token consumption

As the skill ecosystem grows (Skills Hub, community skills, MCP servers),
this problem will become increasingly severe.

## Proposed Solution

Add an optional semantic routing layer that uses embedding-based retrieval
(sentence-transformers + FAISS) to filter skills before injecting them into
the agent context. Only the top-k most relevant skills are registered per query.

Key design principles:
- **Zero-invasive**: Disabled by default, optional dependency (`copaw[semantic]`)
- **Fail-open**: Falls back to existing behavior on any error
- **No interface changes**: All existing public APIs remain unchanged

### Background

I'm 燕衡 from Alibaba Private Cloud. We've been working on compositional skill
routing for LLM agents and have a paper in preparation on this topic.
Key findings from our experiments:

- Embedding-based skill retrieval reduces context consumption by 99%+
while maintaining selection accuracy
- A lightweight encoder (all-MiniLM-L6-v2, ~80MB) is sufficient for
skill-level routing — no GPU required
- Metadata-only retrieval (name + description) matches full-body retrieval

This PR adapts the core algorithms natively into CoPaw's codebase
(no external dependency). Happy to share more details about the research
privately if helpful.

## Scope

I plan to contribute this in 3 focused PRs:
- **PR1**: Semantic skill filtering (this issue) — smallest change, highest value
- **PR2**: MCP tool filtering — reuses PR1 infrastructure
- **PR3**: Multi-skill composition — task decomposition + DAG planning

## Implementation Plan

- New module: `src/copaw/routing/`
- Config: `semantic_routing` section in config.json (disabled by default)
- Optional deps: `sentence-transformers`, `faiss-cpu` (declared as extras)
- Integration point: `CoPawAgent._register_skills()`
- Full test coverage with auto-skip when optional deps not installed

Happy to discuss the approach before submitting code. Looking forward to
contributing to CoPaw!
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.