Gaming • AI • Entertainment
BepInEx mod that adds a persistent, LLM-driven NPC companion to Valheim. The companion (default name: Sigrid) uses the lab's LiteLLM endpoint to make real-time decisions, respond to player chat in-character, manage inventory, fight enemies, eat food, and follow commands.
Creators: Ken Boustead + Codie (Claude Code CLI)
Started: 2026-04-07
Status: Active Development Phase 4 Complete and In Testing.
Architecture
Single BepInEx plugin DLL targeting net471 (Unity Mono). Runs on both dedicated server and client — companion ZDO lives server-side, GameObject lives client-side.
Runtime: BepInEx 5.4 + HarmonyX + Jotunn 2.29.0 on Valheim (Unity 6)
LLM Backend: LiteLLM proxy <SERVER_IP>:4000 → Ollama <SERVER_IP>:11434, dual RTX 3060 12GB headless linux OS
Model: gemma4:e4b (Gemma 4 27B 4-bit) via ollama_chat/ provider with think: false
File Purpose
src/Plugin.cs BepInEx entry point
src/CompanionConfig.cs All BepInEx ConfigEntry definitions
src/Companion/CompanionPrefab.cs Prefab build + ZNetScene injection + spawn/despawn RPCs
src/Companion/LLMCompanionBehaviour.cs Per-companion MonoBehaviour — AI loop, action dispatch, food system, inventory management
src/Companion/CompanionZDO.cs ZDO persistence (companion data + inventory serialization)
src/LLM/LLMConnector.cs WebClient HTTP on ThreadPool + ConcurrentQueue drain on main thread
src/LLM/LLMRequest.cs Request DTOs + hand-rolled ToJson()
src/LLM/LLMRequestBuilder.cs Personality + game state prompt construction
src/LLM/GameStateBuilder.cs JSON snapshot of game state for LLM context
src/Commands/ChatCommandHandler.cs Chat.SendText Harmony patch for @Sigrid
src/Patches/WorldLoadPatch.cs ZNetScene.Awake postfix — prefab registration
Built with