agentd logs misses latest persistent event when session file lacks trailing newline

t-816·WorkTask·
·
·
Created15 hours ago·Updated14 hours ago·pipeline runs →

Dependencies

Description

Edit

After , persistent session log can contain a valid JSON object without a trailing newline (e.g. initial custom agent_start). prints because log reader drops trailing partial line unconditionally. This makes resets look broken and hides recent activity. Repro: reset with --clear-log, inspect session file contains JSON but no newline count, run logs returns no entries.

Git Commits

70daf843fix(agentd): realtime persistent logs and trailing-line parse
Coder Agent14 hours ago3 files

Timeline (6)

💬[human]15 hours ago

Correction: Repro is: (1) run 'agentd reset omni-coder --mode persistent --clear-log'; (2) check ~/.local/state/agentd-agents/sessions/omni-coder.jsonl contains a JSON event without trailing newline; (3) run 'agentd logs omni-coder --mode persistent --last 5' and it prints '-- No entries --'. Reader currently drops trailing non-newline JSONL chunk even when it is valid JSON.

🔄[human]Open → InProgress14 hours ago
💬[human]14 hours ago

Fixed in commit 70daf843.

Changes:

  • Omni/Agentd/SessionLog.hs
  • splitCompleteJsonlLines now keeps a trailing line when it is valid JSON even if file lacks final newline.
  • prevents agentd logs --last ... from hiding freshest valid event at EOF.
  • Omni/Agentd/Daemon.hs tests
  • added regression tests:
  • splitter keeps trailing valid JSON without newline
  • tail reader keeps trailing valid JSON without newline
  • Omni/Agent.hs
  • flush stdout (hFlush) after each JSON trace event and JSON result line.
  • removes long buffering lag in persistent session JSONL writes under systemd/tee.

Verification:

  • lint Omni/Agent.hs Omni/Agentd/SessionLog.hs Omni/Agentd/Daemon.hs
  • typecheck.sh Omni/Agent.hs
  • typecheck.sh Omni/Agentd/Daemon.hs
  • bild --test Omni/Agentd/Daemon.hs
  • bild Omni/Agent.hs
  • bild Omni/Agentd.hs

Runtime smoke on omni-coder:

  • Restarted persistent agent to pick up new binaries/runtime assets.
  • Sent probe: echo after-flush-fix via agentd send ...
  • agentd logs omni-coder --mode persistent --last 10 now immediately showed infer/tool/result events and completion.
🔄[human]InProgress → Review14 hours ago