PHPackages                             cognesy/agents - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cognesy/agents

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cognesy/agents
==============

SDK for building custom AI agents

v2.7.0(1w ago)003MITPHPPHP ^8.3

Since Mar 13Pushed 1mo agoCompare

[ Source](https://github.com/cognesy/agents)[ Packagist](https://packagist.org/packages/cognesy/agents)[ Docs](https://instructorphp.com)[ RSS](/packages/cognesy-agents/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (9)Dependencies (65)Versions (14)Used By (3)

Instructor Agents
=================

[](#instructor-agents)

SDK for building composable AI agents in PHP.

This package provides:

- `AgentLoop` for step-based agent execution
- tools and tool execution runtime
- hooks/guards for lifecycle control
- `AgentBuilder` capabilities for composition
- templates and session runtime for persisted workflows

This package is a split from the [Instructor PHP monorepo](https://github.com/cognesy/instructor-php).

Installation
------------

[](#installation)

```
composer require cognesy/agents
```

Minimal Example
---------------

[](#minimal-example)

```
use Cognesy\Agents\AgentLoop;
use Cognesy\Agents\Data\AgentState;

$agent = AgentLoop::default();
$state = AgentState::empty()->withUserMessage('What is 2+2?');
$result = $agent->execute($state);

echo $result->finalResponse()->toString();
```

Coding Agent
------------

[](#coding-agent)

`UseCodingTools` installs the provider-familiar `read`, `bash`, `edit`, and `write` tool names. `CodingAgentPrompt` renders matching operating guidance from the prompt shipped in `resources/prompts/coding/coding-agent.md.twig`.

```
use Cognesy\Agents\Builder\AgentBuilder;
use Cognesy\Agents\Capability\Coding\UseCodingTools;
use Cognesy\Agents\Data\AgentState;
use Cognesy\Agents\Prompts\Coding\CodingAgentPrompt;

$workDir = '/path/to/project';
$agent = AgentBuilder::base()
    ->withCapability(new UseCodingTools($workDir))
    ->build();

$state = AgentState::empty()
    ->withSystemPrompt(CodingAgentPrompt::with(
        documentation_path: $workDir . '/AGENTS.md',
    ))
    ->withUserMessage('Inspect the project and make the requested change.');

$result = $agent->execute($state);
```

`documentation_path` is optional. When it is omitted, the rendered prompt does not invent a package-relative documentation location.

The file contracts are deliberately bounded and conservative:

- `read` defaults to a numbered 200-line/32 KiB window and returns an exact continuation hint. Agents can explicitly increase `limit` and `max_bytes`when a larger window or complete file is justified.
- `edit` streams through the source and atomically commits only after exact match validation succeeds.
- `write` creates a new file atomically, requires an existing parent directory, and refuses to replace different content.
- `bash` returns at most a 32 KiB window and explains how to recover from larger output.

Legacy `UseFileTools` remains available with the existing `read_file`, `edit_file`, and `write_file` names.

Documentation
-------------

[](#documentation)

Use the Agents docs for actual usage and architecture details:

- `packages/agents/docs/01-introduction.md`
- `packages/agents/docs/02-basic-agent.md`
- `packages/agents/docs/05-tools.md`
- `packages/agents/docs/13-agent-builder.md`
- `packages/agents/docs/14-agent-templates.md`
- `packages/agents/docs/16-session-runtime.md`

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~4 days

Total

13

Last Release

11d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/184133?v=4)[Dariusz Debowczyk](/maintainers/ddebowczyk)[@ddebowczyk](https://github.com/ddebowczyk)

---

Top Contributors

[![ddebowczyk](https://avatars.githubusercontent.com/u/184133?v=4)](https://github.com/ddebowczyk "ddebowczyk (43 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cognesy-agents/health.svg)

```
[![Health](https://phpackages.com/badges/cognesy-agents/health.svg)](https://phpackages.com/packages/cognesy-agents)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19467.3M1.9k](/packages/drupal-core)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.9M535](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
