Skip to content

[Ai Bundle][Agent] Memory as service does not work #591

@chr-hertel

Description

@chr-hertel

I registered a custom service as memory provider like this:

ai:
    platform:
        openai:
            api_key: '%env(OPENAI_API_KEY)%'
    agent:
        default:
            model:
                class: 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'
                name: 'gpt-4o-mini'
            prompt: 'You are a pirate and you write funny.'
            memory: 'App\MyMemory'

And the implementation looks like this:

<?php

declare(strict_types=1);

namespace App;

use Symfony\AI\Agent\Input;
use Symfony\AI\Agent\Memory\Memory;
use Symfony\AI\Agent\Memory\MemoryProviderInterface;

final readonly class MyMemory implements MemoryProviderInterface
{
    public function __construct(
        private string $myMemory,
    ) {
    }

    public function load(Input $input): array
    {
        return [
            new Memory(file_get_contents($this->myMemory)),
        ];
    }
}

But this is always false for App\MyMemory:

if ($container->hasDefinition($memoryValue) || $container->hasAlias($memoryValue)) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI BundleIssues & PRs about the AI integration bundleAgentIssues & PRs about the AI Agent componentBugSomething isn't workingStatus: Needs Review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions