Skip to content

Handle typing generics in skill API method annotations - #571

Merged
NeonDaniel merged 1 commit into
NeonGeckoCom:devfrom
OscillateLabsLLC:fix/api-method-generic-annotations
Sep 25, 2026
Merged

NeonDaniel merged 1 commit into
NeonGeckoCom:devfrom
OscillateLabsLLC:fix/api-method-generic-annotations

Conversation

@mikejgray

Copy link
Copy Markdown
Contributor

Description

NeonSkill._register_public_api calls issubclass() on each API method's parameter and return annotations. Typing generics such as Optional[str], List[str], or dict[str, str] are not classes, so issubclass raises TypeError. The error is not caught (only ImportError is), so the whole skill fails to initialize:

neon_skill.py:291  issubclass(signature.return_annotation, BaseModel)
TypeError: issubclass() arg 1 must be a class
ERROR - Skill initialization failed

The fix checks that an annotation is a class before issubclass, for both parameters and return values. Methods typed with pydantic models behave the same as before.

Tests added to tests/neon_skill_tests.py:

  • test_typed_api_method: <skill_id>.public_api publishes the request and response JSON schemas, and JSON kwargs from the bus arrive as the request model.
  • test_generic_annotations: regression test. A method with Optional[str] parameter and return initializes, publishes no schemas, and is callable. Fails on current dev with the TypeError above; passes with this change.

Issues

None filed. Found while evaluating the typed skill API (as used in skill-date_time) for exposing skill methods as LLM tools.

Other Notes

Locally, 6 existing tests in neon_skill_tests.py fail with OSError: File name too long from combo_lock on macOS with a long checkout path. They fail the same way on clean dev and are unrelated to this change.

_register_public_api called issubclass() on every parameter and return
annotation. Typing generics such as Optional[str] are not classes, so
issubclass raised TypeError and the whole skill failed to initialize.
Only check annotations that are classes.

Adds tests for the typed public API (published schemas, kwargs coerced
into the request model) and a regression test for generic annotations.
@mikejgray
mikejgray force-pushed the fix/api-method-generic-annotations branch from 5b2446d to 3a0ffe9 Compare September 25, 2026 21:01
@NeonDaniel
NeonDaniel merged commit 000969f into NeonGeckoCom:dev Sep 25, 2026
10 checks passed
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.

2 participants