BoundaryML/baml · error
unsupported type: StreamState[any] cannot be passed as input
Error message
unsupported type: StreamState[any] cannot be passed as inputs to baml functions
What it means
shared.StreamState[any] is an internal streaming bookkeeping type produced by baml streaming calls; it is not a serializable input. encodeValue explicitly rejects it when it appears among baml function arguments.
Source
Thrown at engine/language_client_go/baml_go/serde/encode.go:129
Handle: handle,
},
}, nil
}
// Check for custom serializers first using the original value (could be pointer or value)
if serializer, ok := originalValue.(BamlSerializer); ok {
encoded, err := serializer.Encode()
if err != nil {
return nil, err
}
return encoded, nil
}
switch concreteValue.(type) {
case shared.Checked[any]:
return nil, fmt.Errorf("unsupported type: Checked[any] cannot be passed as inputs to baml functions")
case shared.StreamState[any]:
return nil, fmt.Errorf("unsupported type: StreamState[any] cannot be passed as inputs to baml functions")
}
// Handle primitive kinds and collections using reflection value rv (points to underlying value)
switch rv.Kind() {
case reflect.String:
return &cffi.HostValue{
Value: &cffi.HostValue_StringValue{
StringValue: rv.String(),
},
}, nil
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return &cffi.HostValue{
Value: &cffi.HostValue_IntValue{
IntValue: rv.Int(),
},
}, nil
View on GitHub (pinned to bd85ce9dee)
Solutions
- Extract the actual streamed value from the StreamState before passing it on
- Pass the concrete data (string/struct/slice) rather than the stream container
- Keep streaming state out of structs used as baml inputs
Example fix
// before state := stream.State // shared.StreamState[any] b.Next(ctx, state) // after b.Next(ctx, state.Value)
Defensive patterns
Strategy: type-guard
Validate before calling
func notStreamState(v any) bool { return !strings.Contains(reflect.TypeOf(v).String(), "StreamState") } Type guard
func isStreamState(v any) bool { return strings.Contains(reflect.TypeOf(v).String(), "StreamState") } Try / catch
if err := b.Fn(ctx, in); err != nil {
if strings.Contains(err.Error(), "StreamState[any] cannot be passed") { /* extract .Value and retry */ }
} Prevention
- Extract the current value from StreamState before forwarding data between calls
- Never store StreamState inside structs used as baml inputs
- Keep streaming bookkeeping separate from payload data
When it happens
Trigger: Passing the StreamState returned by a streaming baml call (or an object/field containing it) as an argument to another baml function; storing a streaming state inside a class field passed to baml.
Common situations: Chaining streaming calls; accidentally using the StreamState container instead of its current value; holding stream state in a shared struct that is later reused as input.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- unsupported type: Checked[any] cannot be passed as inputs to
- unsupported type for BAML encoding: %T (Kind: %s)
- failed to get text: %w
- {s:?}
- unexpected stream state
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/a632816b31d5f3cc.
Report an issue: GitHub.