Title#
Restore agent-runner.log in agent-worker InvocationProcessor
Problem#
After the fire-and-forget BullMQ refactor, InvocationProcessor stopped creating meta/agent-runner.log, leaving the viewer returning 404 and removing the human-readable audit trail for pipeline runs.
Task / Link#
Closes AgentSDE/agent-core#496
Changes#
- Switch
stdiofrom fd-based (['ignore', stdoutFd, stderrFd]) to pipe mode (['ignore', 'pipe', 'pipe']) - Add
cetTs()helper returning CET/CEST timestamps insv-SElocale format - Open
agent-runner.login append mode and write timestamped start header, per-chunk entries, and completion footer - Parse stdout JSON lines:
tool_use→[tool:X],text→[text]; malformed lines are silently skipped - Write stderr chunks to log with
stderr:prefix - Add
logEndedboolean guard to prevent write-after-end errors - Accumulate stdout in memory buffer (avoids file-read race after WriteStream close)
- Add unit tests covering: log creation/format, JSON line parsing,
logEndedguard, error path
Notes#
process()is fire-and-forget — result is pushed tophase-resultqueue asynchronously in theclosehandler- Pipe mode keeps the worker's event loop alive while the child runs, which is correct for a long-running BullMQ worker
Testing#
- Unit tests: 7 passing — log creation, start header format, footer format,
[tool:X]/[text]parsing, malformed JSON resilience,logEndedguard, error entry on spawn failure - Verified with
npm run lint(zero warnings/errors) andnpm run test