定制 agent-state-language/asl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agent-state-language/asl

Composer 安装命令:

composer require agent-state-language/asl

包简介

A JSON-based domain-specific language for defining configurable, composable AI agent workflows

README 文档

README

A JSON-based domain-specific language for defining configurable, composable AI agent workflows.

License: MIT PHP 8.1+

Overview

Agent State Language extends the concepts of AWS Step Functions' Amazon States Language with agent-native primitives for:

  • 🧠 Memory & Context - Persistent memory, sliding context windows
  • 🔧 Tool Orchestration - Permissions, rate limits, sandboxing
  • 👤 Human-in-the-Loop - Approval gates, feedback collection
  • 💬 Multi-Agent Communication - Debates, delegation, consensus
  • 💰 Cost Management - Token budgets, model fallbacks
  • 🛡️ Guardrails - Input/output validation, content moderation
  • 📊 Observability - Reasoning traces, execution logs

Quick Start

Installation

composer require agent-state-language/asl

Define a Workflow

Create workflow.asl.json:

{
  "Comment": "Simple greeting workflow",
  "StartAt": "Greet",
  "States": {
    "Greet": {
      "Type": "Task",
      "Agent": "GreeterAgent",
      "Parameters": {
        "name.$": "$.userName"
      },
      "End": true
    }
  }
}

Run It

<?php

use AgentStateLanguage\Engine\WorkflowEngine;
use AgentStateLanguage\Agents\AgentRegistry;

$registry = new AgentRegistry();
$registry->register('GreeterAgent', new MyGreeterAgent());

$engine = WorkflowEngine::fromFile('workflow.asl.json', $registry);
$result = $engine->run(['userName' => 'Alice']);

echo $result->getOutput(); // "Hello, Alice!"

State Types

Core States (AWS ASL Compatible)

State Description
Task Execute an agent with parameters
Choice Conditional branching
Map Iterate over arrays
Parallel Execute branches concurrently
Pass Transform data
Wait Pause execution
Succeed End successfully
Fail End with failure

Agent-Native States (ASL Extensions)

State Description
Approval Human-in-the-loop gate
Debate Multi-agent deliberation
Checkpoint Save/resume point

Agent-Native Extensions

Memory Block

{
  "AnalyzeCode": {
    "Type": "Task",
    "Agent": "Analyzer",
    "Memory": {
      "Read": ["project_patterns", "user_preferences"],
      "Write": { "Key": "analysis_results", "TTL": "7d" }
    }
  }
}

Context Block

{
  "GenerateResponse": {
    "Type": "Task",
    "Agent": "Responder",
    "Context": {
      "Strategy": "sliding_window",
      "MaxTokens": 8000,
      "Priority": ["$.currentTask", "$.recentHistory"]
    }
  }
}

Tools Block

{
  "Research": {
    "Type": "Task",
    "Agent": "Researcher",
    "Tools": {
      "Allowed": ["web_search", "read_file"],
      "Denied": ["write_file", "execute_shell"],
      "RateLimits": { "web_search": { "MaxPerMinute": 10 } }
    }
  }
}

Budget Block

{
  "Comment": "Workflow with cost controls",
  "Budget": {
    "MaxTokens": 100000,
    "MaxCost": "$5.00",
    "OnExceed": "PauseAndNotify"
  }
}

Approval State

{
  "ReviewChanges": {
    "Type": "Approval",
    "Prompt": "Review the proposed changes",
    "Options": ["approve", "reject", "modify"],
    "Timeout": "24h",
    "Next": "ApplyChanges"
  }
}

Debate State

{
  "DebateSolution": {
    "Type": "Debate",
    "Agents": ["ProAgent", "ConAgent", "JudgeAgent"],
    "Topic.$": "$.proposal",
    "Rounds": 3,
    "Consensus": { "Required": true, "Arbiter": "JudgeAgent" }
  }
}

Documentation

Examples

Example Description
Task Breakdown Recursive task decomposition
Code Review Multi-agent review with approval
Research Assistant Web search and synthesis
Customer Support Intent routing and escalation
Content Pipeline Generation and moderation

Tutorial Path

Core Tutorials

  1. Hello World - Your first workflow
  2. Simple Workflow - Sequential states
  3. Conditional Logic - Choice states
  4. Parallel Execution - Concurrent branches
  5. Recursive Workflows - Map iterations
  6. Memory & Context - State persistence
  7. Tool Orchestration - Tool permissions
  8. Human Approval - Human-in-the-loop
  9. Multi-Agent Debate - Agent collaboration
  10. Cost Management - Budget controls
  11. Error Handling - Retry and catch
  12. Building Skills - Composition patterns

claude-php-agent Integration

  1. Integrating Claude PHP Agent - Wrapper pattern for ASL
  2. Tool-Enabled Agent Workflows - Tools in workflows
  3. Multi-Agent Orchestration - Parallel agent execution
  4. Loop Strategies in Workflows - ReAct, Reflection, Plan-Execute
  5. RAG-Enhanced Workflows - Knowledge-augmented agents

Requirements

  • PHP 8.1 or higher
  • Composer

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Related Projects

Integration with claude-php-agent

ASL can be combined with claude-php-agent for advanced AI agent workflows:

use AgentStateLanguage\Engine\WorkflowEngine;
use AgentStateLanguage\Agents\AgentRegistry;
use ClaudeAgents\Agent;
use ClaudePhp\ClaudePhp;

// Create a claude-php-agent wrapped for ASL
$client = ClaudePhp::make(getenv('ANTHROPIC_API_KEY'));
$agent = Agent::create($client)
    ->withSystemPrompt('You are a helpful assistant.')
    ->withTools([...]);

// Register with ASL
$registry = new AgentRegistry();
$registry->register('Assistant', new ClaudeAgentAdapter('Assistant', $agent));

// Run workflow with advanced agent capabilities
$engine = WorkflowEngine::fromFile('workflow.asl.json', $registry);
$result = $engine->run(['task' => 'Analyze this code...']);

See Tutorial 13: Integrating Claude PHP Agent for complete integration guide.

agent-state-language/asl 适用场景与选型建议

agent-state-language/asl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「DSL」 「workflow」 「Agent」 「state-machine」 「ai」 「orchestration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 agent-state-language/asl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 agent-state-language/asl 我们能提供哪些服务?
定制开发 / 二次开发

基于 agent-state-language/asl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-20