Skip to content

Refactor code structure for improved readability and maintainability - #74

Merged
Iamsdt merged 1 commit into
mainfrom
cleanup2
Mar 31, 2026
Merged

Refactor code structure for improved readability and maintainability#74
Iamsdt merged 1 commit into
mainfrom
cleanup2

Conversation

@Iamsdt

@Iamsdt Iamsdt commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and refactorings to the skill discovery and validation logic in the codebase, as well as a minor fix to embedding dimension handling and a small code style update. The most significant changes involve refactoring skill metadata parsing into smaller helper functions for better maintainability and clarity, improving validation logic, and correcting the embedding dimension for a Google model.

Skill discovery and parsing refactor:

  • Refactored the discover_skills function in agentflow/skills/loader.py to delegate parsing and validation of each skill to a new _discover_skill helper, which uses additional helpers for extracting identity, metadata, triggers, resources, tags, and priority. This modularizes the logic, improves readability, and makes the code easier to maintain. [1] [2]
  • Added new helper functions: _discover_skill, _extract_identity, _metadata_block, _normalize_text_list, _resolve_resources, _normalize_tags, _parse_priority, and _extract_frontmatter_yaml to encapsulate and clarify the parsing and validation of skill metadata.

Skill validation improvements:

  • Improved the SkillMeta model's field validators for triggers and resources in agentflow/skills/models.py to use more explicit variable names, ensure cleaned/stripped values, and provide clearer error handling for invalid or empty entries.

Embedding model fix:

  • Updated the default dimension for the "gemini-embedding-001" Google embedding model from 768 to 3072 in agentflow/store/embedding/google_embedding.py to reflect the correct dimensionality.

Minor code cleanup:

  • Removed an unnecessary # noqa: PLR0912 comment from the discover_skills function definition for better code style.

Bugfix in conversation state handling:

  • Changed the way a new message is appended to the context in agentflow/graph/utils/utils.py to use unpacking ([*existing_state.context, new_msg]) for clarity and consistency.

@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
agentflow/skills/loader.py 81.57% 9 Missing and 5 partials ⚠️
agentflow/graph/utils/utils.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Iamsdt
Iamsdt merged commit e2aee06 into main Mar 31, 2026
2 checks passed
@Iamsdt
Iamsdt deleted the cleanup2 branch March 31, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant