chen-zhanjie/hyperf-agentic
Composer 安装命令:
composer require chen-zhanjie/hyperf-agentic
包简介
Hyperf-native AI Agent SDK — config-driven, Hermes-inspired
README 文档
README
简体中文 | English
A config-driven AI Agent SDK for Hyperf applications. Agent is a config, not a class.
Installation
composer require chen-zhanjie/hyperf-agentic
Publish config files:
php bin/hyperf.php vendor:publish chenzhanjie/hyperf-agentic
Quick Start
1. Configure LLM Provider
Edit config/autoload/agentic/providers.php:
return [ 'default' => 'openai', 'providers' => [ 'openai' => [ 'protocol' => 'openai', 'api_key' => env('OPENAI_API_KEY'), 'base_url' => 'https://api.openai.com/v1', 'model' => 'gpt-4o', ], ], ];
2. Define an Agent
Edit config/autoload/agentic/agents.php:
return [ 'general' => [ 'persona' => 'You are a helpful assistant.', 'max_iterations' => 10, ], ];
3. Run the Agent
use ChenZhanjie\Agentic\Agentic; $agentic = $this->container->get(Agentic::class); $result = $agentic->run('general', [ ['role' => 'user', 'content' => 'Hello!'], ]); echo $result->content;
Database-Driven Agents (v0.4.0)
Create agents dynamically from database config:
use ChenZhanjie\Agentic\Persona\Persona; $result = $agentic->runWithConfig( [ 'persona' => new Persona(name: 'Expert', content: 'You are an expert.'), 'tools' => ['search'], 'skills' => ['search-guide'], 'max_iterations' => 15, ], [['role' => 'user', 'content' => 'Hello']], ['conversation_id' => 'conv-123'], // auto history management );
Core API
| Method | Description |
|---|---|
run(name, messages) |
Execute a named agent |
runStream(name, messages, onEvent) |
Execute with SSE streaming |
runWithConfig(config, messages, options) |
Execute with dynamic config |
runStreamWithConfig(config, messages, onEvent, options) |
Dynamic config + streaming |
chat(messages) |
Pure LLM chat (no tools) |
chatStream(messages, onChunk) |
Pure LLM streaming |
resume(sessionId) |
Resume a suspended session |
approveTool(tool, sessionId) |
Approve a tool/pattern globally or per-session |
approveAll(sessionId) |
Approve all tools globally or per-session |
revokeTool(tool, sessionId) |
Revoke a tool approval |
revokeAll(sessionId) |
Revoke all approvals |
Documentation
| Document | Description |
|---|---|
| Getting Started | Installation and quick start |
| Configuration | Full configuration reference |
| API Reference | Agentic facade method reference |
| Tools | Tool system: registration, custom tools, built-ins |
| Skills | 3-level progressive disclosure skill system |
| Guardrails | Input/output safety checks |
| Conversations | Multi-turn conversation persistence |
| Database Agents | Database-driven dynamic agent creation |
| Architecture | 5-layer architecture overview |
| Changelog | Version history |
简体中文文档:docs/zh-CN/
Architecture
Layer 5: Entry Points (Controller / Command / CLI)
↓
Layer 4: Agentic Facade (config-driven entry point)
↓
Layer 3: Agent Core (AgentRunner + ToolDispatcher + LoopState + GuardrailRunner + MiddlewarePipeline)
↓
Layer 2: Subsystems (ToolRegistry / PromptBuilder / LlmClient / SkillRegistry)
↓
Layer 1: Foundation (Contract/ — interfaces, zero upstream dependencies)
Testing
composer install vendor/bin/phpunit
575 tests, 1146 assertions — all passing.
Note: Run
vendor/bin/phpunitafter install. Test count reflects latest version.
License
MIT
chen-zhanjie/hyperf-agentic 适用场景与选型建议
chen-zhanjie/hyperf-agentic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 chen-zhanjie/hyperf-agentic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chen-zhanjie/hyperf-agentic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-15