feat: knowledge base for long-term memory (#1099)#1115
feat: knowledge base for long-term memory (#1099)#1115bitloi wants to merge 44 commits intoeigent-ai:mainfrom
Conversation
- Add SQLite-backed knowledge store (backend/app/utils/knowledge_base.py) with add_entry, get_entries, delete_entry, get_context_for_prompt - Inject KB context into chat prompts via build_conversation_context (query-scoped retrieval when user question is available) - Add REST API: POST/GET/DELETE /knowledge (knowledge_controller) - Add remember_this tool (KnowledgeBaseToolkit) for developer agent to save facts to the project KB; register in get_toolkits for custom agents - Developer system message: use remember_this for important facts/decisions
…PI tests - knowledge_base: use os.environ.get instead of app.component.environment.env so tests run from backend/ without repo-root utils - tests: add test_knowledge_base.py (add/get/delete, query filter, context, wrong project no-op) and TestClient API test (POST/GET/DELETE /knowledge)
- Resolve router.py: use main's logging, add knowledge_controller - Accept deletion of backend/app/utils/agent.py (agent code moved to app/agent/) - Add knowledge base to new agent module: KnowledgeBaseToolkit in tools.py, developer.py (toolkit + tools + tool_names), remember_this in DEVELOPER_SYS_PROMPT
- Rebase KB changes onto upstream main chat_service: add get_knowledge_context import, query param and KB block in build_conversation_context, pass query= at simple-question, multi-turn simple, and question_confirm call sites
- router.py: align with main style (single-line imports/config), keep knowledge_controller - chat_service.py: add ActionTimeoutData import for main compatibility, keep knowledge base
|
@a7m-1st @4pmtong @Wendong-Fan Please review my pr. |
bytecii
left a comment
There was a problem hiding this comment.
Thanks for contribution. Left some comments.
|
@bytecii I just fixed the issues you mentioned, would you please review the updates again? |
|
@bitloi I don't think they are fixed |
…y, remove remember_this prompt, ruff lint
Sorry for the mistake, I didn't push the changes. |
|
@Wendong-Fan Would you please check the pr? |
@Wendong-Fan, thanks for the review! I made the changes you suggested - switched from SQLite to a simple markdown file at |
thanks @bitloi for the update! |
…dback) - memory_file: get_context_for_prompt -> get_index_for_prompt (first max_lines; cap at _MAX_INDEX_LINES); add MEMORY_ARCHITECTURE_PROMPT - knowledge_base_toolkit: remove remember_this/read_project_memory; agent uses file ops on .eigent/*.md; get_tools() returns [] - Validation, error handling, and tests updated for index-based design
…oi/eigent into feature/knowledge-base-1099
…mpt, doc toolkit - memory_file: remove append_memory, write_memory (unused in production); keep read_memory, get_index_for_prompt - chat_service: when knowledge_base_toolkit in data.tools, inject MEMORY_ARCHITECTURE_PROMPT and get_index_for_prompt(working_directory) into system prompt - knowledge_base_toolkit: doc why toolkit has no tools (signal for chat_service to inject memory prompt) - tests: use _write_memory helper instead of removed append/write_memory
|
@nitpicker55555 I fixed them. Would you mind reviewing it? |
- Remove KnowledgeBaseToolkit; add use_project_memory to NewAgent and ActionNewAgent - chat_service injects memory prompt when use_project_memory is true - Revert build_conversation_context to single-line args (no linter-only changes) - Regenerate uv.lock without ruff - Update tests: drop toolkit tests, keep memory_file tests
…oi/eigent into feature/knowledge-base-1099
|
@nitpicker55555 Can you check the changes again? |
|
@bitloi backend/app/router.py changes are still only linter changes. Please remove these linter changes @Wendong-Fan what do you think of the current design? |
@nitpicker55555 Fixed it. |
…ory, move tests, add continuation note - Rename memory_file.py to long_term_memory.py and update logger/imports - Rename use_project_memory to use_long_term_memory (NewAgent, ActionNewAgent, chat_service) - Add remaining line count to truncation note in get_index_for_prompt - Move tests to backend/tests/app/utils/test_long_term_memory.py - Add comment that memory index is snapshot at agent-creation time
|
@bytecii Ready for review! |
Description
Implements knowledge base for long-term memory (closes #1099).
What this PR does:
file_save_path/.eigent_knowledge/or~/.eigent). Table:project_id,content,created_at. Data persists across sessions.POST /knowledgewithproject_idandcontent. (2)remember_thistool for the developer agent (and custom agents viaknowledge_base_toolkit) so the assistant can save facts when the user asks.LIKE;get_context_for_prompt(project_id, query=...)builds a formatted string (max 4000 chars, 20 entries) for injection into prompts.build_conversation_context()prepends knowledge base context when building prompts. Used for simple-question answers, multi-turn simple path,question_confirm, and workforce context. Optionalquery(user question) filters relevant entries when available.GET /knowledge?project_id=...&query=...&limit=50,DELETE /knowledge/{id}?project_id=....No frontend changes; backend-only. Users can add entries via API (e.g. curl) or by asking the developer agent to remember something; retrieved KB is injected into chat context automatically.
What is the purpose of this pull request?