2222class AgentAggregate implements AgentInterface,
2323 HasLinkedAgentsInterface,
2424 HasLinkedToolsInterface,
25- HasLinkedContextSourcesInterface
25+ HasLinkedContextSourcesInterface,
26+ MetadataAwareInterface
2627{
27- /**
28- * @var array<TAssociation>
29- */
28+ /** @var array<TAssociation> */
3029 private array $ associations = [];
3130
3231 public function __construct (
@@ -92,7 +91,7 @@ public function getMemory(): array
9291 {
9392 return \array_values (
9493 \array_filter (
95- $ this ->agent -> getMetadata (),
94+ $ this ->getMetadata (),
9695 static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Memory,
9796 ),
9897 );
@@ -102,7 +101,7 @@ public function getPrompts(): array
102101 {
103102 return \array_values (
104103 \array_filter (
105- $ this ->agent -> getMetadata (),
104+ $ this ->getMetadata (),
106105 static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Prompt,
107106 ),
108107 );
@@ -115,7 +114,7 @@ public function getConfiguration(): array
115114 {
116115 return \array_values (
117116 \array_filter (
118- $ this ->agent -> getMetadata (),
117+ $ this ->getMetadata (),
119118 static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Configuration,
120119 ),
121120 );
@@ -128,11 +127,9 @@ public function addAssociation(Solution $association): void
128127 $ this ->associations [] = $ association ;
129128 }
130129
131- public function addMetadata (SolutionMetadata ...$ metadatum ): void
130+ public function addMetadata (SolutionMetadata ...$ metadata ): void
132131 {
133- foreach ($ metadatum as $ metadata ) {
134- $ this ->agent ->addMetadata ($ metadata );
135- }
132+ $ this ->agent ->addMetadata (...$ metadata );
136133 }
137134
138135 private function validateDependency (Solution $ association ): void
@@ -145,4 +142,17 @@ private function validateDependency(Solution $association): void
145142 }
146143 }
147144 }
145+
146+ public function getMetadata (): array
147+ {
148+ $ metadata = $ this ->agent ->getMetadata ();
149+
150+ foreach ($ this ->associations as $ association ) {
151+ if ($ association instanceof MetadataAwareInterface) {
152+ $ metadata = \array_merge ($ metadata , $ association ->getMetadata ());
153+ }
154+ }
155+
156+ return $ metadata ;
157+ }
148158}
0 commit comments