Skip to content

Commit 54104d9

Browse files
committed
bug #358 [AIBundle] Fix single agent alias (Guikingone)
This PR was merged into the main branch. Discussion ---------- [AIBundle] Fix single agent alias | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | Fix #355 | License | MIT Small fix related to agent injection. Commits ------- bbcf491 fix(aibundle): agent alias rollback
2 parents a7ff987 + bbcf491 commit 54104d9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/ai-bundle/src/AiBundle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
112112
foreach ($config['agent'] as $agentName => $agent) {
113113
$this->processAgentConfig($agentName, $agent, $builder);
114114
}
115+
if (1 === \count($config['agent']) && isset($agentName)) {
116+
$builder->setAlias(AgentInterface::class, 'ai.agent.'.$agentName);
117+
}
115118

116119
foreach ($config['store'] ?? [] as $type => $store) {
117120
$this->processStoreConfig($type, $store, $builder);

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function testInjectionAgentAliasIsRegistered()
4646
],
4747
]);
4848

49+
$this->assertTrue($container->hasAlias('Symfony\AI\Agent\AgentInterface'));
4950
$this->assertTrue($container->hasAlias('Symfony\AI\Agent\AgentInterface $myAgentAgent'));
5051
}
5152

0 commit comments

Comments
 (0)