Search by

adachsoft / ai-tool-call-middleware

Middleware decorators for adachsoft/ai-tool-call facade.

Maintainers

Package info

gitlab.com/a.adach/ai-tool-call-middleware

Issues

pkg:composer/adachsoft/ai-tool-call-middleware

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.1 2026-09-03 08:10 UTC

This package is auto-updated.

Last update: 2026-09-03 07:01:25 UTC


README

adachsoft/ai-tool-call-middleware provides decorators for the public adachsoft/ai-tool-call facade.

Output-size safeguard

Wrap a facade through OutputSizeLimitingFacadeFactory:

use AdachSoft\AiToolCallMiddleware\OutputSize\OutputSizeLimitingFacadeFactory;

/** @var OutputSizeLimitingFacadeFactory $factory */
$factory = $container->get(OutputSizeLimitingFacadeFactory::class);
$facade = $factory->wrap($baseFacade);

wrap() returns an AiToolCallFacadeInterface. The returned facade measures supported tool results in bytes and passes results within the configured limit through unchanged. Oversized results are returned as a structured truncation payload containing the original size, configured limit, returned size, preview, and guidance for requesting a narrower result.

The middleware does not throw an exception when an output exceeds the limit. Results that cannot be measured are passed through unchanged, using a fail-open policy so the safeguard does not break an otherwise valid tool call. Exceptions raised by the wrapped facade are propagated unchanged.

Tool discovery methods are delegated without modification. The safeguard therefore applies only to tool-call results.

Individual tools should still provide their own limits, pagination, filtering, and truncation metadata. See the repository documentation in docs/tool-output-size-rules.md for the output-size contract.