Skip to content

sourcegraph-amp: wire thread resume with thread ID persistence #748

@mafredri

Description

@mafredri

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).
  • After feat(coder/modules/agentapi): add state persistence #736 lands: enable_state_persistence = true.

Investigation needed first

Test these approaches for capturing the thread ID:

  1. Check if Amp sets an AMP_THREAD_ID environment variable.
  2. Parse --stream-json output for a thread/session identifier.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions