Problem
Two issues:
-
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.
-
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
continue defaults to true.
- The initial prompt is only sent on cold start, not when resuming an existing session.
- 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.
Version bump
minor
Refs coder/internal#1258
Problem
Two issues:
Resume is off by default. The module has full resume wiring (
--continue,--session,--type opencodeall present instart.sh) but thecontinuevariable inmain.tfdefaults tofalse. Out of the box, sessions are never resumed.Prompt is re-sent on resume. In
build_opencode_args(), the initial prompt is added toAGENTAPI_ARGSvia-I "$PROMPT"unconditionally whenARG_AI_PROMPTis set, regardless of whetherARG_CONTINUEis 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 = trueandai_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
--continuegracefully creates a new session when no prior sessions exist, so the default flip is safe for first-run scenarios.Desired outcome
continuedefaults totrue.enable_state_persistenceinmain.tf(defaulttrue) and pass it through to themodule "agentapi"block so the Coder UI preserves chat history across restarts, matching the agent's resumed session.Version bump
minorRefs coder/internal#1258