Skip to content

feat!: unify prompts and skills into shared templates and registry#20

Open
SalemBajjali wants to merge 34 commits into
mainfrom
issue-17
Open

feat!: unify prompts and skills into shared templates and registry#20
SalemBajjali wants to merge 34 commits into
mainfrom
issue-17

Conversation

@SalemBajjali

Copy link
Copy Markdown
Contributor

Closes #17

This PR addresses the structural changes discussed in #17.

Changes

Templates

  • Created a unified templates/ directory
  • Moved prompts/base.py into templates/ and renamed BasePromptTemplate to BaseTemplate
  • Moved skills/base.py into templates/ as skill_template.py and renamed BaseSkillTemplate to SkillTemplate
  • SkillTemplate now inherits from BaseTemplate sharing the same structure

Registry

  • Replaced separate PromptRegistry and SkillRegistry with a single Registry that handles both prompts and skills

StructuredTaskRunner

  • Simplified with a unified _execute() method
  • execute_skill() and execute_prompt() are now thin wrappers around _execute()

Tests

  • Updated unit and integration tests to reflect new templates and registry structure
  • Updated skill tests to use semantic versioning format (0.1.0)

Notebooks

  • Updated example notebook to reflect new structure

SalemBajjali and others added 28 commits June 4, 2026 09:57
@SalemBajjali SalemBajjali self-assigned this Jun 23, 2026
@SalemBajjali SalemBajjali requested a review from a team as a code owner June 23, 2026 20:39

@korikuzma korikuzma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review - also I think we need to change the PR title since it is a breaking change. refactor -> feat!:

See https://www.conventionalcommits.org/en/v1.0.0/

Will do a deep dive later this week

Comment thread src/wags_llm/registry/__init__.py Outdated
Comment thread src/wags_llm/registry/base.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should think about the case where PromptTemplate and SkillTemplate share the same name/version. Currently, one would overwrite the other in the registry. We should consider adding a template_type optional parameter to help distinguish which to use (if this is valid use case) or raise ValueError if name/version already exists in the registry (if this is invalid use case)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I updated the registry to include task_type as part of the registry key, so templates are now stored by (name, version, task_type) instead of just (name, version).
  • This allows a PromptTemplate and SkillTemplate to share the same name/version without overwriting each other. The registry determines the task type internally during registration based on the template instance, and get() now requires the task type so retrieval is explicit.
  • I also added a duplicate check so registering the same (name, version, task_type) combination raises a ValueError instead of silently replacing the existing template.
  • I added tests to cover both behaviors: one test confirms that a prompt and skill can share the same name/version, and another confirms that registering a duplicate skill with the same name/version raises a ValueError.
  • NOTE: I noticed the registry tests may be a bit scattered, such as test_registry.py and test_skill_registry.py. We may want to combine them or move them under a dedicated registry test folder. I can open a separate issue for this or update it directly in this PR if preferred.

Comment thread src/wags_llm/services/structured_task.py Outdated
@SalemBajjali SalemBajjali changed the title refactor: unify prompts and skills into shared templates and registry feat!: unify prompts and skills into shared templates and registry Jun 24, 2026

@korikuzma korikuzma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked about this yesterday, but posting in GH too:

  • Need to pull in changes from main branch, update the skills nb
  • Proposals for registry name/version conflict

MAX_LOG_CHARS = int(getenv("MAX_LOG_CHARS", "500"))


class TaskKind(Enum):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be my preference

Suggested change
class TaskKind(Enum):
class TaskType(Enum):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts of changing the attribute name from kind to type as well in _execute?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, just add a prefix

mcannon068nw
mcannon068nw previously approved these changes Jun 25, 2026

@mcannon068nw mcannon068nw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

_logger = logging.getLogger(__name__)


class TaskType(Enum):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this more... I change my mind and think we should rename task type to template type. The registry doesn't need to care about tasks and is only concerned with templates.

Suggested change
class TaskType(Enum):
class TemplateType(Enum):

This leads into a larger change that I think would clean this up.

  • Move TemplateType enum to templates/base.py
  • Change the current PromptTemplate to BaseTemplate, with a new class variable (template_class: ClassVar[TemplateType])
  • Create new module for PromptTemplate (templates/prompt_template.py), which would only include:
class PromptTemplate(BaseTemplate):
    template_type = TemplateType.PROMPT
  • Update SkillTemplate to follow similar approach to PromptTemplate (inherit from BaseTemplate and include new template_type class var)
  • Then in here (registry), we could do the following:
_TEMPLATE_CLASS_TO_TYPE = MappingProxyType({
    SkillTemplate: TemplateType.SKILL,
    PromptTemplate: TemplateType.PROMPT,
})

Then in the register method, we could do the following

try:
    template_type = _TEMPLATE_CLASS_TO_TYPE[type(template)]
except KeyError:
    msg = f"Unsupported template type: {type(template)}"
    raise TypeError(msg) from None

and remove the helper method

task_type.value,
)

if key in self._templates:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Update docstring with this error please

import re
from collections.abc import Mapping

# NEW

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Suggested change
# NEW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create ABC for Template and Registry

3 participants