Search by

adachsoft / ai-integration-middleware

Middleware decorators for adachsoft/ai-integration tool-calling chat facade.

Maintainers

Package info

gitlab.com/a.adach/ai-integration-middleware

Issues

pkg:composer/adachsoft/ai-integration-middleware

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-09-04 15:07 UTC

This package is not auto-updated.

Last update: 2026-09-04 19:28:21 UTC


README

Middleware decorators for adachsoft/ai-integration tool-calling chat facades.

Problem

AI providers reject a request when the conversation contains an assistant message with a tool call but no matching tool result. A typical provider error is:

No tool output found for function call <id>

This package repairs that history immediately before the decorated facade sends it to a provider. Each missing result is represented by a deterministic synthetic tool message.

Installation

composer require adachsoft/ai-integration-middleware

Usage

The middleware is opt-in. Wrap the facade at the composition root and pass the returned facade wherever a ToolCallingChatFacadeInterface is required:

use AdachSoft\AiIntegrationMiddleware\OrphanedToolCall\OrphanedToolCallRepairingFacadeFactory;

$toolCallingChatFacade = (new OrphanedToolCallRepairingFacadeFactory())
    ->wrap($toolCallingChatFacade);

// Pass $toolCallingChatFacade to the consumer as ToolCallingChatFacadeInterface.

A custom message can be configured through the factory constructor:

$toolCallingChatFacade = (new OrphanedToolCallRepairingFacadeFactory(
    'The previous tool execution was interrupted. Run the tool again if needed.',
))->wrap($toolCallingChatFacade);

Scope and limitations

  • The middleware does not persist or modify conversation history.
  • Existing messages and their order are preserved.
  • Existing tool results are never replaced.
  • Tool messages without a corresponding assistant tool call are outside the repair scope and are passed through unchanged.
  • The middleware is disabled unless the facade is explicitly wrapped.
  • The package does not depend on adachsoft/ai-agent.

The public composition API is OrphanedToolCallRepairingFacadeFactory::wrap(). The decorator and repair service are internal implementation details.

See the middleware design rules for the package conventions used by future decorators.

License

MIT