adachsoft / ai-agent-config-repository
AI agent configuration repository library for AdachSoft projects.
Package info
gitlab.com/a.adach/ai-agent-config-repository
pkg:composer/adachsoft/ai-agent-config-repository
Requires
- php: ^8.3
- adachsoft/ai-agent: ^0.9
- adachsoft/ai-integration: ^0.7
- adachsoft/ai-tool-call: ^2.0
- adachsoft/collection: ^3.0
Requires (Dev)
- adachsoft/php-code-style: ^0.3
- friendsofphp/php-cs-fixer: ^3.89
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.4
- rector/rector: ^2.3
This package is not auto-updated.
Last update: 2026-05-07 13:48:55 UTC
README
Framework-agnostic library for storing and using AI agent configuration
for agents built with the adachsoft/ai-agent runtime.
This package provides:
- a model of agent configuration (VO/DTO/Collection/Exception),
- SPI repository layer with full CRUD for agent configurations and system prompts,
- a Public API for creating
AiAgentFacadeInterfaceinstances based on configuration loaded from repositories.
Requirements
- PHP:
^8.3 adachsoft/collection:^3.0adachsoft/ai-agent:^0.8adachsoft/ai-integration:^0.6.1adachsoft/ai-tool-call:^2.0
Installation
composer require adachsoft/ai-agent-config-repository
Package structure
Root namespace:
AdachSoft\AiAgentConfigRepository\...
Directory layout:
src/AiAgentConfigRepository/PublicApiVo– value objects (agent, prompt, tool, tool group identifiers)Dto– agent configuration DTO and policies DTOCollection– VO collections based onAbstractImmutableCollectionException– domain exceptions exposed by the Public APIAiAgentFromConfigFactoryInterface– factory creatingAiAgentFacadeInterfacefrom config
src/AiAgentConfigRepository/SPIRepository– repository interfaces for agent configs and system prompts (full CRUD)Mapper– mapper interface from agent definition to DTOs fromadachsoft/ai-agent
src/AiAgentConfigRepository/InfrastructureRepository/InMemory– in-memory reference implementations of repositoriesFactory– implementation ofAiAgentFromConfigFactoryInterface
Public API
Value Objects (VO)
AdachSoft\AiAgentConfigRepository\PublicApi\Vo\AgentIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\PromptIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\ToolIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\ToolGroupId
Each VO is a simple readonly wrapper around a string (public string $value).
DTOs
AdachSoft\AiAgentConfigRepository\PublicApi\Dto\AgentPoliciesDto- retry / backoff / limits / timeouts / trimming / tools-related policies
AdachSoft\AiAgentConfigRepository\PublicApi\Dto\AgentDefinitionDto- provider-agnostic, complete agent definition that contains:
- identifier, name, description,
- provider id and model id,
- prompt id and system prompt text,
- model parameters,
- timeout in seconds,
- allowed tool ids / tool group ids,
- agent policies (
AgentPoliciesDto), - conversation context strategy id and parameters.
- provider-agnostic, complete agent definition that contains:
Collections
AdachSoft\AiAgentConfigRepository\PublicApi\Collection\ToolIdCollectionAdachSoft\AiAgentConfigRepository\PublicApi\Collection\ToolGroupIdCollection
Both collections extend AdachSoft\Collection\AbstractImmutableCollection and are
strongly typed to ToolId and ToolGroupId respectively.
Exceptions
Namespace:
AdachSoft\AiAgentConfigRepository\PublicApi\Exception
Defined exceptions:
AgentNotFoundExceptionAgentAlreadyExistsExceptionSystemPromptNotFoundExceptionSystemPromptAlreadyExistsExceptionAgentRuntimeBuildFailedException
These exceptions are used by the Public API and SPI implementations to signal consistent error conditions.
SPI layer
AgentConfigRepositoryInterface
AdachSoft\AiAgentConfigRepository\SPI\Repository\AgentConfigRepositoryInterface
SPI repository contract for agent configuration with full CRUD, operating on
AgentDefinitionDto instances identified by AgentId.
SystemPromptRepositoryInterface
AdachSoft\AiAgentConfigRepository\SPI\Repository\SystemPromptRepositoryInterface
SPI repository contract for system prompts with full CRUD, operating on prompt
contents identified by PromptId.
AgentDefinitionMapperInterface
AdachSoft\AiAgentConfigRepository\SPI\Mapper\AgentDefinitionMapperInterface
Mapper responsible for transforming an AgentDefinitionDto into the DTOs
required by the adachsoft/ai-agent runtime:
AgentConfigDtoPortsConfigDtoPoliciesConfigDto
It also wires the ports (ToolCallingChatFacadeInterface, AiToolCallFacadeInterface).
In-memory implementations
The library ships with reference, in-memory repository implementations:
AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemoryAgentConfigRepository- implements
AgentConfigRepositoryInterface - stores
AgentDefinitionDtoinstances in an in-memory array
- implements
AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemorySystemPromptRepository- implements
SystemPromptRepositoryInterface - stores a
PromptId => systemPromptmap in memory
- implements
These are intended as reference implementations and for tests / simple setups. You are expected to provide your own persistence-backed repositories (database, filesystem, etc.) in your application.
Agent factory from configuration
Contract
AdachSoft\AiAgentConfigRepository\PublicApi\AiAgentFromConfigFactoryInterface
Public API for creating AiAgentFacadeInterface instances based on AgentId.
Method:
public function createById(AgentId $agentId, ?PublicEventPublisherInterface $publicEventPublisher = null): AiAgentFacadeInterface;
Exceptions:
AgentNotFoundException– when configuration for the given agent id does not exist,AgentRuntimeBuildFailedException– when the runtime agent cannot be built (e.g. missing prompt, failure inAiAgentBuilder).
Implementation
AdachSoft\AiAgentConfigRepository\Infrastructure\Factory\AiAgentFromConfigFactory
The factory uses:
AgentConfigRepositoryInterface– to loadAgentDefinitionDto,SystemPromptRepositoryInterface– to load the system prompt text,AgentDefinitionMapperInterface– to map the definition toadachsoft/ai-agentDTOs,ToolCallingChatFacadeInterfaceandAiToolCallFacadeInterface– provided ports,AiAgentBuilder– to build the finalAiAgentFacadeInterfaceinstance.
This keeps all mapping from configuration to runtime agent in a single place.
Usage example
use AdachSoft\AiAgentConfigRepository\Infrastructure\Factory\AiAgentFromConfigFactory;
use AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemoryAgentConfigRepository;
use AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemorySystemPromptRepository;
use AdachSoft\AiAgentConfigRepository\PublicApi\Vo\AgentId;
use AdachSoft\AiAgentConfigRepository\SPI\Mapper\AgentDefinitionMapperInterface;
use AdachSoft\AiIntegration\PublicApi\ToolCalling\ToolCallingChatFacadeInterface;
use AdachSoft\AiToolCall\PublicApi\AiToolCallFacadeInterface;
$agentConfigRepository = new InMemoryAgentConfigRepository();
$systemPromptRepository = new InMemorySystemPromptRepository();
$mapper = /* your implementation of AgentDefinitionMapperInterface */;
$toolCallingChatFacade = /* your implementation of ToolCallingChatFacadeInterface */;
$aiToolCallFacade = /* your implementation of AiToolCallFacadeInterface */;
$factory = new AiAgentFromConfigFactory(
$agentConfigRepository,
$systemPromptRepository,
$mapper,
$toolCallingChatFacade,
$aiToolCallFacade,
);
$agentId = new AgentId('my-agent');
$agentFacade = $factory->createById($agentId);
$response = $agentFacade->chat('Hello!');
Tests and quality
The project is configured to work with:
- PHPUnit – unit tests in the
tests/directory, - PHPStan – static analysis configured via
phpstan.neon(coverssrc/andtests/), - Rector – automated refactoring rules configured in
rector.php.
Run tests:
vendor/bin/phpunit
Run PHPStan:
vendor/bin/phpstan analyse src tests
Run Rector in dry-run mode:
vendor/bin/rector process src tests --dry-run