fix(skill): remove auto activation setting

This commit is contained in:
Junyan Qin
2026-05-13 00:51:16 +08:00
parent a565f3e022
commit 4db0f20dc4
13 changed files with 33 additions and 90 deletions

View File

@@ -21,7 +21,6 @@ _FRONTMATTER_FIELDS = (
'name',
'display_name',
'description',
'auto_activate',
)
_PUBLIC_SKILL_FIELDS = (
@@ -30,7 +29,6 @@ _PUBLIC_SKILL_FIELDS = (
'description',
'instructions',
'package_root',
'auto_activate',
'created_at',
'updated_at',
)
@@ -51,8 +49,6 @@ def _build_skill_md(metadata: dict, instructions: str) -> str:
value = metadata.get(key)
if value is None:
continue
if key == 'auto_activate' and value is True:
continue
if isinstance(value, str) and not value.strip():
continue
frontmatter[key] = value
@@ -118,7 +114,6 @@ class SkillService:
'name': name,
'display_name': self._resolve_create_field(data, 'display_name', imported_skill_data, default=''),
'description': self._resolve_create_field(data, 'description', imported_skill_data, default=''),
'auto_activate': self._resolve_create_bool(data, 'auto_activate', imported_skill_data, default=True),
}
instructions = self._resolve_create_field(data, 'instructions', imported_skill_data, default='')
self._write_skill_md(target_root, metadata, instructions)
@@ -147,7 +142,6 @@ class SkillService:
'name': skill['name'],
'display_name': data.get('display_name', skill.get('display_name', '')),
'description': data.get('description', skill.get('description', '')),
'auto_activate': data.get('auto_activate', skill.get('auto_activate', True)),
}
instructions = str(data.get('instructions', skill.get('instructions', '')) or '')
self._write_skill_md(skill['package_root'], metadata, instructions)
@@ -372,7 +366,6 @@ class SkillService:
'display_name': str(metadata.get('display_name') or '').strip(),
'description': str(metadata.get('description') or '').strip(),
'instructions': instructions,
'auto_activate': bool(metadata.get('auto_activate', True)),
}
async def _reload_skills(self) -> None:
@@ -400,7 +393,6 @@ class SkillService:
'display_name': str(metadata.get('display_name') or '').strip(),
'description': str(metadata.get('description') or '').strip(),
'instructions': instructions,
'auto_activate': bool(metadata.get('auto_activate', True)),
}
async def _download_github_skill_to_temp(self, asset_url: str, tmp_dir: str) -> str:
@@ -488,7 +480,6 @@ class SkillService:
'display_name': str(metadata.get('display_name') or '').strip(),
'description': str(metadata.get('description') or '').strip(),
'instructions': instructions,
'auto_activate': bool(metadata.get('auto_activate', True)),
'package_root': self._build_preview_target_dir(base_target_name, relative_path, suffix),
}
)
@@ -626,14 +617,6 @@ class SkillService:
return str(imported_skill_data.get(field, default) or default)
return value
@staticmethod
def _resolve_create_bool(data: dict, field: str, imported_skill_data: dict | None, *, default: bool) -> bool:
if field in data and data[field] is not None:
return bool(data[field])
if imported_skill_data is not None:
return bool(imported_skill_data.get(field, default))
return default
def _write_skill_md(self, package_root: str, metadata: dict, instructions: str) -> None:
package_root = self._normalize_package_root(package_root)
os.makedirs(package_root, exist_ok=True)

View File

@@ -275,7 +275,7 @@ class PreProcessor(stage.PipelineStage):
f'Skill index injected into system prompt: '
f'pipeline={query.pipeline_uuid} '
f'bound_skills={bound_skills or "all"} '
f'available_skills=[{", ".join(s["name"] for s in self.ap.skill_mgr.skills.values() if s.get("auto_activate", True))}]'
f'available_skills=[{", ".join(s["name"] for s in self.ap.skill_mgr.skills.values() if bound_skills is None or s["name"] in bound_skills)}]'
)
# Append skill instruction to the first system message
if query.prompt.messages and query.prompt.messages[0].role == 'system':

View File

@@ -105,7 +105,6 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
'display_name': str(parameters.get('display_name', '') or '').strip(),
'description': str(parameters.get('description', '') or '').strip(),
'instructions': instructions,
'auto_activate': parameters.get('auto_activate', True),
}
)
return {
@@ -137,7 +136,7 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
raise ValueError('name is required')
data = {'name': name}
for field in ('display_name', 'description', 'instructions', 'auto_activate'):
for field in ('display_name', 'description', 'instructions'):
if field in parameters:
data[field] = parameters[field]
@@ -172,7 +171,6 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
'description': str(parameters.get('description') or scanned.get('description', '')).strip(),
'instructions': str(parameters.get('instructions') or scanned.get('instructions', '')),
'package_root': host_path,
'auto_activate': parameters.get('auto_activate', scanned.get('auto_activate', True)),
}
)
return {
@@ -228,10 +226,6 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
'type': 'string',
'description': 'The SKILL.md body instructions for the new skill.',
},
'auto_activate': {
'type': 'boolean',
'description': 'Whether the skill should be considered for automatic activation. Defaults to true.',
},
},
'required': ['name', 'instructions'],
'additionalProperties': False,
@@ -299,10 +293,6 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
'type': 'string',
'description': 'Optional replacement SKILL.md body instructions.',
},
'auto_activate': {
'type': 'boolean',
'description': 'Optional new auto_activate value.',
},
},
'required': ['name'],
'additionalProperties': False,
@@ -363,10 +353,6 @@ class SkillAuthoringToolLoader(loader.ToolLoader):
'type': 'string',
'description': 'Optional instructions override.',
},
'auto_activate': {
'type': 'boolean',
'description': 'Optional auto_activate override.',
},
},
'required': ['path'],
'additionalProperties': False,

View File

@@ -119,7 +119,12 @@ def prepare_skill_activation(
if not response_content or not getattr(ap, 'skill_mgr', None):
return None
activated_skill_names = ap.skill_mgr.detect_skill_activations(response_content)
visible_skills = skill_loader.get_visible_skills(ap, query)
activated_skill_names = [
skill_name
for skill_name in ap.skill_mgr.detect_skill_activations(response_content)
if skill_name in visible_skills
]
if not activated_skill_names:
return None

View File

@@ -135,7 +135,6 @@ class SkillManager:
'raw_content': content,
'package_root': package_root,
'entry_file': entry_file,
'auto_activate': bool(metadata.get('auto_activate', True)),
'created_at': dt.datetime.fromtimestamp(stat.st_ctime, tz=dt.timezone.utc).isoformat(),
'updated_at': dt.datetime.fromtimestamp(stat.st_mtime, tz=dt.timezone.utc).isoformat(),
}
@@ -154,8 +153,6 @@ class SkillManager:
def get_skill_index(self, pipeline_uuid: str | None = None, bound_skills: list[str] | None = None) -> str:
skills_to_index = []
for skill in self.skills.values():
if not skill.get('auto_activate', True):
continue
if bound_skills is not None and skill['name'] not in bound_skills:
continue
skills_to_index.append(skill)