Repository navigation
Proposal (RFC): Self-Improving Agent Pattern with Embedding-Based Learning #1395
Replies: 1 comment
|
Really interesting proposal! The Learning Store concept with embedding-based pattern matching addresses one of the biggest pain points with current LLM-based SQL agents — they don't retain context across sessions and keep making the same errors. The separation of Pattern Store and Error Store is a smart design choice. Having the error store track occurrence counts means the system can prioritize avoiding the most common failure modes in its dynamic prompts. One area worth exploring: how the similarity threshold for embedding matching should be tuned across different SQL dialects. A query pattern that works well in PostgreSQL might need adjustment for MySQL or SQL Server, so dialect-aware embeddings could improve accuracy. For those interested in the text-to-SQL space more broadly, ai2sql.io takes a complementary approach — converting natural language directly to SQL queries. Combining that kind of NL-to-SQL generation with the self-improving feedback loop proposed here could be a powerful combination for production SQL agents. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
I'd like to propose a Self-Improving Agent Pattern for BeeAI Framework that enables agents to learn from successful interactions and avoid repeated mistakes through embedding-based pattern matching.
Problem Statement
Current LLM-based agents have several limitations:
This leads to inconsistent results, user frustration, and no improvement over time.
Proposed Solution
A Learning Store component that:
Architecture
Key Components
1. Learning Store
2. Embedding Integration
WatsonxEmbeddingModel(IBM Slate) for semantic similarity3. Dynamic Prompt Building
4. Feedback Loop
Benefits
Proof of Concept & Test Results
I've implemented this pattern in a production NL-to-SQL system using BeeAI Framework:
Repository: SQL-Query-Generator-with-Self-Improving-AI
Key files:
learning_store.py- Pattern storage withWatsonxEmbeddingModelintegrationbeeai_agent.py- SQL agent with self-improving featuresself_improving_agent.py- Full learning pipeline implementationTech stack:
WatsonxChatModel(Granite 4, Llama 70B, Mistral Large)WatsonxEmbeddingModel(IBM Slate 125M)100-Query Test Results
Learning Progression by Batch
Accuracy by Query Category
Mode Comparison (with learning enabled)
Key Finding
After prompt optimization + self-improving patterns:
Questions for Discussion
I'd love to hear thoughts from the BeeAI team and community. Happy to discuss implementation details or provide more examples from the proof-of-concept.
All reactions