Skip to content

Conversation

@mathpirate
Copy link
Contributor

@mathpirate mathpirate commented Oct 28, 2025

Fixes CT-1006: "Error: Unexpected CommonTools type: Stream" when building patterns with llm() function.

The issue occurred when Stream types were wrapped in nested OpaqueRef layers (e.g., Opaque<OpaqueRef<Stream>>). The schema generator's wrapper detection via typeNode worked, but getWrapperTypeInfo(type) failed due to complex union structure.

Solution: Added recursivelyUnwrapOpaqueRef() method that:

  • Reuses existing isOpaqueRefType() and extractOpaqueRefTypeArgument()
  • Recursively unwraps nested OpaqueRef layers in unions
  • Finds the base wrapper type (Cell/Stream/OpaqueRef)

Includes test fixture opaque-opaqueref-stream to verify the fix.


Summary by cubic

Fixes handling of Stream types wrapped in nested OpaqueRef layers in the schema generator. Resolves CT-1006 so patterns using llm() build without the “Unexpected CommonTools type: Stream” error.

  • Bug Fixes
    • Added recursivelyUnwrapOpaqueRef to peel nested OpaqueRef layers in unions and find the base wrapper type (Cell/Stream/OpaqueRef) using existing helpers.
    • Correctly outputs Stream properties (asStream) even when wrapped as Opaque<OpaqueRef<...>>.
    • Added test fixture opaque-opaqueref-stream to verify the fix.

Fixes CT-1006: "Error: Unexpected CommonTools type: Stream" when building
patterns with llm() function.

The issue occurred when Stream types were wrapped in nested OpaqueRef layers
(e.g., Opaque<OpaqueRef<Stream<void>>>). The schema generator's wrapper
detection via typeNode worked, but getWrapperTypeInfo(type) failed due to
complex union structure.

Solution: Added recursivelyUnwrapOpaqueRef() method that:
- Reuses existing isOpaqueRefType() and extractOpaqueRefTypeArgument()
- Recursively unwraps nested OpaqueRef layers in unions
- Finds the base wrapper type (Cell/Stream/OpaqueRef)

Includes test fixture opaque-opaqueref-stream to verify the fix.
@linear
Copy link

linear bot commented Oct 28, 2025

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@mathpirate mathpirate merged commit 24a492d into main Oct 28, 2025
9 checks passed
@mathpirate mathpirate deleted the gideon/ct-1006-stream-type-support branch October 28, 2025 22:03
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.

3 participants