Skip to content

Session end lifecycle missing for OpenCode, Gemini CLI, and Codex #48

@Alan-TheGentleman

Description

@Alan-TheGentleman

Context

PR #47 fixes session-stop for Claude Code by calling POST /sessions/{id}/end from the hook. But the other three agents have no equivalent — their sessions always have ended_at = NULL.

Current state

Agent Session start Session end
Claude Code session-start.sh hook → POST /sessions session-stop.sh hook → POST /sessions/{id}/end (PR #47)
OpenCode engram.ts plugin → POST /sessions Nothing
Gemini CLI MCP mem_session_start via protocol Nothing
Codex MCP mem_session_start via protocol Nothing

What's already available

The MCP tool mem_session_end exists and works. Agents just need to be told to call it.

Proposed fix per agent

  • OpenCode: Add a session-end event handler in engram.ts that calls POST /sessions/{id}/end (same pattern as the session creation handler)
  • Gemini CLI: Add instruction in the system prompt telling the agent to call mem_session_end before closing
  • Codex: Add instruction in the memory config telling the agent to call mem_session_end before closing

Why it matters

Without ended_at, session duration is unknown, the session list grows unbounded with no way to tell which sessions are active vs finished, and any future cleanup/retention logic can't distinguish stale sessions from ongoing ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions