adachsoft / ai-agent-final-report
Generates a final report when an AI agent run stops at a configured limit.
Requires
- php: >=8.3
- adachsoft/ai-agent: ^0.13 || ^0.14
- adachsoft/ai-conversation-model: ^0.2
Requires (Dev)
- adachsoft/php-code-style: ^0.7.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.4
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A framework-independent package that generates a short final report when an adachsoft/ai-agent run stops because of a configured limit. The model is invoked without tools on a temporary copy of the conversation, which is deleted after the attempt. The report can optionally be appended to the original conversation.
Installation
Install the package with Composer:
composer require adachsoft/ai-agent-final-report
Requirements
This package requires PHP 8.3 or later.
Configuration
Add the extension to an agent definition:
{
"extensions": {
"final_report": {
"on": ["step_budget", "duration_budget"],
"append_to_conversation": true
}
}
}
The on setting is required and must be a non-empty list of non-empty limit-reason strings. prompt is optional; its default asks for completed work, remaining work, exact work state, and the next step. The {limit_reason} placeholder is replaced before invoking the model. append_to_conversation defaults to true.
Usage
The following integration example shows how to call the service after an agent run reaches a configured limit.
Application integration
The application must:
- Provide a
ReportModelInvokerInterfaceimplementation that invokes the configured agent model with tools disabled, using the supplied temporary conversation ID and prompt. - Call
FinalReportService::generate()after a run finishes with a limit reason, passing the source conversation ID, agent ID, limit reason, and the agent's extensions. - Handle the returned report, which is
nullwhen the extension does not apply, its configuration is invalid, the invocation fails, or the model returns no text.
For example:
$report = $finalReportService->generate(
conversationId: $conversationId,
agentId: $agentId,
limitReason: $limitReason,
extensions: $agentExtensions,
);
When append_to_conversation is enabled, the service appends one assistant message to the original conversation with runtime_notice and limit_reason metadata. The invocation prompt and any model interaction remain on the temporary conversation and are not added to the original history.
This package depends only on adachsoft/ai-agent; the application owns the model invoker and the integration with its run lifecycle.