Download the PHP package heiner/agent-graph without Composer
On this page you can find all versions of the php package heiner/agent-graph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heiner/agent-graph
More information about heiner/agent-graph
Files in heiner/agent-graph
Package agent-graph
Short Description Durable agent graph runtime for Laravel AI SDK agents.
License MIT
Homepage https://github.com/heinergiehl/agent-graph
Informations about the package agent-graph
AgentGraph for Laravel AI SDK
AgentGraph is a Laravel package and runtime SDK for durable AI agent graphs. It complements the official laravel/ai package with graph orchestration, checkpoints, resumable runs, interrupts, scoped memory, idempotent tasks, traces, queues, and graph-as-tool integration.
AgentGraph does not replace Laravel AI providers, agents, tools, streaming, or structured output. It uses Laravel AI through public contracts such as Laravel\Ai\Contracts\Agent and Laravel\Ai\Contracts\Tool.
Release Status
0.13.x is the hardened pre-v1 release line intended for real Laravel app integration testing. Breaking changes are still possible before v1, but they will be documented in CHANGELOG.md and UPGRADE.md.
The v1 target is a hardened MVP: stable graph execution, checkpoints, interrupts/resume, idempotent tasks, scoped memory, traces, queues, run-event observation, Laravel AI agent nodes, graphs as tools, native subgraph nodes, and durable app workflow sessions. Experimental checkpoint inspection, replay, forking, worker-backed queued supersteps, and vector memory contracts are available for post-v1-style workflows. OpenTelemetry export and visual workflow editing remain outside the stable v1 core.
CI currently validates the 0.13 release line against PHP 8.3/8.4, Laravel 12/13, and laravel/ai ^0.7. laravel/ai ^1.0 stays declared for forward compatibility but should remain non-blocking until upstream tags a 1.x release.
Installation
The ^0.13 constraint tracks the stable 0.13 line while staying below the next minor pre-v1 line. Historical 0.13.0-beta.* tags remain available for apps that explicitly test prereleases, but normal installs should use the stable tag.
agent-graph:install publishes the package config and migrations. The database store uses these tables by default:
agent_graph_runsagent_graph_checkpointsagent_graph_writesagent_graph_tasksagent_graph_interruptsagent_graph_memoriesagent_graph_node_executionsagent_graph_traces
Set AGENT_GRAPH_DB_CONNECTION when AgentGraph tables should live on a non-default Laravel database connection. Migrations, database stores, agent-graph:doctor, agent-graph:prune, runtime transactions, and the optional PgvectorMemoryStore all use the configured connection. Leave it unset to use database.default.
Useful production env settings:
Use AGENT_GRAPH_STORE=memory only for tests and local throwaway runs. Use AGENT_GRAPH_EXECUTION_MODE=queued_supersteps only when workers boot the same graph definitions and process the configured queue.
Set AGENT_GRAPH_LOCK_TTL_SECONDS longer than the longest expected node execution or active session start path. The default is 300 seconds.
Production runs require a cache store that supports atomic locks. Keep AGENT_GRAPH_LOCK_FAIL_WITHOUT_PROVIDER=true outside local throwaway tests.
First Graph
Interrupts
Nodes can pause execution for user input, approval, delay, webhook, manual review, or state edit.
Resume later:
Only active runs can be resumed. completed, cancelled, and failed runs reject resume() and resumeWithStateEdit() so terminal history is not mutated accidentally.
The resumed node can read the original resume response separately from merged graph state:
For manual state correction flows, use the explicit state-edit resume API. The patch is validated against the graph state schema before the interrupt is resolved.
Runtime Inspection
Inspect a run without resuming it:
Build a replayable timeline for debuggers or admin UIs:
Observe normalized workflow events for a single run:
Run events are workflow observations such as run.started, node.started, stream.delta, checkpoint.created, interrupt.created, run.completed, and run.failed. They are not an HTTP streaming protocol and do not replace Laravel AI token/model streaming.
List recent runs for dashboards, admin screens, or recovery tools:
List idempotent tasks for inspectors or side-effect debugging:
Record generic parent/child run lineage for delegated tools, nested workflows, or inspector UIs:
Parent metadata is stored under run.meta.parent. Manual child runs and native SubgraphNode child runs use the same lineage shape so inspector UIs can show delegated work consistently.
Supersteps and Send
Multiple StateGraph::START edges execute as the first superstep. Multiple static or conditional next nodes run as one deterministic superstep. Each node in the same frontier sees the same base state; writes are merged after the whole superstep completes.
If multiple nodes write the same state channel in one superstep, define an explicit reducer:
Reducer names are strict. Unknown strings throw during reducer normalization instead of silently falling back to last-write-wins.
Send input is node-local and is not persisted into graph state unless the target node writes it. Parallel interrupts are intentionally rejected in the same superstep; route approval or review after fan-in.
Node Retry Policies
Retry policies are configured per node and apply only to thrown node exceptions. They do not retry NodeResult::fail(), interrupts, delays, or schema-validation failures.
maxAttempts includes the first attempt. Retry attempts emit node.retrying Laravel events, traces, and normalized RunEvent objects when observation is enabled. Successful retried writes include runtime.retry metadata with attempts, max attempts, and failed attempts.
Retries can repeat node side effects. Wrap external API calls, emails, payments, CRM writes, and other irreversible work in $context->tasks()->once() with stable task keys before enabling retry policies in production.
Runtime Hardening
Per-node timeout and concurrency policies are additive to retry policies:
Timeouts are portable wall-clock checks after node execution returns. Concurrency uses AgentGraph's lock provider and does not change Laravel AI provider, queue, or streaming behavior. The built-in runtime currently supports exclusive node concurrency only: limit must be 1.
Idempotent tasks now use leases. A running task key cannot be executed again until its lease expires; completed task keys still return their stored result and key reuse with different input is rejected.
For stricter human-resume flows, use resumeStrict():
Normal resume() remains permissive for unknown payload keys while still validating known state channels.
State schemas are strict about schema definitions. Unknown primitive types such as strng, unknown union members, and unknown structured types throw during validation. Structured arrays declared with StateSchema::array('ids', 'string') require a PHP list, and every item is validated against the item schema.
cancel() applies only to active runs: running, interrupted, or delayed. Terminal runs remain unchanged. Resume, state-edit resume, cancel, queued continuation, and delayed continuation paths are protected by run locks.
Interrupts can carry expiry policy metadata:
Subgraphs
Use SubgraphNode to run a registered graph as a durable child run. Child runs are normal AgentGraph runs with run.meta.parent lineage.
Supported modes are isolated(), shared(), and mapped(). Child interrupts bubble as parent subgraph interrupts with child_run_id and child_interrupt_id; resuming the parent forwards the answer to the child before continuing the parent node. Parallel interrupt restrictions still apply.
Time Travel
Checkpoint inspection, replay, and forking are exposed as experimental public APIs. They create new runs and never mutate the original run history.
Inspect a specific checkpoint:
Replay from a checkpoint:
Fork from a checkpoint with a reducer-aware state patch:
List replay and fork children for a source checkpoint:
Replay and fork runs also store run.meta.parent with relationship set to replay or fork, so AgentGraph::childRuns($sourceRunId) can visualize run-level lineage while timeTravelChildren() remains checkpoint-specific.
Replay and fork can execute downstream nodes again. Wrap external side effects such as CRM writes, email, payments, and API calls in idempotent $context->tasks()->once() blocks before using time travel in production.
Laravel AI Agent Node
AgentNode::stream() still delegates to Laravel AI's stream() API. AgentGraph keeps dispatching GraphStreamDelta for streamed text deltas and, when run-event observation is enabled, also exposes those deltas as normalized stream.delta RunEvent objects. Use onTextDelta() for a direct synchronous callback to bridge deltas into app transports:
AgentNode can also copy public Laravel AI response metadata into graph state without touching provider internals:
Graphs as Tools
The tool returns JSON with status, run_id, thread_id, state, interrupt, and error.
Tool responses always include:
Interrupted runs return a machine-readable interrupt payload. Failed runs return status: "failed" and an error object.
Use output() when a parent agent needs a narrower JSON response. Long-running lifecycle observation should use RunEvent callbacks instead of GraphTool persistence hooks.
For active-thread app workflows, use a durable session or durable tool instead of changing GraphTool:
AgentGraph::graph(...)->thread(...)->run() intentionally creates a new run. AgentGraph::session(...)->run() is active-thread idempotent: it returns the existing running, interrupted, or delayed run for the graph+thread when one exists, and that check/start path is protected by an AgentGraph session lock. Use session()->start() when you explicitly want a fresh run.
DurableGraphTool returns JSON with status, run_id, thread_id, state, interrupt, summary, and error.
Memory Manager
AgentGraph::memory() wraps the configured memory store with extractor and privacy helpers:
Vector memory is contract-based and optional. Laravel AI can provide embeddings; AgentGraph stores vectors only when an application binds a vector store. The default bindings are deterministic/in-memory test-safe adapters. PgvectorMemoryStore and stubs/pgvector-memory-migration.stub are optional experimental starting points for semantic memory on PostgreSQL pgvector, not core persistence for runs, checkpoints, interrupts, queues, or audit logs.
Stable v1 Public APIs
The 0.13 release exposes the intended v1-stable API surface documented in docs/api-reference.md. In short:
StateGraphfor fluent graph definitions.NodeandNodeContextfor runtime node implementation.NodeResultfor writes, gotos, interrupts, completion, and failures.Sendfor dynamic fan-out and map/reduce style supersteps.RetryPolicyand per-nodeStateGraph::retry()configuration for thrown node exceptions.TimeoutPolicy,ConcurrencyPolicy, and per-nodeStateGraph::timeout()/StateGraph::concurrency()configuration.AgentGraphfacade for defining, running, resuming, state-edit resuming, inspecting, listing, cancelling, and exposing tools.RunSnapshotfor read-only runtime inspection.RunTimelinefor ordered checkpoint/write/interrupt/failure timelines with optional state diffs.RunEventfor optional per-run workflow event observation and collection.CheckpointSnapshotfor read-only checkpoint inspection and experimental time-travel workflows.AgentNodefor Laravel AI agent execution.GraphToolfor Laravel AI tool integration with optional input, output, and run metadata mapping.DurableGraphSessionandDurableGraphToolfor active-thread app workflows.SubgraphNodefor native child graph execution with parent/child lineage.- Store contracts for production adapters and tests, including enumerable memory inspection and replaceable delay scheduling.
checkpoint(), replay(), fork(), and timeTravelChildren() are public experimental APIs. They are documented and tested, but remain outside the stable v1 core until time-travel workflows have more production mileage.
Production Checklist
- Run and monitor the published migrations.
- Use database stores as the source of truth.
- Set
AGENT_GRAPH_DB_CONNECTIONbefore migrating when AgentGraph should use a dedicated connection. - Configure queue workers for background and delayed graph continuation.
- Keep
execution.mode=syncunless a graph is registered during app boot and workers can processNodeExecutionJob/ContinueSuperstepJob. - Keep cache locks fail-closed outside local throwaway tests.
- Queue jobs use package-level tries, timeout, backoff, and AgentGraph tags for worker telemetry.
- Run
php artisan agent-graph:prune --dry-run --traces --tasks --memoriesbefore enabling retention deletes. - Keep trace redaction keys current for your domain.
- Scope memory by tenant or actor before using it in multi-tenant apps.
- Use idempotent task keys for every external side effect.
- Use
tasks()for side-effect inspection instead of reading package task tables directly. - Use
inspect()andruns()for recovery/admin UIs instead of reading package tables directly. - Use
timeline()for debugger and trace UIs instead of reconstructing checkpoint history manually. - Use run-event callbacks for lightweight workflow observation; keep token streaming in Laravel AI.
- Use
timeTravelChildren()to inspect replay/fork lineage for a source checkpoint. - Use
resumeWithStateEdit()for manual state correction flows. - Use per-node retry policies for transient thrown exceptions, and keep side effects idempotent with
tasks()->once(). - Configure
agent-graph.tasks.lease_secondsfor the maximum expected side-effect duration. - Configure
agent-graph.locks.ttl_secondslonger than the longest expected node execution. - Use
resumeStrict()for public endpoints that should reject unknown resume payload keys. - Treat terminal runs as immutable for resume/state-edit/cancel flows; use replay or fork for follow-up work from historical state.
- Keep
GraphToolgeneric; useDurableGraphToolfor active-run-per-thread application semantics. - Use explicit reducers for any state channel that can be written by more than one node in the same superstep.
- Keep graph definitions generic; product-specific UI belongs in consuming apps.
- For multi-tenant memory, always include tenant or actor scope in reads and writes.
- Run
php artisan agent-graph:doctorafter deploys and before release validation. TreatFAILlines as release blockers; the command checks database tables, cache locks, store driver, queue settings, lease/lock timing, and max-step bounds.
Status
This MVP includes the durable runtime core, deterministic supersteps, dynamic Send fan-out, per-node retry/timeout/concurrency policies, database and in-memory stores, scoped memory, interrupts with expiry, task leases, traces, queue jobs, worker-backed queued supersteps, Laravel AI adapter, graph tool adapters, subgraph nodes, run-event observation, commands, tests, docs, optional experimental vector-memory adapters, and experimental checkpoint replay/fork APIs. Post-MVP work includes visual timeline tooling, production-grade pgvector CI/adapter hardening, OpenTelemetry export, and visual editor serialization.
All versions of agent-graph with dependencies
illuminate/cache Version ^12.0 || ^13.0
illuminate/console Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/events Version ^12.0 || ^13.0
illuminate/queue Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
laravel/ai Version ^0.7 || ^1.0