Skip to content

opencode: enable session resume by default and fix prompt re-delivery #742

@mafredri

Description

@mafredri

Problem

Two issues:

  1. Resume is off by default. The module has full resume wiring (--continue, --session, --type opencode all present in start.sh) but the continue variable in main.tf defaults to false. Out of the box, sessions are never resumed.

  2. Prompt is re-sent on resume. In build_opencode_args(), the initial prompt is added to AGENTAPI_ARGS via -I "$PROMPT" unconditionally when ARG_AI_PROMPT is set, regardless of whether ARG_CONTINUE is true. When a session is resumed, the task prompt gets re-injected into an already-active conversation, potentially re-triggering the original task.

To reproduce: set continue = true and ai_prompt = "some task". Start the module, have a conversation, stop, restart. The agent resumes the session but the task prompt is re-sent as a new message.

OpenCode's --continue gracefully creates a new session when no prior sessions exist, so the default flip is safe for first-run scenarios.

Desired outcome

Version bump

minor

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions