anomalyco / anomalyco/opencode

session: v2 import rejects V1 export JSON and its own export file (SchemaError missing keys)

Open
#49,314 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 16, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

v2.0.4 session import fails on both V1's opencode export output and V2's own
session export output — the exporter omits keys the importer requires. V1
sessions created after installing V2 have no supported migration path, and
export → import round-trips fail.

Environment

  • opencode 2.0.4 (opencode2, npm @opencode/cli), V1 1.18.31 (winget)
  • OS: Windows 11 (build 10.0.26100.8655)
  • Shell: pwsh 7.6.6
  • Plugins: @slkiser/opencode-quota@latest

Repro

  1. V1: opencode export <id> > s.json → V2: opencode2 session import s.json
    SchemaError: Missing key ["info"]["location"] (V1 exports info.directory)
  2. Fix infoMissing key [...]["state"]["error"] — importer requires
    state.error on every tool part
  3. opencode2 session export <id> > v2.json, re-import → same state.error
    failure: exporter omits error on 58/59 tool parts, so V2's own export
    can't round-trip
  4. Add error everywhere → Missing key [...]["state"]["content"][0]
    exporter omits content on error-status tools, importer wants non-empty

Expected

Import accepts V1 export JSON, and V2's own export round-trips.

Notes

  • Consistent, not intermittent. Same class as #21941 (fixed in 1.4.3, recurred here).
  • Install-time V1 migration gap is #41217 — CLI import is the only path for
    sessions created after install.
  • Import endpoint undocumented/experimental; migration guide has no session section.
  • Worked around with a custom converter (V1 → v2 shape); 736 msgs / 570 tool
    parts imported fine after.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.