Skip to content

goose: wire session resume on workspace restart #744

@mafredri

Description

@mafredri

Problem

Goose has native SQLite-based session persistence (~/.local/share/goose/sessions/sessions.db) and supports resuming named sessions via goose run --resume --name <name>. However, start.sh always starts a fresh session with no resume logic. It also doesn't pass --type goose to agentapi.

The module currently passes the task prompt via --instructions "$PROMPT_FILE". On resume, this must be skipped to avoid re-sending the task into an active conversation.

Desired outcome

  • On cold start (no prior session): Goose creates a named session and processes the task prompt.
  • On warm start (prior session exists): Goose resumes the named session. The task prompt (--instructions) is not re-sent.
  • --type goose is passed to agentapi server.
  • After feat(coder/modules/agentapi): add state persistence #736 lands: enable_state_persistence = true.

Claude Code's start.sh is the reference implementation for this pattern (session detection, conditional resume, prompt skipping).

Key upstream behaviors

  • goose run --resume --name X when session X doesn't exist: Goose warns and creates a new session (block/goose#3904). This is a safe fallback.
  • The SQLite DB uses WAL mode, meaning sessions.db-wal and sessions.db-shm sidecar files must be on the same persistent volume.
  • sqlite3 CLI may not be installed in all workspace images. Session detection should not depend on it, or should degrade gracefully.
  • block/goose#6236 reported subprocess panics when resuming without a TTY. AgentAPI provides a PTY but this combination should be tested.

Version bump

minor

Refs #696

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions