long_term_memory: true without an embedding model crashes the entire server (unrecovered panic in saveCurrentConversation)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu trong knowledgebase.go tại Agent.saveCurrentConversation, sau đó lần theo callback qua consumeJob trong agent.go và JobResult.Finish trong result.go. Tái hiện với long_term_memory được bật và không có mô hình embedding hoặc knowledge base, đồng thời xác minh rằng request được cấu hình sai báo lỗi mà không làm máy chủ kết thúc hoặc ảnh hưởng đến các agent khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
This is found and redacted by Claude, as I'm fucking unable to explain it better.
It's not a code review, but an actual crash I encountered while I let it work for me.
LocalAI version:
localai/localai:v4.9.0-gpu-nvidia-cuda-13 (LocalAI v4.9.0, commit f7ad3f70eb5d8a0ddf80e08557f0d7df28cf032e; vendored github.com/mudler/LocalAGI v0.0.0-20260606071251-14aed1ae4336)
Environment, CPU architecture, OS, and Version:
Linux ia 6.8.0-139-generic #139-Ubuntu SMP PREEMPT_DYNAMIC Sat Aug 1 03:52:05 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Bare-metal host (not a VM), Ubuntu 24.04.4 LTS, NVIDIA GeForce RTX 3090, driver 580.173.02, CUDA 13.0. Running via Docker Compose with runtime: nvidia. Backend: llama-cpp / cuda13-llama-cpp.
Describe the bug
Creating an agent via POST /api/agents (or PUT /api/agents/{name}) with "long_term_memory": true but without an embedding model installed/configured causes an unrecovered Go panic (nil pointer dereference) the first time that agent finishes a chat job and the framework tries to save the conversation. The panic is not scoped to the misconfigured agent's own goroutine — it crashes the entire local-ai process (PID 1 in the container). Docker's restart policy (unless-stopped) then restarts the container, which wipes the in-memory observables/job history for every agent on the instance (not just the misconfigured one) and briefly takes the whole API down for all users/agents while it reloads.
Root cause appears to be that long_term_memory depends on an embedding model (default seems to be granite-embedding-107m-multilingual, built-in chromem vector store) that was never installed on this instance, and the save-conversation code path dereferences it without a nil check.
To Reproduce
- Start LocalAI v4.9.0 with the agent pool enabled (default) and no embedding model installed (fresh instance, or one where
granite-embedding-107m-multilingualwas never pulled via the gallery). - Create an agent:
curl -X POST http://localhost:8080/api/agents \ -H "Content-Type: application/json" \ -d '{ "name": "test-agent", "model": "<any working chat model>", "system_prompt": "You are a test agent.", "api_url": "http://localhost:8080/v1", "api_key": "sk-local", "long_term_memory": true }' - Send it a chat message:
curl -X POST http://localhost:8080/api/agents/test-agent/chat \ -H "Content-Type: application/json" \ -d '{"message": "hello"}' - Wait for the model to generate a response and for the framework to attempt saving the conversation — the whole server crashes and restarts a few seconds later.
Expected behavior
The API should return an error for that specific request/agent (e.g. "long_term_memory requires an embedding model / knowledge base to be configured"), and the rest of the server (other agents, in-flight requests) should be unaffected. At minimum, the panic should be recovered at the job/goroutine level so one misconfigured agent can't take down the whole process.
Logs
Saving conversation agent="supervisor" conversation size=4
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xf9a3a9]
goroutine 7150 [running]:
github.com/mudler/LocalAGI/core/agent.(*Agent).saveCurrentConversation(0x1c1dad1543c0, {0x1c1da66b8f08, 0x4, 0x1c1da591c730?})
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/knowledgebase.go:176 +0x629
github.com/mudler/LocalAGI/core/agent.(*Agent).consumeJob.func8({0x1c1da66b8f08?, 0x4?, 0x4?})
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/agent.go:1420 +0x28
github.com/mudler/LocalAGI/core/types.(*JobResult).Finish(0x1c1da50fd290, {0x0?, 0x0?})
/root/go/pkg/mod/github.com/mudler/[email protected]/core/types/result.go:43 +0xdf
github.com/mudler/LocalAGI/core/agent.(*Agent).consumeJob(0x1c1dad1543c0, 0x1c1da566e180, {0x48076fd, 0x4})
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/agent.go:1423 +0x2b27
github.com/mudler/LocalAGI/core/agent.(*Agent).run(0x1c1dad1543c0, 0x1c1da4854e70)
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/agent.go:1543 +0xfd
github.com/mudler/LocalAGI/core/agent.(*Agent).Run.func1()
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/agent.go:1521 +0x3a
created by github.com/mudler/LocalAGI/core/agent.(*Agent).Run in goroutine 6913
/root/go/pkg/mod/github.com/mudler/[email protected]/core/agent/agent.go:1520 +0x1db
docker inspect on the container right after the crash showed ExitCode=0, OOMKilled=false, Error="", and docker events showed a die event with no preceding kill/stop action — confirming this is the process self-terminating on the panic, not an external kill/OOM.
Additional context
Workaround that resolves it: install an embedding model first (POST /models/apply with {"id": "localai@granite-embedding-107m-multilingual"}), then set both long_term_memory: true and enable_kb: true together on the agent (long_term_memory alone is not enough / is what triggers the crash). Retested with the same repro steps after applying the workaround: no panic, container RestartCount unchanged, GET /api/agents/collections shows a collection for the agent, and the job's observables history shows a clean "Recall" step (KB auto-search) before the actual response.
Found while building a multi-agent setup (Planner/Coder/Reviewer/Supervisor) on top of LocalAI's native agent pool.
Regards
- Ngôn ngữ chính
- Go
- Star
- 50k
- Fork
- 4.6k
- Merge trung bình
- 20 giờ 40 phút
- Pull request đã merge (30 ngày)
- 341
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mudler/LocalAI
-
[Bug] Qwen3.8-27b Uncensored Fails to Download due to 404Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug unconfirmed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Realtime: ASR EOU language tags leak into the LLM conversation (unintended reply-language switching)Có thể đã có người làm @nexxtmobile đã nhận 11 ngày trước. Đang mởarea/api bug unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Open Responses API doesn't accept "output_text" as an input ItemCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mudler/LocalAI#12337 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gallery model audio-cpp-sortformer-diarization fails to install: SHA mismatch, reproducible across retriesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
mudler/LocalAI#11995 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Agent pool Postgres DSN is logged in cleartext, including the password, while the auth DSN is redactedCó thể đã có người làm @localai-org-maint-bot đã nhận 46 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
mudler/LocalAI#11991 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của mudler/LocalAI
Issue tương tự
-
VLAgent `spec.k8sCollector.includePodLabels: false` has no effectCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
VictoriaMetrics/operator#2772 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Gaurav-Gosain/tuios#1316 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs: investigation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:auth documentation priority:low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
kube-tarian/sigrun#203 ·