The deployed agentd daemon (PID 3077988, nix store path /nix/store/vf8n2ir0mb301rlng7n0m4aq0l43mdxk-agentd) fails to write to pi.log files immediately after creating them.
Symptoms:
Failed to write pi log: .../pi.log: hPutStr: illegal operation (handle is closed)Impact:
Root cause:
The log file handle opened in spawnPiAgentInner is being closed by something before the readPiOutput async can use it. The systemd service has ProtectSystem=strict with ReadWritePaths=/var/log/agentd, so permissions are fine (the file IS created). Possible GC or file descriptor issue in the deployed version.
Workaround: The agents web UI now shows the agent's summary (from daemon API) in a RESPONSE section, which provides basic send/receive feedback without requiring log files.
Fix needed: Debug why the log handle is closed. May require redeploying agentd with additional logging or a different handle management approach.
Fixed. pi.log handle bug resolved by using path-based append-per-line instead of persistent handle. Also added messages table to agentd DB for conversation history (user/assistant messages stored and served via GET /agents/:id/messages API). Web UI now renders chat thread from DB.