{"slug": "parse-ai-coding-jsonl-safely-before-you-infer-completion", "title": "Parse AI Coding JSONL Safely Before You Infer Completion", "summary": "Agent Island v1.7.1 implements defensive JSONL parsing for AI coding transcripts, using platform-specific safeguards such as a 64 MiB backstop on macOS and a 1,000,000-character line skip on Windows. The system employs provider-aware projections, semantic ordering, and deduplication to safely infer session state from live coding-agent data.", "body_md": "JSONL is easy to underestimate. One object per line sounds like a format you can parse with a short loop. A live coding-agent transcript adds the cases that make that loop unsafe: a partial final append, an unusually large record, duplicate events, provider-specific envelopes, and old completion markers that later activity has invalidated.\n\nHere is the defensive design we use before inferring session state.\n\nDo not read an unbounded transcript into one string. Use a streaming reader and a documented line policy. Agent Island v1.7.1 currently uses different released safeguards on each platform: the macOS Claude reader has a 64 MiB backstop, while the Windows reader skips a line above 1,000,000 characters before parsing.\n\nThose are not one shared limit. They are platform-specific policies with the same goal: one malformed or pathological record should not take down the rest of the scan.\n\nBroad deserialization creates accidental dependencies on unrelated payloads. A monitor needs a smaller provider-aware projection.\n\nFor Claude, useful fields include `type`\n\n, `uuid`\n\n, `timestamp`\n\n, `message.stop_reason`\n\n, `isSidechain`\n\n, `isApiErrorMessage`\n\n, and `toolEndsTurn`\n\n. For Codex, released readers inspect fields such as `type`\n\n, `payload.type`\n\n, `payload.turn_id`\n\n, `role`\n\n, `timestamp`\n\n, `completed_at`\n\n, and `started_at`\n\n.\n\n``` php\nread bounded line\n  -> parse JSON\n  -> project provider-specific fields\n  -> attach identity and semantic time\n  -> reduce ordered events into state\n```\n\nA completion-shaped event belongs to one turn. A later user message or start event means the session moved on. The reducer must compare semantic order and allow later activity to supersede the older completion.\n\nThis is also why file modification time is not enough. One file can contain several turns, and the newest event may contradict an earlier stop marker.\n\nA syntactically valid line can still be semantically wrong for a foreground alert.\n\nRun provider-specific guards before the generic completion reducer.\n\nAgent Island watches JSONL files for changes and keeps polling as a fallback. Event-driven observation reduces delay; polling recovers from a missed watcher notification. A partial line skipped now can be reconsidered after the next append.\n\nCaching unchanged files by path, size, and modification time is useful, but the cache must invalidate when the source changes. Caching is an optimization, not permission to freeze an old state.\n\nSafe JSONL parsing is bounded I/O plus provider-aware semantics, ordering, deduplication, and refresh behavior. The complete implementation notes and current scope are in the [canonical guide](https://agent-island.dev/guides/parse-ai-coding-jsonl-safely/?utm_source=devto&utm_medium=content&utm_campaign=distribution_20260725).", "url": "https://wpnews.pro/news/parse-ai-coding-jsonl-safely-before-you-infer-completion", "canonical_source": "https://dev.to/agentis/parse-ai-coding-jsonl-safely-before-you-infer-completion-8j8", "published_at": "2026-07-24 19:58:00+00:00", "updated_at": "2026-07-24 20:01:50.962612+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "artificial-intelligence", "large-language-models"], "entities": ["Agent Island", "Claude", "Codex"], "alternates": {"html": "https://wpnews.pro/news/parse-ai-coding-jsonl-safely-before-you-infer-completion", "markdown": "https://wpnews.pro/news/parse-ai-coding-jsonl-safely-before-you-infer-completion.md", "text": "https://wpnews.pro/news/parse-ai-coding-jsonl-safely-before-you-infer-completion.txt", "jsonld": "https://wpnews.pro/news/parse-ai-coding-jsonl-safely-before-you-infer-completion.jsonld"}}