Skip to content

Fix: to_gemini_tool to return types.Tool object. Fixes #223#229

Open
Areen-09 wants to merge 1 commit into
ARPAHLS:mainfrom
Areen-09:feat/issue-223-fix-gemini-tool
Open

Fix: to_gemini_tool to return types.Tool object. Fixes #223#229
Areen-09 wants to merge 1 commit into
ARPAHLS:mainfrom
Areen-09:feat/issue-223-fix-gemini-tool

Conversation

@Areen-09

@Areen-09 Areen-09 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR resolves an issue (#223) where SkillLoader.to_gemini_tool() was returning a plain dictionary instead of a proper types.Tool object. The google-genai SDK expects a types.Tool instance inside GenerateContentConfig(tools=...), which caused runtime failures when developers passed the output of to_gemini_tool() directly into their Gemini generation config, as shown in our documentation and some examples.

Changes introduced:

  • Framework (skillware/core/loader.py): SkillLoader.to_gemini_tool() now correctly imports google.genai and constructs/returns a types.Tool object instead of a raw dictionary.
  • Examples: Removed the manual types.Tool wrapping from all Gemini examples (gemini_uk_companies_house_handler.py, gemini_issue_resolver.py, etc.). Additionally, all Gemini examples now consistently use SkillLoader._sanitize_function_tool_name(bundle["manifest"]["name"]) for deriving tool names safely.
  • Tests (tests/test_loader.py): Updated the test assertions for test_to_gemini_tool to inspect the nested Protobuf structures of the types.Tool object (tool.function_declarations[0]).
  • Documentation: Updated docs/usage/gemini.md to clarify that to_gemini_tool() automatically handles this object instantiation for the developer.
  • Changelog: Added a Fixed entry under [Unreleased] detailing the framework breaking fix.

Type of Change (Matches Issue Templates)

  • Skill Proposal: New Skill (Contains manifest.yaml, skill.py, and instructions.md)
  • Bug Report Fix: Non-breaking change which fixes an execution error or framework bug
  • Doc Fix: Documentation Update
  • Framework Feature / RFC Updates: Core Framework Update (Changes to base_skill.py, loader.py, etc.)

Checklist (all PRs)

  • My code follows the Agent Code of Conduct.
  • I have run python -m flake8 ., pytest skills/ (or skillware test), and pytest tests/ locally (or the subset relevant to this change).
  • CHANGELOG.md updated under [Unreleased] if this PR changes user-visible behavior.
  • examples/README.md is updated if this PR adds, renames, or removes a runnable script under examples/.

Related Issues

Fixes #223

@rosspeili

Copy link
Copy Markdown
Contributor

Thanks @Areen-09, this is a solid fix.

LGTM on the loader + examples + tests. to_gemini_tool() returning types.Tool with sanitized names matches what google-genai expects, and the example dispatch updates look right. Tests pass locally.

Before merge:

  • Update Gemini snippets in docs/skills/issue_resolver.md, token_limiter.md, and uk_companies_house_handler.md, they still show manual types.Tool wrapping / dict mutation, which will break now that the loader returns types.Tool.
  • Fix docs/introduction.md, Gemini tool names are sanitized like OpenAI, not raw category/skill_name.
  • Maybe add a test_to_gemini_tool case for slash sanitization, note API return-type change under Changed in CHANGELOG.

Happy to merge once those doc bits are in, core work looks good. <3

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.

[Bug]: SkillLoader.to_gemini_tool() returns raw dict instead of types.Tool, breaking all Gemini examples

2 participants