Skip to content

fix(loader): use consistent key for retrieval tools in collect_classes#11

Closed
MicaPerdomo wants to merge 1 commit intocogsol:mainfrom
MicaPerdomo:fix/collect-classes-retrieval-tool-key
Closed

fix(loader): use consistent key for retrieval tools in collect_classes#11
MicaPerdomo wants to merge 1 commit intocogsol:mainfrom
MicaPerdomo:fix/collect-classes-retrieval-tool-key

Conversation

@MicaPerdomo
Copy link

Summary

collect_classes stores retrieval tool entries using obj.__name__ (e.g. "ProductDocsSearch"), but collect_definitions uses the explicit name attribute (e.g. "product_docs_search"). When the migration runner looks up classes by definition key, the mismatch causes "retrieval is required for retrieval tool" errors.

This changes collect_classes to use getattr(obj, "name", None) or obj.__name__ as the key, matching the logic already used in collect_definitions.

Changes

  • cogsol/core/loader.py: Use consistent key logic in collect_classes for retrieval tools (1 line → 2 lines)
  • tests/test_agents.py: Add 2 tests for explicit name keying and fallback behavior

Test plan

  • pytest — all tests pass (94 total, 2 new)
  • black --check . — no formatting changes
  • ruff check . — 0 errors
  • mypy cogsol — 0 issues

collect_classes stores retrieval tool entries using obj.__name__ (e.g.
"ProductDocsSearch"), but collect_definitions uses the explicit name
attribute (e.g. "product_docs_search"). When the migration runner looks
up classes by definition key, the mismatch causes "retrieval is required
for retrieval tool" errors.

Use getattr(obj, "name", None) or obj.__name__ as the key, matching
the logic already used in collect_definitions.
@MicaPerdomo
Copy link
Author

Closing — these changes are already included in #10.

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