`memorix background start` hangs indefinitely when triggered from OpenCode AI agent
Description
When the memorix background start command is executed via OpenCode's Bash tool (e.g., from an AI agent), the process hangs and cannot be terminated until bash timeout. The user has to forcefully stop the AI agent output to regain control.
Steps to Reproduce
- Have Memorix v1.0.6 installed
- In OpenCode, invoke a task that calls
memorix background startvia the Bash tool - Observe that the command hangs indefinitely
- The only resolution is to stop the AI agent output entirely
Environment
- Memorix version: 1.0.6
- Trigger: AI agent calling
memorix background startvia OpenCode Bash tool - Does NOT reproduce when the user runs the same command directly in OpenCode Terminal.
Expected Behavior
- Command should start in background and return control immediately
- OR: If background start requires a foreground phase (setup/registration), it should complete and exit within a reasonable time
- User should be able to interrupt with standard signals
Actual Behavior
Process hangs indefinitely when started from OpenCode AI agent context. Works fine when run directly by user in terminal.
Additional Context
The issue appears to be specific to how OpenCode's Bash tool spawns subprocesses — when an AI agent invokes the command, the process becomes detached in a way that prevents standard signal propagation. Direct terminal invocation works correctly.
This suggests the problem is in how the Bash tool handles background processes for AI agent commands, not Memorix itself or type of how this Memorix command is handled in terminal.
Priority
Medium — Hinders AI agent workflows that need to start Memorix background service, but workaround exists (user can start it manually before agent invocation).
this is a really common pattern with background daemons launched from AI agent bash tools. the issue is usually that the spawned process inherits the parent's stdout/stderr file descriptors, so the bash tool waits for those FDs to close even though the main process has daemonized. the fix on the daemon side is making sure you redirect stdout and stderr to /dev/null (or a log file) before the process detaches. on the caller side, you can work around it with something like memorix background start > /dev/null 2>&1 & but that's a band-aid. we ran into the same thing launching background services from agent tool calls and the proper fix was always in the daemon's fork/exec path, closing inherited FDs explicitly.
our tool executor that manages background process spawning and FD cleanup from within agent tool calls: https://github.com/m13v/fazm/blob/main/Desktop/Sources/Providers/ChatToolExecutor.swift
Thanks for the detailed diagnosis and the implementation reference. We’ve confirmed this is a real background-process issue on our side, and we’ll address it in the upcoming v1.0.7 line. The fix will focus on making background startup and detach behavior reliable from agent-driven tool execution paths, rather than relying on caller-side workarounds.
glad it was useful. the agent-driven launch path is a bit of an underspecified contract across a lot of tools right now. will be interesting to see how you handle the detach behavior in v1.0.7 - if you end up publishing any notes on the approach, would be good context for anyone else running into this.
Fixed in v1.0.7 memorix background start now detects non-TTY environments (AI agent bash tools) and skips the 30-second health check wait loop, returning immediately after spawning the background process. The process still becomes healthy asynchronously. Check status with: memorix background status