#5021·hindsight

Hindsight coding-agents plugin causes MaxListenersExceededWarning and session hangs (58 hooks vs Node default cap of 10)

Author: jeremiah-cpCreated Oct 1, 2026Updated Oct 1, 2026
Labelsbug

Bug Description

Environment: OS: macOS (Apple Silicon) OpenCode: 1.18.30 (serve mode) Plugin: @vectorize-io/hindsight-coding-agents (installed via npx) Hindsight server: hindsight-all Python package, localhost:8888 LLM: Ollama qwen3-coder:30b (also used by OpenCode agents)

Issues: MaxListenersExceededWarning on boot The plugin registers ~58 lifecycle hooks across 5 categories (Git history, repo context, session monitoring). OpenCode's host runtime attempts to register all 58 without raising Node/Bun's default listener cap of 10. Log output: MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added to [yZ]. The event emitter jams. Server becomes intermittently unresponsive. Hook race condition (silent session failures) The integration uses session.created (flags session as "recalled") and system.transform (checks the flag before injecting memory). Due to execution order race, the system can flag a session as "recalled" before memory is injected, causing OpenCode to silently skip context recall. No error thrown. Agent acts as if it has no persistent context. Ollama model contention Both the Hindsight server and OpenCode agents default to the same Ollama model (qwen3-coder:30b). With OLLAMA_NUM_PARALLEL=1, Hindsight's memory operations block the agent's model calls and vice versa. Cloud models (which bypass local Ollama) work fine; local models hang indefinitely. Installer issues (macOS) If opencode.json is empty/missing structure, the installer writes invalid JSON (missing brackets, trailing commas). OpenCode crashes on next boot reading corrupt config. If terminal lacks write permission to ~/.hindsight/coding-agents/, installer fails silently halfway. OpenCode hangs looking for plugin files that don't exist.

Symptoms observed: Server accepts TCP connections but returns empty HTTP responses intermittently Sessions timeout with status: timeout, sometimes with agent response in transcript, sometimes without Local Ollama models stop responding entirely; cloud models work intermittently opencode --print-logs shows Hindsight service errors (when accessible)

Suggested fixes: Raise Node's listener cap or batch hook registration Fix hook execution order to prevent race Document Ollama contention; suggest separate models for Hindsight server vs agents Validate JSON before writing config; fail loudly on permission errors

Steps to Reproduce

Install OpenCode 1.18.30 Install Hindsight coding-agents plugin: npx @vectorize-io/hindsight-coding-agents (or via their installer) Start Hindsight server: hindsight-api on localhost:8888 (Ollama backend) Start OpenCode: opencode serve --port 4096 Observe MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added in server logs on boot Create a session using local Ollama model (qwen3-coder:30b) - session hangs, reports timeout Create a session using cloud model - works intermittently Server becomes unresponsive to new connections; process eventually gets killed

Expected Behavior

Expected: Plugin loads without warnings; sessions complete normally.

Actual Behavior

Actual: 58 hooks exceed Node's 10-listener default; event emitter jams; local models hang; server dies.

Version

No response

LLM Provider

Ollama