Download the PHP package claude-php/agent without Composer
On this page you can find all versions of the php package claude-php/agent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download claude-php/agent
More information about claude-php/agent
Files in claude-php/agent
Package agent
Short Description A powerful PHP framework for building AI agents with Claude, featuring ReAct loops, tool orchestration, and advanced agentic patterns
License MIT
Homepage https://github.com/claude-php/agent
Informations about the package agent
Claude PHP Agent Framework
A powerful PHP framework for building AI agents with Claude, featuring ReAct loops, tool orchestration, hierarchical agents, and advanced agentic patterns.
Features
- ๐ Loop Strategies - ReactLoop, PlanExecuteLoop, ReflectionLoop, and StreamingLoop
- ๐ Streaming Flow Execution - Real-time token streaming with event broadcasting
- ๐จ Template System - 22+ starter templates with instant instantiation
- ๐ฏ Error Handling Service - User-friendly error messages for all API errors (NEW!)
- ๐ ๏ธ Tool System - Easy tool definition, registration, and execution
- ๐ง Memory Management - Persistent state across agent iterations
- ๐๏ธ Agent Patterns - ReAct, Plan-Execute, Reflection, Hierarchical, and more
- ๐ค Adaptive Agent Service - Intelligent agent selection, validation, and auto-adaptation
- ๐ Output Parsers - JSON, XML, Markdown, CSV, Lists, and Regex with auto-detection
- ๐ Chain Composition - Sequential, parallel, and conditional chain execution
- โก Production Ready - Retry logic, error handling, logging, and monitoring
- ๐ Async/Concurrent - AMPHP-powered parallel execution for batch operations
- ๐ MCP Server - Model Context Protocol integration for Claude Desktop and IDEs
- ๐ฏ Extensible - Build custom agents and patterns with ease
- ๐ Component Validation - Runtime validation by instantiation (v0.8.0)
- ๐ข Services System - Enterprise service management with dependency injection (v0.7.0)
- ๐งช Code Generation - AI-powered code generation with validation pipelines (v0.8.0)
Installation
Quick Start
Real-Time Streaming Flow Execution ๐
NEW! Stream agent execution with token-by-token LLM responses, progress tracking, and event broadcasting:
Features:
- ๐ฏ Token-by-token LLM responses
- ๐ Real-time progress tracking
- ๐ง Tool execution events
- ๐ก SSE support for web apps
- ๐ช Multiple listener broadcasting
- โก Generator-based streaming
๐ Examples
Error Handling Service
Convert technical API errors into user-friendly messages. Inspired by Langflow's error handling approach:
Error Pattern Coverage:
- Rate limits โ "Rate limit exceeded. Please wait before retrying."
- Auth errors โ "Authentication failed. Please check your API key."
- Timeouts โ "Request timed out. Please try again."
- Connection โ "Connection error. Check your network."
- 9 default patterns + custom pattern support
Features:
- ๐ฏ User-friendly messages for all Claude API errors
- ๐ Smart retry logic with exponential backoff
- ๐ Detailed error context for debugging
- โ๏ธ Configurable patterns (defaults + custom)
- ๐ข Service layer integration
- ๐ ๏ธ Safe tool execution helpers
๐ Examples
Template/Starter Project System
The framework includes a comprehensive template system with 22+ ready-to-use agent configurations:
Quick Start
Available Templates (22+)
Basic Agents (5): Basic Agent, ReAct, Chain-of-Thought, Reflex, Model-Based
Advanced Agents (5): Reflection, Plan-Execute, Tree-of-Thoughts, MAKER, Adaptive
Specialized (5): Hierarchical, Coordinator, Dialog, Intent Classifier, Monitoring
RAG & Knowledge (3): RAG Agent, Memory Chatbot, Knowledge Manager
Workflows (2): Sequential Tasks, Debate System
Production (2): Production Agent, Async Batch Processor
Features
- ๐ Advanced Search - Find templates by name, tags, category, or difficulty
- ๐ฆ Instant Instantiation - Create agents with one line of code
- ๐พ Custom Templates - Export your agents as reusable templates
- ๐ท๏ธ Smart Organization - 6 categories, 30+ tags, 3 difficulty levels
- ๐ Rich Metadata - Use cases, requirements, setup time, and more
๐ Creating Templates
Progress Updates (Legacy)
You can also receive progress events via onUpdate():
MCP Server Integration
The framework includes a full Model Context Protocol (MCP) server that exposes agent capabilities to MCP clients like Claude Desktop, IDEs, and other AI tools.
Quick Start
Features
- 15 MCP Tools - Agent discovery, execution, visualization, and configuration
- Dual Transport - STDIO for Claude Desktop, SSE for web clients
- Agent Discovery - Search and explore 16+ agent types
- Workflow Visualization - ASCII art diagrams and JSON graphs
- Real-time Execution - Run agents directly through MCP
- Session Management - Isolated per-client sessions with memory
Available Tools
Agent Discovery: search_agents, list_agent_types, get_agent_details, count_agents
Execution: run_agent, get_execution_status
Tool Management: list_tools, search_tools, get_tool_details
Visualization: visualize_workflow, get_agent_graph, export_agent_config
Configuration: update_agent_config, create_agent_instance, validate_agent_config
๐ Full MCP Documentation
Core Concepts
Loop Strategies
The framework provides multiple loop strategies for different types of tasks:
ReactLoop (Default)
The Reason-Act-Observe pattern for general-purpose tasks:
PlanExecuteLoop
Plan first, then execute systematically for complex multi-step tasks:
ReflectionLoop
Generate, reflect, and refine for high-quality outputs:
See the Loop Strategies Guide for detailed documentation.
Tools
Tools give Claude the ability to interact with the world:
Agent Patterns
Basic ReAct Agent
Hierarchical Agent (Master-Worker)
Reflection Agent
Memory & State
Production Features
MAKER Agent (Massively Decomposed Agentic Processes)
โก NEW: Solve million-step tasks with near-zero error rates!
Key Features:
- โ Extreme task decomposition into atomic subtasks
- โ Multi-agent voting for error correction at each step
- โ Red-flagging to detect and retry unreliable responses
- โ Scales to organization-level tasks (millions of steps)
- โ Sub-linear cost scaling with proper decomposition
Paper Results: Successfully solved 20-disk Towers of Hanoi (1,048,575 moves) with ZERO errors!
See MakerAgent Documentation for detailed documentation.
Adaptive Agent Service
๐ฏ NEW: Intelligent agent selection with automatic validation and adaptation!
Key Features:
- โ Intelligent agent selection based on task analysis
- โ Automatic quality validation and scoring
- โ Adaptive retry with different agents on failure
- โ Request reframing for better results
- โ Performance tracking and learning
See docs/adaptive-agent-service.md for detailed documentation.
Agent Patterns Reference
| Pattern | Use Case | Scalability | Example |
|---|---|---|---|
| ReAct | General-purpose autonomous tasks | ~100 steps | Research, calculations, data processing |
| Plan-Execute | Complex multi-step tasks | ~1K steps | Project planning, workflows |
| Reflection | Quality-critical outputs | ~500 steps | Code generation, writing |
| Hierarchical | Multi-domain tasks | ~5K steps | Business analysis, reports |
| Chain-of-Thought | Complex reasoning | ~500 steps | Math problems, logic puzzles |
| Tree-of-Thoughts | Exploration tasks | ~1K steps | Creative writing, optimization |
| MAKER/MDAP | Million-step tasks, zero errors | Millions+ | Long sequences, organization-level tasks |
| Monitoring | System monitoring, anomaly detection | Real-time | Server metrics, performance tracking |
| Scheduler | Task scheduling, cron jobs | Continuous | Automated workflows, batch processing |
| Alert | Intelligent alerting, notifications | Real-time | System alerts, incident management |
| Reflex | Rule-based responses | Instant | FAQs, simple automation |
| Model-Based | State-aware decision making | ~500 steps | Planning, simulation |
| Utility-Based | Optimization, trade-offs | ~100 steps | Resource allocation, decision support |
| Learning | Adaptive behavior, feedback loops | Continuous | Personalization, strategy evolution |
| Collaboration | Multi-agent coordination (AutoGen) | ~5K steps | Team workflows, complex research |
| TaskPrioritization | Goal-driven task management (BabyAGI) | ~1K steps | Project breakdown, execution |
| Coordinator | Agent orchestration, load balancing | ~10K steps | Distributed systems, agent networks |
| Dialog | Conversational AI, context tracking | Continuous | Customer service, assistants |
| IntentClassifier | Intent recognition, entity extraction | Instant | Command routing, NLU |
| EnvironmentSimulator | What-if analysis, prediction | ~100 steps | Testing, planning |
| SolutionDiscriminator | Solution evaluation, voting | ~50 steps | Quality assurance, selection |
| MemoryManager | Knowledge management, retrieval | Continuous | Shared memory, context |
| AdaptiveAgentService | Meta-agent selection & validation | Varies | Auto-optimization, quality assurance |
Configuration
Streaming Flow Execution ๐
NEW! Real-time streaming flow execution with comprehensive event management, inspired by Langflow's architecture.
Features
- Token-by-Token Streaming - Real-time LLM responses as they're generated
- Progress Tracking - Detailed execution progress with time estimates
- Event Broadcasting - Multiple subscribers with one-to-many pattern
- SSE Support - Server-Sent Events for web applications
- Queue-Based - Non-blocking event emission with configurable limits
- Langflow Compatible - Compatible event types and patterns
Quick Example
SSE Streaming for Web Apps
JavaScript Client:
Multiple Listeners
Available Event Types
Flow Lifecycle: flow.started, flow.completed, flow.failed
Token Streaming: token.received, token.chunk
Iterations: iteration.started, iteration.completed, iteration.failed
Tools: tool.started, tool.completed, tool.failed
Progress: progress.update, step.started, step.completed
Errors: error, warning, info
Documentation
- ๐ Complete Guide - Architecture, usage, and best practices
- ๐ Event Reference - All 25+ event types documented
- ๐ฏ Streaming Patterns - Advanced patterns and SSE implementation
- ๐ก Examples - 4 comprehensive working examples
Architecture
The system adapts Python's async patterns to PHP:
| Python (Langflow) | PHP (claude-php-agent) |
|---|---|
async/await |
Generator/yield |
asyncio.Queue |
SplQueue |
| Async subscribers | Iterator pattern |
async for |
foreach with Generator |
Async & Concurrent Execution
The framework leverages AMPHP for true asynchronous and concurrent execution:
Batch Processing
Process multiple agent tasks concurrently:
Parallel Tool Execution
Execute multiple tool calls simultaneously:
Promise-Based Workflows
Use promises for async operations:
See the examples directory for complete async/concurrent examples.
Output Parsers
Transform unstructured LLM responses into structured data:
Available Parsers:
- JsonParser - Extract and validate JSON
- ListParser - Parse bullet/numbered lists
- RegexParser - Pattern-based extraction
- XmlParser - Parse XML/HTML
- MarkdownParser - Extract structured markdown
- CsvParser - Parse CSV/TSV data
- ParserFactory - Auto-detection and convenience methods
See Parsers Documentation for complete guide.
Examples
See the examples directory for 110+ complete working examples including:
Core Examples (70+ files):
- Basic ReAct agents and multi-tool usage
- Hierarchical agent systems (master-worker pattern)
- Reflection agents for self-improvement
- Production-ready agent setups with error handling
- Adaptive agent service with intelligent selection
- Async/concurrent execution with AMPHP
- MAKER framework for million-step reliable tasks
- Output parsers for structured data extraction
- Chain composition patterns
๐ Tutorial Examples (42 files in examples/tutorials/):
- Component validation patterns (7 examples)
- Services system usage (7 examples)
- MCP server integration (7 examples)
- Code generation workflows (7 examples)
- Production deployment patterns (7 examples)
- Testing strategies (7 examples)
๐ Streaming Flow Execution (4 examples in examples/Execution/):
basic-streaming.php- Token streaming with event handlingprogress-tracking.php- Real-time progress monitoringmultiple-listeners.php- Event broadcasting patternsse-server.php- Complete SSE endpoint with HTML client
๐ก All examples are fully runnable:
php examples/Execution/basic-streaming.php
Documentation
๐ Getting Started
New to AI agents? Start with our comprehensive tutorial series:
- ๐ Getting Started Tutorials - Complete beginner-friendly series
- Tutorial 0: Introduction to Agentic AI
- Tutorial 1: Your First Agent
- Tutorial 2: ReAct Loop Basics
- Tutorial 3: Multi-Tool Agent
- Tutorial 4: Production-Ready Patterns
- Tutorial 5: Advanced Patterns
๐ New Features Tutorials (v0.7.0 - v0.9.0)
Master the latest framework capabilities:
- ๐ Streaming Flow Execution - Real-time streaming with event management (NEW!)
- ๐ Component Validation - Runtime validation by instantiation (45min)
- ๐ข Services System - Enterprise service management (50min)
- ๐ MCP Server Integration - Connect to Claude Desktop (55min)
- ๐งช Code Generation - AI-powered code generation (50min)
- ๐ Production Patterns - Production deployment (60min)
- โ Testing Strategies - Comprehensive testing (55min)
๐ก 46 runnable examples included - Each feature comes with working code samples!
๐ Complete Documentation
- Quick Start Guide - Get started in 5 minutes
- ๐ Streaming Flow Execution - Real-time streaming guide
- Event Reference - All event types
- Streaming Patterns - SSE & patterns
- ๐ฏ Error Handling Service - User-friendly error messages (NEW!)
- Tutorial - Complete 6-part tutorial
- Documentation Index - Complete guide to all features
- All Tutorials - 17+ comprehensive tutorials with examples
- Loop Strategies - Understanding agent loops
- Agent Selection Guide - Choose the right pattern
- Best Practices Guide - Production-ready patterns
- MCP Server Integration - Claude Desktop connectivity
- Component Validation - Runtime validation guide
- Services System - Enterprise service management
- Examples - 79+ working code examples + 55 tutorial examples
Requirements
- PHP 8.1, 8.2, or 8.3
- Composer
- claude-php/claude-php-sdk
Installation
For detailed setup instructions, see QUICKSTART.md.
Contributing
We welcome contributions! Please see:
- CONTRIBUTING.md - Contribution guidelines
- SECURITY.md - Security policy
- CHANGELOG.md - Version history
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs/
License
MIT License - see LICENSE for details.
What's New
v1.3.0 (Latest)
- โจ Error Handling Service - User-friendly error messages for all API errors (HIGH PRIORITY)
- 9 default error patterns for common API errors
- Custom pattern support with override capability
- Full service layer integration
- Comprehensive retry logic and tool helpers
- ๐ New tutorial: Complete 6-part Error Handling tutorial
- ๐ 9 new examples with real API testing
- ๐ง Deprecated old ErrorHandler with migration guide
v0.8.0
- โจ Component Validation Service - Runtime validation by instantiation
- โจ Code Generation Agent - AI-powered code generation with validation
- ๐ New tutorials: Component Validation, Code Generation, Production Patterns, Testing Strategies
- ๐ 42 new tutorial examples in
examples/tutorials/
v0.7.0
- โจ Services System - Enterprise service management with dependency injection
- โจ MCP Server - Model Context Protocol integration for Claude Desktop
- ๐ New tutorials: Services System, MCP Server Integration
- ๐ง Enhanced observability and monitoring
See CHANGELOG.md for complete version history.
Acknowledgments
Built with โค๏ธ using Claude PHP SDK and inspired by the latest research in AI agents and LLM orchestration.
All versions of agent with dependencies
claude-php/claude-php-sdk Version ^0.5
psr/log Version ^3.0
php-mcp/server Version ^1.0
php-mcp/schema Version ^1.0
react/event-loop Version ^1.5
react/stream Version ^1.4