diff --git a/src/Agent/AgentAggregate.php b/src/Agent/AgentAggregate.php index 6c4655d..9a9240e 100644 --- a/src/Agent/AgentAggregate.php +++ b/src/Agent/AgentAggregate.php @@ -22,11 +22,10 @@ class AgentAggregate implements AgentInterface, HasLinkedAgentsInterface, HasLinkedToolsInterface, - HasLinkedContextSourcesInterface + HasLinkedContextSourcesInterface, + MetadataAwareInterface { - /** - * @var array - */ + /** @var array */ private array $associations = []; public function __construct( @@ -92,7 +91,7 @@ public function getMemory(): array { return \array_values( \array_filter( - $this->agent->getMetadata(), + $this->getMetadata(), static fn(SolutionMetadata $metadata): bool => $metadata->type === MetadataType::Memory, ), ); @@ -102,7 +101,7 @@ public function getPrompts(): array { return \array_values( \array_filter( - $this->agent->getMetadata(), + $this->getMetadata(), static fn(SolutionMetadata $metadata): bool => $metadata->type === MetadataType::Prompt, ), ); @@ -115,7 +114,7 @@ public function getConfiguration(): array { return \array_values( \array_filter( - $this->agent->getMetadata(), + $this->getMetadata(), static fn(SolutionMetadata $metadata): bool => $metadata->type === MetadataType::Configuration, ), ); @@ -128,11 +127,9 @@ public function addAssociation(Solution $association): void $this->associations[] = $association; } - public function addMetadata(SolutionMetadata ...$metadatum): void + public function addMetadata(SolutionMetadata ...$metadata): void { - foreach ($metadatum as $metadata) { - $this->agent->addMetadata($metadata); - } + $this->agent->addMetadata(...$metadata); } private function validateDependency(Solution $association): void @@ -145,4 +142,17 @@ private function validateDependency(Solution $association): void } } } + + public function getMetadata(): array + { + $metadata = $this->agent->getMetadata(); + + foreach ($this->associations as $association) { + if ($association instanceof MetadataAwareInterface) { + $metadata = \array_merge($metadata, $association->getMetadata()); + } + } + + return $metadata; + } } diff --git a/src/Agent/MetadataAwareInterface.php b/src/Agent/MetadataAwareInterface.php new file mode 100644 index 0000000..f466b61 --- /dev/null +++ b/src/Agent/MetadataAwareInterface.php @@ -0,0 +1,14 @@ + @@ -17,9 +19,11 @@ public function __construct( public readonly ?string $description = null, ) {} - public function addMetadata(SolutionMetadata $metadata): void + public function addMetadata(SolutionMetadata ...$metadata): void { - $this->metadata[] = $metadata; + foreach ($metadata as $meta) { + $this->metadata[] = $meta; + } } public function getMetadata(): array