Skip to content

gemini: wire session resume on workspace restart #745

Closed as not planned
Closed as not planned

Description

@mafredri

Problem

Gemini CLI supports gemini --resume "latest" for resuming the most recent session, and stores session JSON files under ~/.gemini/tmp/<project_hash>/chats/. The module's start.sh always starts a fresh session with no resume logic. It also doesn't pass --type gemini to agentapi.

The module currently passes the task prompt via --prompt-interactive "$PROMPT". On resume, this must be skipped.

Desired outcome

  • On cold start: Gemini starts normally with the task prompt.
  • On warm start (prior sessions exist): Gemini resumes the latest session. The task prompt is not re-sent.
  • --type gemini is passed to agentapi server.
  • Expose enable_state_persistence in main.tf (default true) and pass it through to the module "agentapi" block so the Coder UI preserves chat history across restarts, matching the agent's resumed session.

Key upstream behaviors

  • Critical: --resume "latest" causes a dead loop when no sessions exist (google-gemini/gemini-cli#15892). The module MUST check for existing sessions before passing --resume. Session files live under ~/.gemini/tmp/*/chats/*.json.
  • Session files can grow very large (400MB+ reported in google-gemini/gemini-cli#15292) for long-running tasks.

Version bump

minor

Refs #696, coder/internal#1258

Activity

  1. added theissue type on Feb 23, 2026
  2. Harsh9485 commented on Mar 18, 2026

    @Harsh9485
    Contributor

    I'm working on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions