Skip to content

fix(skills): normalize load_skill_from_dir relative path resolution#4687

Open
pandego wants to merge 2 commits intogoogle:mainfrom
pandego:fix/4684-load-skill-dir-path
Open

fix(skills): normalize load_skill_from_dir relative path resolution#4687
pandego wants to merge 2 commits intogoogle:mainfrom
pandego:fix/4684-load-skill-dir-path

Conversation

@pandego
Copy link

@pandego pandego commented Mar 3, 2026

Closes #4684

Problem

load_skill_from_dir currently resolves relative paths from the current working directory only. In Agent Engine flows, code may execute from the agent directory while examples/path inputs include the agent directory prefix (for example my-agent/skills/my-skill), producing a duplicated segment and a missing directory error.

Solution

  • Add _resolve_skill_dir_path to normalize skill directory resolution for relative paths.
  • Support an agent-prefixed relative path when cwd is already the agent directory.
  • Reuse this resolver for load_skill_from_dir, validate_skill_dir, and read_skill_properties to keep behavior consistent.
  • Add a unit test covering the duplicate-prefix execution case.

Testing Plan

  • uv run pytest tests/unittests/skills/test__utils.py

Checklist

  • I have read CONTRIBUTING.md.
  • I have performed a self-review.
  • I have added tests that prove the fix is effective.
  • New and existing unit tests pass locally for touched scope.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue with skill directory path resolution where relative paths, especially those prefixed with an agent's name, could lead to incorrect or duplicated path segments when the execution environment's current working directory was already within the agent's scope. By introducing a dedicated path resolution utility, the changes ensure consistent and correct interpretation of skill directory paths, preventing "missing directory" errors and improving the robustness of skill loading and validation.

Highlights

  • Path Resolution Normalization: Introduced _resolve_skill_dir_path to consistently resolve relative skill directory paths, addressing issues where agent-prefixed paths caused errors when the current working directory was already the agent directory.
  • Consistent Path Handling: Integrated the new _resolve_dir_path function into _load_skill_from_dir, _validate_skill_dir, and _read_skill_properties to ensure uniform path resolution across skill-related operations.
  • Improved Test Coverage: Added a new unit test, test_load_skill_from_dir_resolves_duplicate_agent_prefix, to specifically cover the scenario of duplicate agent prefixes in relative paths, ensuring the fix is effective.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/skills/_utils.py
    • Added _resolve_skill_dir_path function to normalize skill directory path resolution.
    • Updated _load_skill_from_dir to use _resolve_skill_dir_path for consistent path handling.
    • Updated _validate_skill_dir to use _resolve_skill_dir_path for consistent path handling.
    • Updated _read_skill_properties to use _resolve_skill_dir_path for consistent path handling.
  • tests/unittests/skills/test__utils.py
    • Added test_load_skill_from_dir_resolves_duplicate_agent_prefix to verify correct relative path resolution.
Activity
  • The author has confirmed reading CONTRIBUTING.md.
  • A self-review of the changes has been performed by the author.
  • New tests have been added to validate the effectiveness of the fix.
  • Existing and new unit tests within the touched scope are passing locally.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Mar 3, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fix for relative path resolution when loading skills, specifically addressing issues with duplicated path segments. The new _resolve_skill_dir_path function is a good approach to centralize this logic. However, I've identified a potential correctness issue in the order of path candidate evaluation and a potentially risky check that could lead to incorrect path resolution in some edge cases. My feedback includes a suggestion to make the path resolution logic safer and more predictable.

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

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path Inconsistency for load_skill_from_dir between adk web and Agent Engine Deployment

2 participants