Problem
Amp stores threads entirely server-side on Sourcegraph's infrastructure. Resume uses amp threads continue [threadId], which is a subcommand rather than a flag. The module currently creates a new thread on every startup by piping the prompt via echo "$PROMPT" | amp. There is no mechanism to capture or reuse a thread ID across restarts.
--type amp is already present. No --type change needed.
Desired outcome
- On cold start: Amp starts a new thread. The thread ID is captured and persisted.
- On warm start: Amp continues the prior thread via
amp threads continue <threadId>. The prompt delivery mechanism changes entirely (from stdin pipe to subcommand).
- 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.
Investigation needed first
Test these approaches for capturing the thread ID:
- Check if Amp sets an
AMP_THREAD_ID environment variable.
- Parse
--stream-json output for a thread/session identifier.
- Use
amp threads list after the first run. Check if it supports machine-readable output.
Also verify:
- What happens with
amp threads continue <invalidId>?
- Does
amp threads continue work reliably in headless mode via agentapi?
Thread resume requires network connectivity to Sourcegraph servers. Air-gapped environments cannot use it.
Version bump
minor
Refs coder/internal#1258
Problem
Amp stores threads entirely server-side on Sourcegraph's infrastructure. Resume uses
amp threads continue [threadId], which is a subcommand rather than a flag. The module currently creates a new thread on every startup by piping the prompt viaecho "$PROMPT" | amp. There is no mechanism to capture or reuse a thread ID across restarts.--type ampis already present. No--typechange needed.Desired outcome
amp threads continue <threadId>. The prompt delivery mechanism changes entirely (from stdin pipe to subcommand).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.Investigation needed first
Test these approaches for capturing the thread ID:
AMP_THREAD_IDenvironment variable.--stream-jsonoutput for a thread/session identifier.amp threads listafter the first run. Check if it supports machine-readable output.Also verify:
amp threads continue <invalidId>?amp threads continuework reliably in headless mode via agentapi?Thread resume requires network connectivity to Sourcegraph servers. Air-gapped environments cannot use it.
Version bump
minorRefs coder/internal#1258