7fce21c145
When using the OpenClaw integration, a single user message would produce 3 prompt records because session_start, message_received, after_compaction, and before_agent_start each independently called /api/sessions/init with different session keys. Changes: - Centralize /api/sessions/init to before_agent_start only - Add canonical session key unification (sessionKey, conversationId, channelId mapped to a single contentSessionId) - Add 2-second dedup guard for edge cases - Fix cwd: "" in tool_result_persist (use workspaceDir fallback chain, skip + warn if unavailable) - Add delayed session completion (configurable, default 5s) to avoid race with in-flight observations - Clean up all tracking Maps on session_end and gateway_start Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>