earendil-works/pi · error · JsonlDecodeError

syntax

syntax

Error message

is not valid JSON

What it means

Error "is not valid JSON" thrown in earendil-works/pi.

Source

Thrown at packages/agent/src/harness/session/jsonl/codec.ts:38

	"step_attempt",
	"tool_started",
	"queue_enqueued",
	"queue_cancelled",
	"write_deferred",
	"usage",
]);
const OPERATION_KINDS = new Set(["run", "compaction", "navigation"]);

function isObject(value: unknown): value is Record<string, unknown> {
	return typeof value === "object" && value !== null && !Array.isArray(value);
}

function parseObject(line: string): Record<string, unknown> {
	let value: unknown;
	try {
		value = JSON.parse(line);
	} catch (error) {
		throw new JsonlDecodeError("syntax", "is not valid JSON", error instanceof Error ? error : undefined);
	}
	if (!isObject(value)) throw new JsonlDecodeError("schema", "is not a JSON object");
	return value;
}

function requireString(value: unknown, field: string): string {
	if (typeof value !== "string") throw new JsonlDecodeError("schema", `has invalid ${field}`);
	return value;
}

function requireSequence(value: unknown): number {
	if (!Number.isSafeInteger(value) || (value as number) <= 0) {
		throw new JsonlDecodeError("schema", "has invalid seq");
	}
	return value as number;
}

function requireTimestamp(value: unknown): number {

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Fix the malformed JSONL line in the session file; validate each line with JSON.parse before writing, or delete the corrupt line.

When it happens

Trigger: Thrown at packages/agent/src/harness/session/jsonl/codec.ts:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/e26682b764f47c3a. Report an issue: GitHub.