PHPackages                             gawrys/counterparty-ai - 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. gawrys/counterparty-ai

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

gawrys/counterparty-ai
======================

Optional AI-assisted risk research subsystem for counterparty-verification. Advisory only; never decides hard pass/fail.

v0.1.1(today)08↑2525%2MITPHPPHP &gt;=8.2CI passing

Since Jun 23Pushed todayCompare

[ Source](https://github.com/igorgawrys1/counterparty-ai)[ Packagist](https://packagist.org/packages/gawrys/counterparty-ai)[ RSS](/packages/gawrys-counterparty-ai/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (11)Versions (3)Used By (2)

Counterparty AI
===============

[](#counterparty-ai)

[![Packagist Version](https://camo.githubusercontent.com/344d18efe0658b6f52d4ded9c0cd6b5d5a3e737bae9e2abe97bdb196b01a5cc8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6761777279732f636f756e74657270617274792d61692e737667)](https://packagist.org/packages/gawrys/counterparty-ai)[![Total Downloads](https://camo.githubusercontent.com/d7298f5b402659dc1f8fb70ea4f866bd41f2aad77ccbddd68f14b69d623712cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6761777279732f636f756e74657270617274792d61692e737667)](https://packagist.org/packages/gawrys/counterparty-ai)[![CI](https://github.com/igorgawrys1/counterparty-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/igorgawrys1/counterparty-ai/actions/workflows/ci.yml)[![PHP](https://camo.githubusercontent.com/dad72c42359ce03cc1cd9d1b3251dcc5769e6f45e218d6149e19bd7bcb1bfac0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e32253230253743253230382e33253230253743253230382e342d3737376262342e737667)](https://www.php.net/)[![PHPStan](https://camo.githubusercontent.com/745eb989b9e4903dc598fe2cc63ed4226198be55b7c729001cbd1ece7676fef6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e2e737667)](https://phpstan.org/)[![Psalm](https://camo.githubusercontent.com/1516496318aec6e2baf9f8ed7888070c8c0c279848ee94165206d1fa8796d864/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5073616c6d2d6c6576656c253230312d627269676874677265656e2e737667)](https://psalm.dev/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Optional **AI-assisted risk research** for the [Counterparty Verification](https://github.com/igorgawrys1/counterparty-core) toolkit. It plugs into the same `RiskStrategy` seam as the rule-based default and adds qualitative, **advisory** context using an LLM with native tool use.

> ⚠️ **The AI never decides hard pass/fail.** It consumes the finished verification report as ground truth, grounds every claim in a tool's source URL (no source → inconclusive), and forces human review below a confidence threshold. Output is advisory only.

A separate package on purpose: prompts change often and must not bump the core's version.

Features
--------

[](#features)

- **`AiRiskStrategy`** - a drop-in `RiskStrategy`; PSR-16 cached by counterparty + report + prompt version to bound cost.
- **Native tool use (function calling)** - the model invokes `registry_lookup`, `web_search` and `verification_report`; the provider executes them and feeds results back, looping until the findings JSON is returned.
- **Two reference providers over PSR-18, no SDK** - `AnthropicResearchProvider`, `OpenAiResearchProvider`. Adding another LLM is one `AbstractAiResearchProvider` subclass.
- **Structured output, validated** - force JSON, parse, validate, retry; malformed output is never trusted.
- **Deterministic test kit** - `FakeAiResearchProvider`, recorded cassettes and an in-memory PSR-16 cache, so tests run offline.

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

[](#installation)

```
composer require gawrys/counterparty-ai
```

Usage
-----

[](#usage)

```
use Gawrys\Counterparty\Ai\AiRiskStrategy;
use Gawrys\Counterparty\Ai\Prompt\RiskPromptBuilder;
use Gawrys\Counterparty\Ai\Research\AnthropicResearchProvider; // or OpenAiResearchProvider
use Gawrys\Counterparty\Ai\Tool\{RegistryTool, ReportLookupTool};

$strategy = new AiRiskStrategy(
    provider: new AnthropicResearchProvider($http, $apiKey),
    promptBuilder: new RiskPromptBuilder(),
    tools: [new RegistryTool($registries), new ReportLookupTool()],
    cache: $psr16Cache,
    reviewThreshold: 0.6,
);

$verifier = new Verifier($checks, $strategy, $clock);
```

Switching LLM is a one-line change (`OpenAiResearchProvider`), or implement `AbstractAiResearchProvider::complete()` for any other backend. Removing this package never breaks the rule-based default - the core has no dependency on it.

See the **[documentation](https://igorgawrys1.github.io/counterparty-verification/ai/)** for prompts, grounding rules and writing custom tools.

Testing
-------

[](#testing)

```
composer check
```

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

Contributing &amp; Security
---------------------------

[](#contributing--security)

Pull requests welcome. Report security issues privately - see [SECURITY.md](SECURITY.md).

Credits
-------

[](#credits)

- [Igor Gawrys](https://github.com/igorgawrys1)

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE).

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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 ~3 days

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7e3d761ee1d0092d6f4400cf56467f93fa413fbc1cb7bc2e9776903cb52f5f7?d=identicon)[gawrys](/maintainers/gawrys)

---

Tags

aillmresearchriskdue-diligence

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gawrys-counterparty-ai/health.svg)

```
[![Health](https://phpackages.com/badges/gawrys-counterparty-ai/health.svg)](https://phpackages.com/packages/gawrys-counterparty-ai)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

749284.3k37](/packages/civicrm-civicrm-core)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69634.4M144](/packages/algolia-algoliasearch-client-php)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318117.1k1](/packages/cognesy-instructor-php)[symfony/ai-agent

PHP library for building agentic applications.

31746.8k83](/packages/symfony-ai-agent)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M520](/packages/shopware-core)[symfony/ai-platform

PHP library for interacting with AI platform provider.

521.2M216](/packages/symfony-ai-platform)

PHPackages © 2026

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