-
Notifications
You must be signed in to change notification settings - Fork 3
feat(skills): invoke a user's own skill from a message #553
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f906903
docs: add design for invoking a skill from a message
andrii-novikov 53dc0ee
docs: rewrite the skill invocation design as phase 1a #549
andrii-novikov adf9be7
docs: approve the phase 1a skill invocation design #549
andrii-novikov 3cd3da3
feat(skills): invoke a user's own skill from a message #549
andrii-novikov 2cb6012
refactor(skills): reuse StagedToolSyntheticInjector for skill invocat…
andrii-novikov 3306b69
docs: align the skill invocation design with the implementation #549
andrii-novikov 09f2175
fix(skills): report skill issues that belong to a message, not a URL …
andrii-novikov 34f5fed
docs: mark the skill invocation design as implemented #549
andrii-novikov ee0165d
docs: reconcile skill invocation design with implementation
andrii-novikov 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,3 @@ | ||
| from quickapp.skill_invocation.skill_invocation_module import SkillInvocationModule | ||
|
|
||
| __all__ = ["SkillInvocationModule"] |
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,69 @@ | ||
| import threading | ||
|
|
||
| from quickapp.common.exceptions import InitializationException, SkillInitializationException | ||
| from quickapp.skills import ResolvedSkill, SkillsProvider | ||
|
andrii-novikov marked this conversation as resolved.
|
||
|
|
||
| _USER_SELECTED_HEADER = "Skill `{name}`, selected by the user for this conversation." | ||
|
|
||
|
|
||
| def _mark_user_selected(skill: ResolvedSkill) -> ResolvedSkill: | ||
| """Prepend one line naming the skill as user-selected, so the model can tell it | ||
| apart from the agent's own when the user refers to it in words.""" | ||
| header = _USER_SELECTED_HEADER.format(name=skill.metadata.name) | ||
| return skill.model_copy(update={"content": f"{header}\n{skill.content}"}) | ||
|
|
||
|
|
||
| class _InvokedSkillsContext(SkillsProvider): | ||
| """Request-scoped bag of the skills picked on this conversation's messages, | ||
| populated by ``_SkillInvocationInitializer``, and the ``SkillsProvider`` | ||
| ``SkillsRegistry`` consumes for them. | ||
|
|
||
| The entries are the skills as resolved — own name, own description, real URL, | ||
| files and reader — so everything downstream (the merge, ``generate_skills_xml``, | ||
| ``read_skill``, bundled files) works unchanged. | ||
|
|
||
| ``order`` runs ahead of every agent source (agent/predefined ``0``, dial-prompt | ||
| ``10``, dial-skill ``20``), so a picked skill wins a name collision and the | ||
| agent's same-named skill is dropped by the registry's collision path. | ||
| """ | ||
|
|
||
| order = -10 | ||
| display_name = "user skills" | ||
|
|
||
| def __init__(self) -> None: | ||
| self._current_pick_url: str | None = None | ||
| self._skills_by_url: dict[str, ResolvedSkill] = {} | ||
| self._exceptions: list[InitializationException] = [] | ||
| self._lock = threading.Lock() | ||
|
|
||
| @property | ||
| def resolved_skills(self) -> list[ResolvedSkill]: | ||
| return list(self._skills_by_url.values()) | ||
|
|
||
| @property | ||
| def exceptions(self) -> list[InitializationException]: | ||
| return self._exceptions | ||
|
|
||
| @property | ||
| def current_pick_url(self) -> str | None: | ||
| """The pick on the message being answered, if this turn made one. | ||
|
|
||
| Recorded here rather than re-parsed from the messages later, so the injector | ||
| does not care whether the scrub transformer has already run. | ||
| """ | ||
| return self._current_pick_url | ||
|
|
||
| def set_current_pick_url(self, url: str | None) -> None: | ||
| self._current_pick_url = url | ||
|
|
||
| def set_resolved_skills(self, skills: list[ResolvedSkill]) -> None: | ||
| with self._lock: | ||
| self._skills_by_url = {skill.url: _mark_user_selected(skill) for skill in skills} | ||
|
|
||
| def find_skill(self, url: str) -> ResolvedSkill | None: | ||
| """The skill resolved for *url*, or ``None`` if it failed or was over the cap.""" | ||
| return self._skills_by_url.get(url) | ||
|
|
||
| def append_exception(self, exception: SkillInitializationException) -> None: | ||
| with self._lock: | ||
| self._exceptions.append(exception) | ||
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,19 @@ | ||
| from pydantic import Field | ||
| from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
|
||
|
|
||
| class SkillInvocationSettings(BaseSettings): | ||
| """Operator-level limits for skills the user invokes from a message.""" | ||
|
|
||
| model_config = SettingsConfigDict() | ||
|
|
||
| max_skills: int = Field( | ||
| default=10, | ||
| gt=0, | ||
| description=( | ||
| "Maximum number of distinct picked skills resolved and listed per request " | ||
| "across the conversation, newest first. Each one adds a <skill> block to the " | ||
| "system prompt and one Core fetch on every turn." | ||
| ), | ||
| alias="SKILL_INVOCATION_MAX_SKILLS", | ||
| ) |
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.