Skip to content

v1.1.0 - Streaming Flow Execution System 🌊

Choose a tag to compare

@dalehurley dalehurley released this 03 Feb 21:00
· 16 commits to master since this release

v1.1.0 - Streaming Flow Execution System 🌊

Major feature release bringing real-time streaming flow execution to claude-php-agent, inspired by Langflow's sophisticated event-driven architecture.

🌟 Highlights

  • Real-Time Streaming: Token-by-token LLM responses as they're generated
  • Event-Driven Architecture: Queue-based event management with 25+ event types
  • Progress Tracking: Detailed execution progress with time estimation
  • Multi-Listener Broadcasting: One-to-many event distribution
  • SSE Support: Server-Sent Events for web applications
  • Production Ready: 42 tests, 9/9 real API tests passing

🎯 Key Features

Core Components

  • EventQueue - FIFO event queue based on SplQueue

    • Configurable max size (default: 100)
    • Overflow tracking
    • Statistics and utilization metrics
  • FlowEvent - Comprehensive event system

    • 25+ event types (flow, token, iteration, tool, progress, error)
    • SSE/JSON/Array output formats
    • Type checking helpers
    • Langflow-compatible events
  • FlowEventManager - Advanced event management

    • Event registration with callbacks
    • Queue-based non-blocking emission
    • Multiple listener support
    • Magic method emission
  • FlowProgress - Real-time progress tracking

    • Iteration and step tracking
    • Duration measurement
    • Time remaining estimation
    • Metadata support
  • StreamingFlowExecutor - Main execution engine

    • Generator-based streaming
    • Token-by-token output
    • SSE streaming support
    • Blocking execution option

Service Integration

  • New ServiceType::FLOW_EXECUTOR service
  • New ServiceType::EVENT_MANAGER service
  • Automatic dependency injection
  • Full ServiceManager integration

Enhanced StreamingLoop

  • Optional FlowEventManager integration
  • Automatic event emission
  • Backward compatible (opt-in)

πŸ“š Documentation

Comprehensive documentation (2,800+ lines):

πŸ’‘ Examples

Tutorial Series (100 minutes, 7 examples):

  • Basic streaming
  • Progress tracking
  • Event listeners
  • SSE streaming
  • Custom events
  • Error handling
  • Full integration

Advanced Examples (4 files):

  • Production streaming patterns
  • Progress monitoring
  • Multi-listener broadcasting
  • SSE server with HTML client

All examples tested with real Claude API βœ…

πŸ§ͺ Testing

  • Unit Tests: 42 methods (100% passing)
  • Real API Tests: 9/9 examples working
  • Integration Tests: 12 scenarios verified
  • Code Verification: 100+ samples

πŸš€ Quick Start

```php
use ClaudeAgents\Services\ServiceManager;
use ClaudeAgents\Services\ServiceType;

$executor = ServiceManager::getInstance()->get(ServiceType::FLOW_EXECUTOR);

foreach ($executor->executeWithStreaming($agent, $task) as $event) {
match ($event['type']) {
'token' => print($event['data']['token']),
'progress' => printf("%.1f%%\n", $event['data']['progress_percent']),
'end' => print("Done!\n"),
default => null
};
}
```

πŸŽ“ Tutorial

```bash

Run the tutorial series

cd examples/tutorials/streaming-flow
php 01-basic-streaming.php
php 02-progress-tracking.php

... through 07-integration.php

```

πŸ—οΈ Architecture

Adapts Python patterns to PHP:

Python (Langflow) PHP (claude-php-agent)
async/await Generator/yield
asyncio.Queue SplQueue
Async subscribers Observer pattern

πŸ“Š Statistics

  • Files: 35 created/modified
  • Code: ~8,500 lines
    • Core: ~3,500 lines
    • Examples: ~1,600 lines
    • Tests: ~800 lines
    • Docs: ~2,600 lines

πŸ”„ Backward Compatibility

Fully backward compatible - all existing code continues to work. Streaming features are opt-in.

πŸ™ Acknowledgments

Inspired by Langflow's excellent event-driven architecture.


Full Changelog: https://github.com/claude-php/claude-php-agent/blob/master/CHANGELOG.md