Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

OpenCode 2.1: sessions are not found in the new database and continue --with opencode fails (opencode session import, flat transcript) #96

Open

Description

@acaprino

What happened?

OpenCode 2.1 changed its storage layout, its transcript shape and the CLI command that imports a transcript. With OpenCode 2.1.4 the opencode harness no longer reads or writes anything:

  1. Discovery finds nothing. txcript list --from opencode prints no local opencode sessions found against a 2.1.4 opencode.db that holds hundreds of sessions. 2.1 keeps sessions in session_v2 and every message as one flat record in session_message (id, session_id, type, seq, time_created, time_updated, data); the session, message and part tables txcript queries are gone.

  2. continue --with opencode fails. The top-level opencode import command no longer exists; it is opencode session import <file> [--directory <dir>] now. txcript's save runs opencode import <staged file> and gets:

    error: cannot convert to opencode: `opencode import` failed:
    ERROR
      Unexpected positional argument: "…\opencode-import-20033d02-ce35-4d65-a630-10f98d7f9be4.json"
    
  3. The staged export is rejected by the new importer. Feeding the file txcript left behind to opencode session import returns 400 Bad Request. The server log shows why:

    schema rejection … reason="Missing key\n  at [\"info\"][\"projectID\"]"
    

    and, after adding the header fields the 2.1 schema requires (projectID, cost, tokens, location.directory):

    schema rejection … reason="Expected Session.Message.Info\n  at [\"messages\"][0]"
    

    The 2.1 transfer is { info, messages: [ <flat records> ] }: a message is { id, type: "user" | "assistant" | "shell" | "compaction" | …, time: { created }, … } with an assistant's text, reasoning and tool calls in its content array, and a tool's result inside the call's state. There is no { info, parts } pair any more. The importer's legacy decoder (session-legacy.ts) only renames native-data keys (state/providerState → native); it does not accept the 2.0 layout.

I expected txcript list --from opencode to show the sessions, and txcript continue ./run.json --with opencode to create a session in OpenCode 2.1.

How to reproduce

run.json (Simple document):

{
  "cwd": "D:\\demo",
  "title": "Import probe",
  "messages": [
    { "role": "user", "content": "List the files in the project." },
    { "role": "assistant", "content": [
      { "type": "tool_use", "id": "call_1", "name": "Bash", "input": { "command": "ls" } } ] },
    { "role": "user", "content": [
      { "type": "tool_result", "tool_use_id": "call_1", "content": "README.md\nsrc" } ] },
    { "role": "assistant", "content": "Two entries: README.md and src." }
  ]
}
opencode --version                                   # opencode v2.1.4
txcript list --from opencode                         # no local opencode sessions found (DB has sessions)
txcript continue .\run.json --with opencode --no-resume
# error: cannot convert to opencode: `opencode import` failed: … Unexpected positional argument …

# the staged file is left in %TEMP%; hand it to the 2.1 command directly:
opencode session import $env:TEMP\opencode-import-<uuid>.json --directory D:\demo --print-logs --log-level warn
# schema rejection … Missing key at ["info"]["projectID"] → Error: Failed to import session: Bad Request

A minimal transcript that 2.1.4 accepts is the fixture in OpenCode's own CLI test (packages/cli/test/import-export.test.ts): info with id, projectID, cost, tokens, time { created, updated }, title, location { directory }, and messages as flat { id, type: "user", text, time { created } } records.

Versions

  • txcript: 0.14.4 (release binary, x86_64-pc-windows-msvc). main at 851a257 still runs opencode import (src/harness/opencode.rs).
  • Agents and their versions: OpenCode 2.1.4 (opencode --version).
  • Operating system: Windows 11.

Upstream references (OpenCode v2.1.4)

I am preparing a PR: detect the 2.1 layout in the store (read session_v2 + session_message, keep the 2.0 tables working), and on save pick the CLI command and transcript shape from opencode --version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions