Skip to content

[Agent] Add basic setup for memory injections to system prompt #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

DZunke
Copy link
Contributor

@DZunke DZunke commented Jul 14, 2025

Q A
Bug fix? no
New feature? yes
Docs? yes
Issues
License MIT

See original contribution at php-llm/llm-chain#387

This PR introduces a flexible memory system that allows the LLM to recall contextual information that are permantent for the conversation. In difference to tools it can be always utilized, when use_memory option is not disabled. It would be possible to fetch memory by a tool with a system instruction like always call the tool foo_bar but, for me, this feels like a bad design to always force the model to do a tool call without further need.

Currently i have added just two memory providers to show what my idea is. I could also think about a write layer to fill a memory, together with a read layer, this could, for example, be working good with a graph database and tools for memory handling. But these are ideas for the future.

So for this first throw i hope you get what i was thinking about to reach. I decided to inject the memory to the system prompt, when it is available, instead of adding a second system prompt to the message bag. But this was just a 50/50 thinking. I tried both seem to be working equally, at least for open ai. I am open to change it back again.

What do you think?

@DZunke DZunke requested review from chr-hertel and Nyholm as code owners July 14, 2025 08:19
@DZunke DZunke force-pushed the agent-memory-processor branch 2 times, most recently from 3418c1f to 848ccc9 Compare July 14, 2025 08:29
@OskarStark OskarStark added the Agent Issues & PRs about the AI Agent component label Jul 14, 2025
@OskarStark OskarStark changed the title Add basic setup for memory injections to system prompt [Agent] Add basic setup for memory injections to system prompt Jul 14, 2025
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving this - that saves me some time 🙏

Found one small left over in the example, and please remove declare(strict_types=1); - then we're good to merge this :)

@OskarStark
Copy link
Contributor

please remove declare(strict_types=1); - then we're good to merge this :)

Can we update the PHP-CS-Fixer config?

@DZunke DZunke force-pushed the agent-memory-processor branch from 848ccc9 to d9b13f9 Compare July 15, 2025 18:05
@DZunke DZunke requested a review from OskarStark as a code owner July 15, 2025 18:05
@DZunke DZunke requested a review from chr-hertel July 15, 2025 18:06
@chr-hertel chr-hertel added the Feature New feature label Jul 16, 2025
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now 👍

image

@chr-hertel
Copy link
Member

Thank you @DZunke.

@chr-hertel chr-hertel merged commit 059db10 into symfony:main Jul 16, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants