siyuan-note/siyuan · error

unsupported agent runtime schema version

Error message

unsupported agent runtime schema version: %d

What it means

loadRuntimeLocked unmarshals the persisted session runtime JSON and rejects any runtime whose SchemaVersion exceeds the highest version this kernel build understands (currently 1). This guards against forward-compatibility breakage: a newer SiYuan wrote the runtime file, and an older build is trying to read it.

Solutions

  1. Upgrade the kernel to a build that supports the runtime's schema version (SchemaVersion <= 1 for this build)
  2. If downgrade is intentional, delete or regenerate the affected agent session runtime files, accepting loss of that session's runtime state
  3. Confirm the workspace was not synced from a newer installation and pin all installations to the same kernel version
Defensive patterns

Strategy: try-catch

Validate before calling

const runtime = JSON.parse(readRuntimeFile());
if (runtime.schemaVersion > 1) throw new Error("runtime written by a newer kernel; upgrade required");

Try / catch

try { beginRuntimeTurn(sessionID, turn) } catch (err) {
  if (strings.Contains(err.Error(), "unsupported agent runtime schema version")) {
    // surface an "upgrade required" message instead of retrying
  }
}

Prevention

When it happens

Trigger: Loading a session.json runtime file written by a newer kernel version where runtime.SchemaVersion > 1, via any of loadRuntimeLocked's callers (SetSessionPermissionMode, beginRuntimeTurn, saveRuntimeTurn, saveRuntimeCompaction, loadRuntimeState, resolveSessionPermissionModeLocked).

Common situations: Downgrading the SiYuan kernel after a newer version created agent sessions; syncing a workspace between machines running different kernel versions; restoring a backup made by a newer build.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/ad34bd7739dbb499. Report an issue: GitHub.

Appendix: source

Thrown at kernel/agent/runtime.go:204

func runtimePath(sessionID string) string {
	return filepath.Join(sessionsDir(), sessionID, "runtime.json")
}

func loadRuntimeLocked(sessionID string) (*agentRuntime, error) {
	data, err := os.ReadFile(runtimePath(sessionID))
	if err != nil {
		if os.IsNotExist(err) {
			return &agentRuntime{SchemaVersion: 1, SessionID: sessionID}, nil
		}
		return nil, err
	}
	var runtime agentRuntime
	if err := gulu.JSON.UnmarshalJSON(data, &runtime); err != nil {
		return nil, err
	}
	if runtime.SchemaVersion > 1 {
		return nil, fmt.Errorf("unsupported agent runtime schema version: %d", runtime.SchemaVersion)
	}
	if runtime.SessionID != "" && runtime.SessionID != sessionID {
		return nil, fmt.Errorf("agent runtime session id mismatch")
	}
	if runtime.Revision < 0 {
		return nil, fmt.Errorf("invalid agent runtime revision")
	}
	if runtime.ActiveTurn != nil {
		if runtime.ActiveTurn.TurnID == "" {
			return nil, fmt.Errorf("invalid agent runtime turn id")
		}
		switch runtime.ActiveTurn.State {
		case "running", "finished", "interrupted":
		default:
			return nil, fmt.Errorf("invalid agent runtime turn state")
		}
	}
	if runtime.SchemaVersion == 0 {

View on GitHub (pinned to 9f775e8a12)