agentscope-ai / agentscope-ai/QwenPaw

[Feature Request] 按需加载技能(On-Demand Skill Loading)

Ouverte
#6,699 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
34.9k
Forks
3.1k
Merge moyen
1 j 15 h
PR mergées (30 j)
225

Description

## 🎯 Problem Description

Currently, QwenPaw **loads all enabled skills into the system prompt** on every request. For users with 27+ skills, skill descriptions alone consume approximately **8,000-10,000 tokens** (~25-30% of the system prompt).

This means:
- Every conversation repeatedly consumes significant context budget
- Even when a session doesn't need certain skills, their descriptions are still loaded
- Long conversations quickly hit the context window limit

---

## 📊 Actual Data

Based on Qwen3.6-35B-A3B model measurements:

| Component | Est. Tokens | Share |
|-----------|:-----------:|:-----:|
| Skills descriptions (27) | ~8,000-10,000 | ~25% |
| AGENTS.md | ~9,000-10,000 | ~28% |
| Tool Schemas (~60+ tools) | ~6,000-8,000 | ~18% |
| PROFILE.md | ~3,000-3,500 | ~9% |
| SOUL.md | ~1,000-1,500 | ~3% |
| Session Metadata + others | ~4,000-5,000 | ~12% |
| **Total** | **~35,521** | **100%** |

Skills + AGENTS.md together occupy **~53%** of the system prompt, and the skills portion is ideal for on-demand loading.

---

## 💡 Proposed Solutions

### Option 1: Dynamic Skill Discovery (Recommended)

Inject only `name` + `description` (abbreviated version, ~100-200 tokens per skill) in the system prompt. When the agent decides to use a specific skill, append the full SKILL.md content to the context at that moment.

**Pros:**
- Minimal code changes, only modify context building logic
- Saves ~70-80% skill tokens (from ~10K → ~2-3K)
- Transparent to existing workflows

**Cons:**
- One extra round-trip delay on first use of a new skill (loading full content)

---

### Option 2: User-Specified Active Skills

Allow users to specify which skills they need for the current session via config or message. Only load those skills.

```json
{
"active_skills": ["pdf", "xlsx", "browser_cdp"]
}
```

**Pros:**
- Flexible and controllable
- Suitable for known workflow scenarios

**Cons:**
- Requires manual management by user
- Forgetting to add a needed skill may impact experience

---

### Option 3: Smart Pre-loading

Predict which skills are likely needed based on the agent's historical behavior patterns, and preload only that subset.

**Pros:**
- Fully automated, best UX

**Cons:**
- Complex implementation
- May have false predictions

---

## 🔧 Expected Impact

| Metric | Current | After (Option 1) |
|--------|---------|------------------|
| System prompt total | ~35K tokens | ~25-27K tokens |
| Skills overhead | ~10K tokens | ~1.5-2K tokens |
| Available context | ~125K | ~133-135K |

---

## 📆 References

- Current skill injection logic is in the context construction code
- Skill structure documented in `docs/skills.zh.md`
- Similar needs discussed in other Agent frameworks (e.g., AutoGen, CrewAI tool/skill on-demand loading)

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.