mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-09 17:08:29 +00:00
Reattach loaded skills after compaction
When compression hides an explicitly loaded skill body, reattach the current missing revision as a normal skills_tool history result under one fixed budget. Preserve skill name and revision metadata in automatic and manual compaction summaries without copying full skill bodies.
This commit is contained in:
parent
db01d7c1c8
commit
3c83b2eca2
12 changed files with 222 additions and 25 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
|
|
@ -214,7 +213,7 @@ class SkillsTool(Tool):
|
|||
skill_name=skill.name,
|
||||
agent=self.agent,
|
||||
)
|
||||
revision = self._skill_revision(skill_data)
|
||||
revision = skills_helper.skill_revision(skill_data)
|
||||
metadata = {
|
||||
"name": skill.name,
|
||||
"path": str(skill.path),
|
||||
|
|
@ -255,10 +254,6 @@ class SkillsTool(Tool):
|
|||
additional={"skill_instructions": metadata},
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _skill_revision(skill_data: str) -> str:
|
||||
return hashlib.sha256(skill_data.encode("utf-8")).hexdigest()[:16]
|
||||
|
||||
def _visible_skill_revision_loaded(self, skill_name: str, revision: str) -> bool:
|
||||
history_obj = getattr(self.agent, "history", None)
|
||||
output = getattr(history_obj, "output", None)
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
- `load` includes a `skill_instructions` metadata sidecar in the tool-result content with skill name, path, revision, source, and whether full content was included.
|
||||
- Duplicate `load` calls may omit the full body only when the same skill revision is still present in model-visible `history.output()` content.
|
||||
- Observed side-effect areas: filesystem reads, filesystem deletion, settings/state persistence, chat history content.
|
||||
- Imported dependency areas include: `__future__`, `hashlib`, `helpers`, `helpers.print_style`, `helpers.tool`, `pathlib`, `typing`.
|
||||
- Imported dependency areas include: `__future__`, `helpers`, `helpers.print_style`, `helpers.tool`, `pathlib`, `typing`.
|
||||
|
||||
## Key Concepts
|
||||
|
||||
- Important called helpers/classes observed in the source: `str.strip.lower.replace`, `skill_name.strip`, `super.get_log_object`, `self._normalize_skill_name`, `self.get_log_object`, `skills_helper.list_skills`, `join`, `skills_helper.search_skills`, `skills_helper.find_skill`, `skills_helper.load_skill_for_agent`, `hashlib.sha256`, `skill.path.resolve`, `Path`, `resolved.read_text`, `skill_name.startswith`, `skill_name.endswith`, `self._current_action`, `self.agent.context.log.log`, `Response`, `strip`, `loaded.remove`, `target.is_absolute`.
|
||||
- Important called helpers/classes observed in the source: `str.strip.lower.replace`, `skill_name.strip`, `super.get_log_object`, `self._normalize_skill_name`, `self.get_log_object`, `skills_helper.list_skills`, `join`, `skills_helper.search_skills`, `skills_helper.find_skill`, `skills_helper.load_skill_for_agent`, `skills_helper.skill_revision`, `skill.path.resolve`, `Path`, `resolved.read_text`, `skill_name.startswith`, `skill_name.endswith`, `self._current_action`, `self.agent.context.log.log`, `Response`, `strip`, `loaded.remove`, `target.is_absolute`.
|
||||
- Keep request/response, tool, or helper semantics documented here at the same time as source changes.
|
||||
|
||||
## Work Guidance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue