Download the PHP package packstub/agents without Composer
On this page you can find all versions of the php package packstub/agents. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download packstub/agents
More information about packstub/agents
Files in packstub/agents
Package agents
Short Description AI agents for Laravel: an agent engine and an MCP server sharing one tool list, built on laravel/ai and laravel/mcp — tools gated by the app's own abilities, read or write tokens for Claude Code, Claude Desktop and Cursor, queued turns, budgets and limits per workspace and per user. packstub/filament-agents adds the chat and the operator pages to a Filament panel.
License MIT
Homepage https://github.com/packstub/agents
Informations about the package agents
Agents for Laravel
An AI agent and an MCP server for your Laravel app, built on laravel/ai and laravel/mcp. Write a tool once and it serves both your own assistant and Claude Code, Claude Desktop, Cursor or any other MCP client, with your app's own authorization deciding who may run it. Filament Agents puts a chat and the operator pages on top of it inside a Filament panel.

The engine's tools, turns and approvals, as Filament Agents shows them in a panel. Without Filament, your own chat surface drives the same calls through AgentChat.
Features
- One tool list, two front doors: your own agent and any MCP client (Claude Code, Cursor) call the same tools.
- Your app's authorization: the agent never does more than the signed-in person could, and a token narrows it further.
- Writes are proposals: a write waits for the person's approval, asked as a plain question.
- Turns that survive the request: queued, recorded and polled, with a sync driver when there is no worker.
- Knowledge base and web search: answers from your own documents, cited, and from public pages within an allow-list.
- Guard rails you switch on: a prompt guard against injections, and redaction of secrets in answers.
- A bounded bill: answer and token limits per user and per workspace, checked before the provider is called.
- Your assistant, your prompt: a scaffolded agent class on Anthropic, OpenAI, Gemini or xAI, with failover.
- Tenancy-aware: workspace-bound tokens, tenant databases and per-workspace keys, or no tenancy at all.
- Translatable: German, Spanish, Romanian and Russian included.
Compatibility
| Package | Laravel | PHP | laravel/ai | laravel/mcp |
|---|---|---|---|---|
| 1.x | 13.x | 8.4+ | ^0.11 | ^0.9 |
Installation
The install command publishes the config, offers to run the migrations and scaffolds app/Ai/Agents/Assistant.php. Register the agent and the tools in a service provider and put a provider key in .env (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY or XAI_API_KEY, with AGENT_PROVIDER=anthropic|openai|gemini|xai):
The MCP endpoint answers without a key, since it does not need a model. Read more: Installation.
In a Filament panel
packstub/filament-agents requires this package and adds what a panel shows: the chat pages with an "Ask …" button, approve-in-chat writes, show-table rendering a resource's own table under an answer, the Agent access page that mints tokens, and the operator's AI limits and AI turns pages. Install it instead of this package in a panel app; everything on this page applies unchanged, registered through AgentsPlugin instead of the facade. Read more: Filament Agents.
Writing tools
A tool extends Packstub\Agents\Mcp\AgentTool, declares its $ability, and implements run(Request): array and schema(JsonSchema): array. Mark reads with #[IsReadOnly]; anything else is approval-gated for the agent and needs a write token over MCP. Domain exceptions come back to the model as tool errors, never to the person as a crash.
List the tools on the server class, reads first. The agent reads the same list:
Agents::useTools([...]) works instead of a server class. A write tool may add describe(array $arguments): ?string to phrase its own proposals ("Confirm order RO-00016 for Acme?"); without one the question is the tool's title and its first argument. Read more: Tools.

The agent
packstub-agents:agent scaffolds App\Ai\Agents\Assistant, a subclass of Packstub\Agents\Ai\Agent with two slots to fill: persona() (who it is) and domain() (what the workspace is). The base class supplies the generic working and answering rules, the dynamic context (date, workspace, person, role, language — sent with the question, so the system prompt and the history stay cacheable) and the provider options (Anthropic cache breakpoints on the instructions and the settled history, reasoning effort or thinking level per model). Append to any of them by overriding workRules(), answerRules() or context() and merging the parent's list; suggestions() gives an empty chat its starter questions.
It runs on Anthropic, OpenAI, Gemini or xAI with a model catalog (Claude Opus 5, Claude Haiku 4.5, Claude Opus 5 · Deep); any other laravel/ai provider, Ollama included, runs on its smartest and cheapest models. A failover list (AGENT_FAILOVER=gemini,openai) keeps answering when a provider is overloaded.
Read more: The agent.
Running a turn
Start a conversation, queue a turn, poll it. The RunAgentTurn job restores who asked and where (the person, the guard, the workspace, the locale), runs the middleware pipeline with the budget check, streams the answer from the provider and records what it cost:
AgentChat::for($user) wraps this for a chat surface of your own (send, decide, retry, stop, the transcript with its proposals, the context meter). GET agents/chat/{conversation}/turn returns the answer so far and a status line; run php artisan queue:work, or set AGENT_TURN_DRIVER=sync to run the job inside the request — a turn no worker takes within AGENT_WORKER_WAIT seconds says so on that status line. Long chats replay a token-budgeted window with a rolling summary. Read more: The agent.
Filters and charts
A class implementing AgentResource gives the model a filter vocabulary and a record summary, shared by every search tool that names the same key:
Register it with Agents::useResources([Orders::class]). draw-chart renders bar, line, pie and doughnut charts from numbers the model already retrieved, and any tool can return a chart key of its own. Read more: Tables and charts.

MCP clients
Mint a Sanctum token with the abilities the client should have — read, write, tool:{name} to scope it, tenant:{slug} to bind it to a workspace — and connect any MCP client to POST /mcp:
The endpoint sits behind throttle, auth:sanctum and the package's own middleware, so external agents get exactly the tools the person's role and their token allow. Read more: MCP clients.

Budgets and limits
config/packstub-agents.php holds the platform ceiling (AGENT_TURNS_PER_MINUTE, AGENT_TURNS_PER_DAY, AGENT_TOKENS_PER_DAY, AGENT_TOKENS_PER_MONTH, AGENT_USER_TOKENS_PER_DAY, AGENT_USER_TOKENS_PER_MONTH, AGENT_PROMPT_MAX_CHARS). Rows in agent_limits override it: one global row, optional rows per workspace and per user, empty fields inherit. AgentBudget::summary() gives the numbers for a settings page, and every ended turn keeps its record (provider, model, tokens, tools, duration, how it ended), optionally as one log line. Read more: Budgets and limits.

Tenancy
Tell the package what a workspace is and how the current one is found:
Set the MCP path with the workspace in it ('mcp' => ['path' => 'mcp/{tenant}']) and the middleware looks the workspace up by its slug, checks the person's membership and the token's tenant:{slug} ability, and enters it before any tool runs. A workspace can bring its own provider key through credentialsUsing(). For a database-per-tenant app set 'run_migrations' => false, publish the migrations, keep create_agent_limits_table central and move the chat tables next to your tenant migrations. Read more: Tenancy.
Configuration
Read more: Configuration.
Documentation
- Installation
- Tools
- The agent
- Tables and charts
- MCP clients
- Budgets and limits
- Tenancy
- Configuration
- Security
- Testing
Testing
In your own app, fake the model with Assistant::fake([...]) and drive tools through AcmeServer::tool(ToolClass::class, [...]). Never call a provider from tests. Read more: Testing.
Changelog
See the changelog.
Security vulnerabilities
This package lets a model act inside your app, so we take reports seriously. Please e-mail Security page.
Credits
License
MIT. See the license file.
All versions of agents with dependencies
laravel/ai Version ^1.0
laravel/framework Version ^13.0
laravel/mcp Version ^1.0
laravel/sanctum Version ^4.0
spatie/laravel-package-tools Version ^1.93