22
22
class AgentAggregate implements AgentInterface,
23
23
HasLinkedAgentsInterface,
24
24
HasLinkedToolsInterface,
25
- HasLinkedContextSourcesInterface
25
+ HasLinkedContextSourcesInterface,
26
+ MetadataAwareInterface
26
27
{
27
- /**
28
- * @var array<TAssociation>
29
- */
28
+ /** @var array<TAssociation> */
30
29
private array $ associations = [];
31
30
32
31
public function __construct (
@@ -92,7 +91,7 @@ public function getMemory(): array
92
91
{
93
92
return \array_values (
94
93
\array_filter (
95
- $ this ->agent -> getMetadata (),
94
+ $ this ->getMetadata (),
96
95
static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Memory,
97
96
),
98
97
);
@@ -102,7 +101,7 @@ public function getPrompts(): array
102
101
{
103
102
return \array_values (
104
103
\array_filter (
105
- $ this ->agent -> getMetadata (),
104
+ $ this ->getMetadata (),
106
105
static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Prompt,
107
106
),
108
107
);
@@ -115,7 +114,7 @@ public function getConfiguration(): array
115
114
{
116
115
return \array_values (
117
116
\array_filter (
118
- $ this ->agent -> getMetadata (),
117
+ $ this ->getMetadata (),
119
118
static fn (SolutionMetadata $ metadata ): bool => $ metadata ->type === MetadataType::Configuration,
120
119
),
121
120
);
@@ -128,11 +127,9 @@ public function addAssociation(Solution $association): void
128
127
$ this ->associations [] = $ association ;
129
128
}
130
129
131
- public function addMetadata (SolutionMetadata ...$ metadatum ): void
130
+ public function addMetadata (SolutionMetadata ...$ metadata ): void
132
131
{
133
- foreach ($ metadatum as $ metadata ) {
134
- $ this ->agent ->addMetadata ($ metadata );
135
- }
132
+ $ this ->agent ->addMetadata (...$ metadata );
136
133
}
137
134
138
135
private function validateDependency (Solution $ association ): void
@@ -145,4 +142,17 @@ private function validateDependency(Solution $association): void
145
142
}
146
143
}
147
144
}
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
+ }
148
158
}
0 commit comments