Skip to main content

Release Notes

Executive Summary

This release represents a major architectural milestone for the instructor-php monorepo, introducing the new stream package for functional data processing and significantly refactoring the instructor package’s streaming architecture. The changes focus on modularity, composability, and maintainability while improving type safety across all packages.
  • New stream package: Complete functional stream processing library with 24+ sources, 40+ transducers, and 20+ reducers
  • Major instructor refactoring: Streaming architecture completely redesigned for modularity and testability
  • Better code organization: Logical namespace restructuring across multiple packages
  • Enhanced utilities: New data structures (Deque, Buffer, RingBuffer) and error collection system
  • Type safety improvements: Better PHPDoc annotations and flexible type hints

instructor Package

  • Replaced PartialsGenerator with modular components:
    • Use GeneratePartialsFromJson for JSON streaming mode
    • Use GeneratePartialsFromToolCalls for tool-based streaming mode
  • Method rename: CanGeneratePartials::getPartialResponses()makePartialResponses()
  • Moved classes to new namespaces (aliases may be provided for backward compatibility):
    • Core/ResponseModelFactoryCreation/ResponseModelFactory
    • Core/StructuredOutput*Creation/StructuredOutput*
    • Core/SequenceableHandlerStreaming/SequenceGen/SequenceableEmitter

stream Package

A complete functional stream processing library implementing transducers:
  • 24+ Stream Sources: Array, CSV, JSON, JSONL, HTTP, Filesystem, Text processing
  • 40+ Transducers: Transform, filter, flatten, group, limit, combine, deduplicate
  • 20+ Reducers: Terminal operations for stats, selection, side effects
  • Tee Splitting: Process same source through multiple parallel pipelines
  • Result Monad Support: Functional error handling with dedicated transducers/reducers
  • Progressive Rendering: Iterator-based execution for memory-efficient streaming

utils Package

  • Deque and Circular Buffer data structures
  • Immutable error collection system with serialization
  • New Arrays operations for merging multiple arrays

polyglot Package

  • Inference/Creation/: Factory and builder classes
  • Inference/Streaming/: Stream processing with new ContentAccumulation class
  • Optimized InferenceExecution::errors() using Arrays::mergeMany()
  • Refactored InferenceStream::makePartialResponses() with extracted methods

http-client Package

  • Simplified Symfony driver
  • Added annotations to streaming methods

addons Package

Type Flexibility:
  • Relaxed StepByStep return types from Generator<mixed, TState, mixed, mixed> to iterable<TState>
  • Allows implementations to return any iterable type while maintaining type safety
I