Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ai-bundle/src/AiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
$agentDefinition
->setArgument(2, []) // placeholder until ProcessorCompilerPass process.
->setArgument(3, []) // placeholder until ProcessorCompilerPass process.
->setArgument(4, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))
->setArgument(4, $name)
->setArgument(5, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))
;

$container->setDefinition($agentId, $agentDefinition);
Expand Down
27 changes: 27 additions & 0 deletions src/ai-bundle/tests/DependencyInjection/AiBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,33 @@ public function testAgentHasTag()
$this->assertArrayHasKey('ai.agent.my_agent', $container->findTaggedServiceIds('ai.agent'));
}

public function testAgentNameIsSetFromConfigKey()
{
$container = $this->buildContainer([
'ai' => [
'agent' => [
'my_custom_agent' => [
'model' => ['class' => 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'],
],
],
],
]);

$this->assertTrue($container->hasDefinition('ai.agent.my_custom_agent'));

$agentDefinition = $container->getDefinition('ai.agent.my_custom_agent');
$arguments = $agentDefinition->getArguments();

// The 5th argument (index 4) should be the config key as agent name
$this->assertArrayHasKey(4, $arguments, 'Agent definition should have argument at index 4 for name');
$this->assertSame('my_custom_agent', $arguments[4]);

// Check that the tag uses the config key as name
$tags = $agentDefinition->getTag('ai.agent');
$this->assertNotEmpty($tags, 'Agent should have ai.agent tag');
$this->assertSame('my_custom_agent', $tags[0]['name'], 'Agent tag should use config key as name');
}

#[TestWith([true], 'enabled')]
#[TestWith([false], 'disabled')]
public function testFaultTolerantAgentSpecificToolbox(bool $enabled)
Expand Down