How deductive-ai/memgpt works
MemGPT is a perpetual-chat agent that manages short-term conversation context and longer-lived memory. Its principal workflow is: a user starts or resumes an agent in the CLI, the agent processes turns and model function calls, and persistence and archival storage support continued conversations and retrieval. The README also documents data loading, persona/human configuration, local LLMs, and AutoGen integration. Relationships below use README statements or the SOURCE INDEX reference lists; unsampled implementation details are not inferred.
Main entry points: main.py CLI application · agent.py Agent loop · storage.py Storage selection · cli.py CLI commands
Components 21
CLI and setup
- CLI commands
memgpt/cli/cli.py - Configuration
memgpt/cli/cli_config.py - CLI application
memgpt/main.py - Data loading
memgpt/cli/cli_load.py
Agent runtime
- Agent loop
memgpt/agent.py - Presets and prompts
memgpt/presets.py - Agent functions
memgpt/prompts/gpt_functions.py - Persona definitions
memgpt/personas/personas.py - Human definitions
memgpt/humans/humans.py
Memory and persistence
- Memory tiers
memgpt/memory.py - State persistence
memgpt/persistence_manager.py - Storage selection
memgpt/connectors/storage.py - Local archival store
memgpt/connectors/local.py - Postgres archival store
memgpt/connectors/db.py - Embedding models
memgpt/embeddings.py
Model integrations
- Chat completion
memgpt/openai_tools.py - Local model proxy
memgpt/local_llm/chat_completion_proxy.py
Integrations
- AutoGen adapter
memgpt/autogen/interface.py
Other components
- User
- LLM service
- Directory or database dump
Connections 22
- User → CLI commands: starts chat
README.md - CLI commands → CLI application: dispatches commands
memgpt/cli/cli.py - CLI application → Agent loop: runs agent
memgpt/main.py - CLI commands → Configuration: configures
memgpt/cli/cli.py - CLI application → Presets and prompts: selects preset
memgpt/main.py - Presets and prompts → Agent functions: uses prompts
memgpt/presets.py - CLI application → Persona definitions: loads persona
memgpt/main.py - CLI application → Human definitions: loads human
memgpt/main.py - Agent loop → Chat completion: requests completion
memgpt/agent.py - Chat completion → Local model proxy: routes local requests
memgpt/openai_tools.py - Chat completion → LLM service: calls model
README.md - Agent loop → Memory tiers: updates memory
memgpt/agent.py - Agent loop → State persistence: uses state manager
memgpt/agent.py - Memory tiers → Storage selection: uses archival storage
memgpt/memory.py - Storage selection → Local archival store: selects backend
memgpt/connectors/storage.py - Storage selection → Postgres archival store: selects backend
memgpt/connectors/storage.py - Memory tiers → Embedding models: computes embeddings
memgpt/memory.py - User → Data loading: loads source
README.md - Directory or database dump → Data loading: provides data
README.md - Data loading → Storage selection: stores passages
memgpt/cli/cli_load.py - User → AutoGen adapter: uses AutoGen
README.md - AutoGen adapter → Agent loop: adapts agent
memgpt/autogen/memgpt_agent.py