jbsommeling/agent
A Laravel package for building and running AI agents in PHP. It offers a simple API for prompts, tools, and agent workflows, making it easy to add assistant-style automation and conversational features to existing Laravel apps without complex setup.
composer require jbsommeling/agent. v1.0.3 restores PHP 8.0 support and is CI-tested against Laravel 9 through 13, so the same install works whether you're maintaining an older Laravel 9 app or starting fresh on the newest skeleton. No --ignore-platform-req workaround needed anymore.php artisan vendor:publish --tag="agent-config", then set your provider credentials in .env (the package reads them through config/agent.php). Keep per-environment model names in the config, not in code.config/agent.php (it documents every knob the package actually honours) → the package's tests/ directory. For a v1.x package with a small doc surface, the test suite is the most reliable specification of expected usage.Support\Agents\SummariseTicket, etc.) rather than calling the package directly from controllers. Keeps prompts versionable, makes the call mockable in tests, and gives you one place to add logging and retries.retryUntil/backoff for provider 429s and 5xx.resources/prompts/*.md loaded by the agent class. Diffing prompts in git is the single biggest quality-of-life win once you have more than two agents.max_steps or equivalent); an unbounded loop is an unbounded bill.messages table keyed by conversation ULID) and pass it in on each call. Treat any in-process memory the package offers as a per-request convenience, not storage — it will not survive the next HTTP request or a queue worker restart.response()->stream() or a Livewire wire:stream). For fire-and-forget generation, don't stream at all — streaming a queued job gives you nothing but complexity.Http::fake()) or the package's own fake if it ships one, then assert on the outgoing payload (model, messages, tool schema) rather than on the model's prose. Snapshot-test your rendered prompts; they're the thing most likely to regress silently.agent_runs table of prompt + response + usage for at least a few weeks. When someone reports a bad answer, you want the exact input that produced it.readonly properties, enums, pure intersection types, never, or first-class callable syntax. You can use all of those in your application on 8.1+, but any PR or local patch to the package will fail its CI. Don't vendor-patch it with 8.1-only syntax and expect upstream to take it.Str:: additions in 10/11, Sleep::, newer Http client options) exist inside the package's own code. If you hit a BadMethodCallException after a framework upgrade, that's the first place to look.php artisan config:clear locally and re-deploy on prod — otherwise you'll debug a "wrong model" issue that doesn't exist in the code.config/agent.php and PHP's max_execution_time for any sync path; large completions routinely exceed 30s. Catch Illuminate\Http\Client\ConnectionException and surface a retryable error to the user.Content-Length, and output buffering all corrupt SSE. Disable them for the streaming route and call ob_end_flush()/flush() after each chunk. Behind nginx, also set proxy_buffering off.Http::after() hook (or Http::preventStrayRequests() in tests) to dump the exact request body. Nearly every failure is a malformed JSON schema for a tool, a missing api_key, or a model name that doesn't exist on that provider.max_tokens, cap tool-call iterations, and alert on daily token spend. A retry loop with backoff against a paid endpoint compounds fast.composer update jbsommeling/agent and, if it refuses, composer why-not jbsommeling/agent 1.0.3 to find the constraining dependency.How can I help you explore Laravel packages today?