mudler / mudler/LocalAGI

panic: invalid memory address in Agent.saveCurrentConversation when LongTermMemory is enabled

Open
#405 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2k
Forks
291
Avg merge
30m
Merged PRs (30d)
3

Description

LocalAGI crashes with a panic: runtime error: invalid memory address or nil pointer dereference in core/agent/knowledgebase.go when an agent has LongTermMemory=true.

The crash happens right after the agent successfully returns a response and tries to save the conversation to LocalRecall.

  • LocalAGI: built from main
    • git log -1 --onelinecbe4cd6 (HEAD -> main, origin/main, origin/HEAD) fix: correct API url
  • Deployment: Docker Compose on WSL2 Ubuntu 24.04 (Windows 11 host)
  • GPU: NVIDIA RTX 3060 (using CUDA image for LocalAI)
  • Docker services (from docker-compose.yaml):
services:
  localai:
    image: localai/localai:master
    ports:
      - "8081:8080"
    environment:
      - DEBUG=true
    volumes:
      - ./volumes/models:/models
      - backends:/backends
      - images:/tmp/generated/images

  localrecall-postgres:
    image: quay.io/mudler/localrecall:${LOCALRECALL_VERSION:-v0.5.2}-postgresql
    environment:
      - POSTGRES_DB=localrecall
      - POSTGRES_USER=localrecall
      - POSTGRES_PASSWORD=localrecall
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  localrecall:
    image: quay.io/mudler/localrecall:${LOCALRECALL_VERSION:-v0.5.2}
    depends_on:
      localrecall-postgres:
        condition: service_healthy
      localai:
        condition: service_started
    ports:
      - "8080"
    environment:
      - DATABASE_URL=postgresql://localrecall:localrecall@localrecall-postgres:5432/localrecall?sslmode=disable
      - VECTOR_ENGINE=postgres
      - EMBEDDING_MODEL=granite-embedding-107m-multilingual
      - FILE_ASSETS=/assets
      - OPENAI_API_KEY=sk-1234567890
      - OPENAI_BASE_URL=http://localai:8080
      - HYBRID_SEARCH_BM25_WEIGHT=0.5
      - HYBRID_SEARCH_VECTOR_WEIGHT=0.5
    volumes:
      - localrag_assets:/assets

  localagi:
    # built from Dockerfile.webui
    build:
      context: .
      dockerfile: Dockerfile.webui
    depends_on:
      localai:
        condition: service_healthy
      localrecall-healthcheck:
        condition: service_completed_successfully
      dind:
        condition: service_healthy
    ports:
      - "8080:3000"
    environment:
      - LOCALAGI_MODEL=${MODEL_NAME:-gemma-3-4b-it-qat}
      - LOCALAGI_MULTIMODAL_MODEL=${MULTIMODAL_MODEL:-moondream2-20250414}
      - LOCALAGI_IMAGE_MODEL=${IMAGE_MODEL:-Z-Image-Turbo}
      - LOCALAGI_LLM_API_URL=http://localai:8080
      - LOCALAGI_LOCALRAG_URL=http://localrecall:8080
      - LOCALAGI_STATE_DIR=/pool
      - LOCALAGI_TIMEOUT=5m
      - LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false
      - LOCALAGI_SSHBOX_URL=root:root@sshbox:22
      - DOCKER_HOST=tcp://dind:2375
    volumes:
      - localagi_pool:/pool
     
http server started on 8080
...
status=200 ... host=localrecall:8080


Agent configuration
Created from the WebUI (http://localhost:8080/app):

Name: Nemo-Reasoning

Model: mistral-nemo-2407-local (served by LocalAI on http://localai:8080)

Multimodal model: granite-embedding-107m-multilingual

API URL: http://localai:8080

Local RAG URL (in Model Settings): http://localrecall:8080

Memory Settings:

Long-term Memory: ON

Summary Long-term Memory: OFF

Knowledge Base: OFF (or ON, crash happens even when KB is disabled)

From the logs, the agent config is printed as:

LongTermMemory=true
SummaryLongTermMemory=false
EnableKnowledgeBase=false
LocalRAGURL=http://localrecall:8080
...
time=2026-02-06T10:34:32.649Z level=INFO msg="Saving conversation" agent=Nemo-Reasoning conversation_size=2 source.file=work/core/agent/knowledgebase.go source.L131
time=2026-02-06T10:34:32.649Z level=DEBUG msg="Agent has finished" agent=Nemo-Reasoning source.file=work/core/agent/agent.go source.L197
time=2026-02-06T10:34:32.649Z level=INFO msg="Response from agent" agent=Nemo-Reasoning response="Hi there! It's great to meet you. What brings you here today? ..." source.file=work/webui/app.go source.L383

panic: runtime error: invalid memory address or nil pointer dereference
signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xf314ee

goroutine 45 [running]:
github.com/mudler/LocalAGI/core/agent.(*Agent).saveCurrentConversation(0xc000308b40, 0xc000723a40, 0x2, 0xc0002d62d0?)
    work/core/agent/knowledgebase.go:147 +0x36e
github.com/mudler/LocalAGI/core/agent.(*Agent).consumeJob.func6(...)
    work/core/agent/agent.go:1107 +0x28
github.com/mudler/LocalAGI/core/types.JobResult.Finish(0xc0003aa240, 0x0?, 0x0?)
    work/core/types/result.go:42 +0xe2
github.com/mudler/LocalAGI/core/agent.(*Agent).consumeJob(0xc000308b40, 0xc000102900, 0x1cbbb6f, 0x4)
    work/core/agent/agent.go:1110 +0x1ea5
github.com/mudler/LocalAGI/core/agent.(*Agent).run(0xc000308b40, 0xc0002e8700)
    work/core/agent/agent.go:1309 +0xf2
github.com/mudler/LocalAGI/core/agent.(*Agent).Run.func1(...)
    work/core/agent/agent.go:1287 +0x3a
created by github.com/mudler/LocalAGI/core/agent.(*Agent).Run in goroutine 51
    work/core/agent/agent.go:1286 +0x19b

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in core/agent/knowledgebase.go at saveCurrentConversation, especially line 147, then trace its caller in core/agent/agent.go around lines 1107-1110. Reproduce with LongTermMemory enabled and LocalRAGURL set to LocalRecall, and inspect the conversation-save path. Done means the agent returns without a nil-pointer panic and the conversation-save behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.