Download the PHP package helgesverre/pagent without Composer
On this page you can find all versions of the php package helgesverre/pagent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download helgesverre/pagent
More information about helgesverre/pagent
Files in helgesverre/pagent
Package pagent
Short Description A Pest-inspired LLM Agent Framework for PHP with multi-provider support, automatic tool calling, safety guards, and multi-agent orchestration
License MIT
Homepage https://github.com/helgesverre/pagent
Informations about the package pagent
Pagent π©Έ
A Pest-inspired LLM Agent Framework for PHP
Build intelligent agents with automatic tool calling, multi-provider support, safety guards, and multi-agent orchestrationβall with a clean, fluent API.
Why Pagent?
- π§ͺ Pest-Inspired API - Fluent, expressive syntax that feels natural
- π Real-Time Streaming - SSE streaming for ChatGPT-like experiences
- πΎ Memory & Persistence - SQLite, File, and custom storage adapters
- π§ Automatic Tool Calling - JSON schema generation from PHP functions
- π€ Multi-Provider - Anthropic Claude, OpenAI GPT, Ollama (local), Mock (for testing)
- π‘οΈ Safety Guards - PII detection, content filtering, prompt injection prevention
- π Evaluation Framework - Test datasets with automated metrics and reports
- π Multi-Agent Orchestration - Pipeline, handoff, and delegation patterns
- π‘ Observability & Tracing - OpenTelemetry instrumentation with Jaeger, Zipkin, OTLP support
- β‘ Production Ready - 630+ tests, PHPStan level 9, PHP 8.3+ type safety
Installation
Requirements:
- PHP 8.3 or higher
- Composer 2.x
Quick Start
π Explore: Memory & Persistence
Providers
Mock Provider (for testing)
Anthropic (Claude)
OpenAI (GPT)
Ollama (Local LLMs)
Run models locally with complete privacy and zero API costs:
Benefits:
- π Complete privacy - all data stays local
- π° Zero API costs
- β‘ Low latency
- π οΈ Full tool calling support (qwen3, llama3.1, mistral)
- π‘ NDJSON streaming
π Full Guide: Ollama Integration
Agent Pattern
Agents provide a higher-level abstraction with conversation history:
Provider Configuration
Pagent supports two ways to configure providers:
String-Based (Simple)
Use provider names for quick setup with default configuration:
Instance-Based (Advanced)
Use helper functions or direct instantiation for custom configuration:
When to use each:
- String-based: Quick setup, standard configuration
- Instance-based: Custom config, multiple providers with same name, testing
Provider-Specific Features
The library is intentionally "leaky" - you can use provider-specific features:
Tool Calling
Define tools using PHP closures with automatic JSON schema generation:
Type hints are automatically converted to JSON schema types:
stringβ"string"intβ"integer"floatβ"number"boolβ"boolean"arrayβ"array"
Class-Based Tools
Pagent includes 9 production-ready class-based tools in the Pagent\Tools namespace:
Both closure-based and class-based tools implement ToolInterface and work seamlessly with all providers.
SearchTool - Full-Text Search
The SearchTool provides powerful full-text search capabilities powered by TNTSearch, enabling agents to search through documents, files, and databases:
Key Features:
- Multiple Document Sources: Arrays, files, directories, databases, or pre-built indexes
- Fuzzy Matching: Handles typos and approximate matches
- BM25 Ranking: Industry-standard relevance scoring
- Flexible Returns: Get just IDs or full document content
- Fast Performance: Sub-millisecond to millisecond search times
- UTF-8 Support: Works with international characters
Configuration Options:
Search Results:
Perfect for building:
- RAG (Retrieval-Augmented Generation) systems
- Documentation search agents
- Knowledge base assistants
- Semantic code search
- Content discovery tools
Observability & Distributed Tracing
Pagent includes comprehensive OpenTelemetry instrumentation for monitoring and debugging your LLM agents in production.
Quick Start
Production Monitoring
Connect to Jaeger, Zipkin, or any OpenTelemetry-compatible platform:
What Gets Traced
- Agent Operations - Every prompt, stream, and tool execution
- LLM Requests - Provider calls with token usage
- Tool Executions - Arguments, results, and duration
- Guard Checks - Security validations
- Memory Operations - Load/save operations
- Workflows - Multi-agent pipeline orchestration
Supported Platforms
- Jaeger - Open-source distributed tracing
- Zipkin - Distributed tracing system
- OTLP - Generic protocol (Datadog, New Relic, Honeycomb, etc.)
- Console - Local debugging output
Multi-Agent Workflow Tracing
Benefits
- Debug Complex Workflows - Visualize multi-agent interactions
- Performance Monitoring - Track latency and bottlenecks
- Token Usage Tracking - Real-time token consumption
- Cost Visibility - Understand API usage patterns
- Compliance - Complete audit trail
π Full Guide: Observability Documentation
Development
Quick Commands
Manual Testing
Documentation
The Complete Guide
The Pagent Guide is a comprehensive 28-chapter tutorial covering everything from basics to advanced patterns:
- Part 1: Foundations (Chapters 1-5) - Core concepts and basic usage
- Part 2: Tool Integration (Chapters 6-9) - External system interactions
- Part 3: Real-Time Interaction (Chapters 10-11) - Streaming responses
- Part 4: Persistence and State (Chapters 12-13) - Memory and conversations
- Part 5: Reliability and Safety (Chapters 14-15) - Production robustness
- Part 6: Multi-Agent Orchestration (Chapters 16-19) - Agent coordination
- Part 7: Quality Assurance (Chapters 20-21) - Testing and evaluation
- Part 8: Observability (Chapters 22-23) - Monitoring and debugging
- Part 9: Integration (Chapters 24-25) - Framework integration
- Part 10: Production Excellence (Chapters 26-28) - Optimization and deployment
See guide/README.md for learning paths based on your experience level.
Integration Guides
Learn how to integrate Pagent into your application:
- Vanilla PHP - Pure PHP integration without frameworks
- Slim Framework Integration - Complete Slim 4.x setup with DI and middleware
- Laravel Integration - Laravel setup with service providers and facades
- Symfony Integration - Symfony bundle integration with DI container
Feature Guides
Deep-dive into specific features:
- Streaming Guide - Real-time SSE streaming implementation
- Memory & Persistence - SQLite, File, and custom storage adapters
- Orchestration Workflows - Multi-agent patterns: pipelines, handoffs, delegation
See the docs/ folder for all guides.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for details on:
- Development setup
- Running tests
- Code style guidelines
- Pull request process
Read our Security Policy.
Changelog
See CHANGELOG.md for recent changes.
License
MIT License. See LICENSE for details.
Credits
Created by Helge Sverre.
Inspired by Pest's elegant API design.
All versions of pagent with dependencies
ext-curl Version *
guzzlehttp/guzzle Version ^7.10
nyholm/psr7 Version ^1.8
open-telemetry/api Version ^1.7
open-telemetry/exporter-otlp Version ^1.3
open-telemetry/sdk Version ^1.9
open-telemetry/sem-conv Version ^1.37
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/log Version ^3.0
swaggest/json-schema Version ^0.12.43
symfony/process Version ^7.3
teamtnt/tntsearch Version ^3.0