-
Notifications
You must be signed in to change notification settings - Fork 121
feat: add baseline skills #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
olbychos
wants to merge
41
commits into
main
Choose a base branch
from
feat/add_agent_skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 30 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
e68df13
feat: add baseline skills
olbychos b6fb41c
feat: add baseline skills
olbychos 1a66201
fix: merge to latest main
olbychos 800e59c
fix: merge to latest main
olbychos 3540476
chore: lint
olbychos d22e982
Merge branch 'main' into feat/add_agent_skills
maksymbuleshnyi d5f06ac
Merge branch 'main' into feat/add_agent_skills
maksymbuleshnyi 6b325ec
feat: restructure skills
olbychos 6e1862b
chore: resolve mr confict
olbychos 16286d3
fix: align baseline
olbychos 9677094
fix: bugbot gaps
olbychos 28cb87a
fix: serialization
olbychos 327e386
feat: add dynamiq registry
olbychos 093f4d2
Merge branch 'main' into feat/add_agent_skills
olbychos fa6835f
fix: serialization
olbychos e88cc46
fix: serialization
olbychos f9a3980
fix: tests
olbychos ce37b51
fix: tests
olbychos 95c29ad
fix: comments,config,init
olbychos b49e4bf
fix: annotation
olbychos 7da427e
fix: clean models and config
olbychos e6c4d86
Merge branch 'main' into feat/add_agent_skills
olbychos 4819dce
chore: upd example
olbychos f2ea596
fix: refactor registry, upd examples
olbychos 47b47f5
fix: refactor registry, upd examples
olbychos b823947
fix: config
olbychos fb8dda7
chore: skip qdrant test
olbychos 220fd6b
fix: skills init
olbychos 203d83a
fix: resolve comments
olbychos 189f1ce
fix: resolve comments
olbychos eecd5c0
Merge branch 'main' into feat/add_agent_skills
olbychos 663a436
Merge branch 'main' into feat/add_agent_skills
olbychos 375555c
fix: revert yaml
olbychos 302895f
fix: connection issues
olbychos b830bbb
fix: comments, types, skills registry
olbychos 1f82288
fix: local registry
olbychos 4c32c85
feat: add logs skillstools
olbychos 0aa8ea5
Merge remote-tracking branch 'origin/feat/add_agent_skills' into feat…
olbychos 2766ca3
fix: test,revert yaml
olbychos 410ae51
fix: errors
olbychos 06c01f8
feat: upd local skills
olbychos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| from typing import Any, ClassVar, Literal | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| from dynamiq.nodes import Node, NodeGroup | ||
| from dynamiq.nodes.agents.exceptions import ToolExecutionException | ||
| from dynamiq.runnables import RunnableConfig | ||
| from dynamiq.skills import BaseSkillRegistry | ||
| from dynamiq.skills.utils import extract_skill_content_slice | ||
| from dynamiq.utils.logger import logger | ||
|
|
||
|
|
||
| class SkillsToolInputSchema(BaseModel): | ||
| """Input schema for Skills tool. Actions: list (discover), get (full or partial content).""" | ||
|
|
||
| action: Literal["list", "get"] = Field( | ||
olbychos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ..., | ||
| description="Action: 'list' discover skills, 'get' full or partial skill content.", | ||
| ) | ||
| skill_name: str | None = Field(default=None, description="Skill name (required for get)") | ||
| section: str | None = Field( | ||
| default=None, | ||
| description="For get: return only this markdown section (e.g. 'Welcome messages')", | ||
| ) | ||
| line_start: int | None = Field(default=None, description="For get: 1-based start line (body only)") | ||
| line_end: int | None = Field(default=None, description="For get: 1-based end line (inclusive)") | ||
olbychos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class SkillsTool(Node): | ||
| """Tool for skills: discover and get content from a skill registry (Dynamiq or Local). | ||
|
|
||
| After get, apply the skill's instructions yourself and provide the result in your final answer. | ||
| """ | ||
|
|
||
| group: Literal[NodeGroup.TOOLS] = NodeGroup.TOOLS | ||
| name: str = "SkillsTool" | ||
| description: str = ( | ||
| "Manages skills (instructions only). Use this tool to:\n" | ||
| "- List available skills: action='list'\n" | ||
| "- Get skill content: action='get', skill_name='...'. " | ||
| "For large skills use section='Section title' or line_start/line_end to read only a part.\n\n" | ||
| "After get, apply the skill's instructions yourself in your reasoning and provide the result " | ||
| "in your final answer. Do not call the tool again with user content to transform; " | ||
| "the tool only provides instructions; you produce the output." | ||
| ) | ||
|
|
||
| skill_registry: BaseSkillRegistry = Field( | ||
| ..., | ||
| description="Registry providing skills (Dynamiq or Local).", | ||
| ) | ||
olbychos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| input_schema: ClassVar[type[SkillsToolInputSchema]] = SkillsToolInputSchema | ||
|
|
||
| @property | ||
| def to_dict_exclude_params(self): | ||
| return super().to_dict_exclude_params | { | ||
| "skill_registry": True, | ||
| } | ||
|
|
||
| def execute( | ||
| self, input_data: SkillsToolInputSchema, config: RunnableConfig | None = None, **kwargs | ||
| ) -> dict[str, Any]: | ||
| action = input_data.action | ||
| logger.info("SkillsTool - action=%s", action) | ||
|
|
||
| if action == "list": | ||
| return self._list_skills() | ||
| if action == "get": | ||
| if not input_data.skill_name: | ||
| raise ToolExecutionException("skill_name required for get", recoverable=True) | ||
| return self._get_skill( | ||
| input_data.skill_name, | ||
| section=input_data.section, | ||
| line_start=input_data.line_start, | ||
| line_end=input_data.line_end, | ||
| ) | ||
| raise ToolExecutionException(f"Unknown action: {action}", recoverable=True) | ||
|
|
||
| def _list_skills(self) -> dict[str, Any]: | ||
| metadata_list = self.skill_registry.get_skills_metadata() | ||
| skills_info = [{"name": m.name, "description": m.description} for m in metadata_list] | ||
| names = [m.name for m in metadata_list] | ||
| logger.info("SkillsTool - list: %d skill(s) %s", len(metadata_list), names) | ||
| return { | ||
| "content": { | ||
| "available_skills": skills_info, | ||
| "total": len(metadata_list), | ||
| } | ||
| } | ||
|
|
||
| def _get_skill( | ||
| self, | ||
| skill_name: str, | ||
| section: str | None = None, | ||
| line_start: int | None = None, | ||
| line_end: int | None = None, | ||
| ) -> dict[str, Any]: | ||
| try: | ||
| instructions = self.skill_registry.get_skill_instructions(skill_name) | ||
| except Exception as e: | ||
| raise ToolExecutionException(f"Skill '{skill_name}' not found: {e}", recoverable=True) from e | ||
olbychos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if section is not None or line_start is not None or line_end is not None: | ||
| sliced, section_used = extract_skill_content_slice( | ||
| instructions.instructions, | ||
| section=section, | ||
| line_start=line_start, | ||
| line_end=line_end, | ||
| ) | ||
| out = { | ||
| "name": instructions.name, | ||
| "description": instructions.description, | ||
| "instructions": sliced, | ||
| "section_used": section_used, | ||
| } | ||
| logger.info( | ||
| "SkillsTool - get: skill=%s (section=%s, lines=%s-%s) -> content received", | ||
| skill_name, | ||
| section, | ||
| line_start, | ||
| line_end, | ||
| ) | ||
| return {"content": out} | ||
|
|
||
| logger.info( | ||
| "SkillsTool - get: skill=%s -> content received (%d chars)", | ||
| skill_name, | ||
| len(instructions.instructions), | ||
| ) | ||
| return { | ||
| "content": { | ||
| "name": instructions.name, | ||
| "description": instructions.description, | ||
| "instructions": instructions.instructions, | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.