Skip to main content
Back

npcpy Packs Multi-Agent Teams, Memory Graphs, and Fine-Tuning Into one Open-Source Library

npcpy bundles agents, knowledge graphs, sleep-and-dream memory cycles, and fine-tuning into a single Python library for local or cloud LLMs.

  • npcpy bundles agents, knowledge graphs, and fine-tuning into one MIT-licensed Python library.
  • Works with Ollama, OpenAI, Anthropic, Gemini, MLX, and other providers through LiteLLM.
  • NPCArray offers NumPy-style parallel operations across populations of LLM agents.
  • Knowledge graphs evolve through waking, sleep consolidation, and dream synthesis phases.
  • Sememolution runs genetic selection over a population of KG variants for retrieval.
  • Includes SFT, DPO, and diffusion fine-tuning utilities alongside the agent framework.

Most agent frameworks pick a lane: orchestration, memory, tool calling, or fine-tuning. npcpy tries to be all of them at once, packaging multi-agent teams, a knowledge graph with a sleep/dream lifecycle, parallel model arrays, and SFT/DPO training into one MIT-licensed Python library. It has crossed 1.4k stars on GitHub, and the design choices are unusual enough to be worth a closer look.

The library provides primitives for research and development with multimodal language models, agentic AI, and knowledge graphs, with support for local runtimes like Ollama, llama.cpp, omlx, and LM Studio alongside cloud providers. Everything hangs off a single abstraction, the NPC (Non-Player Character), which carries a persona, a directive, tools, and memory across whichever backend you point it at.

Agents that know what they are

The core object is an NPC with a name, a primary directive, and a model/provider pair. Three agent subclasses sit on top: Agent with default tools, ToolAgent for custom tools plus MCP, and CodingAgent that auto-executes code blocks from LLM responses. The tool set on the base Agent already includes shell, Python, file editing, and web search, so a two-line agent can list every Python file over 500 lines in a repo without extra wiring.

Teams are defined either in code or through files on disk. A team.ctx YAML file picks a coordinator (the forenpc), each agent lives in its own