github / github/copilot-cli

Resuming a session can leave truncated and concatenated events in events.jsonl

未关闭
#4,098 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:sessions
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Describe the bug

A resumed session contained malformed JSONL records that prevented it from being resumed again.

Three physical lines each contained an incomplete event prefix immediately followed by a complete JSON event without a newline or separator:

```text
{"type":"assistant.message", ... {"type":"assistant.message", ...}
```

Parsing failed with:

> Expecting ',' delimiter

### Affected configuration

- GitHub Copilot CLI 1.0.71-0
- Linux
- Model: GPT-5.6 Sol (`gpt-5.6-sol`)
- Context window: 1.1M
- Reasoning effort: high
- Session resumed with `copilot --resume=`

The model configuration may not be directly relevant to JSONL persistence, but it is included to make the report reproducible.

### Observed behavior

The affected `events.jsonl` contained three malformed physical lines:

- One truncated `tool.execution_complete` prefix followed by a complete event.
- Two truncated `assistant.message` prefixes followed by complete events.
- The complete suffixes retained the same tool-call or message identifiers as their truncated prefixes.

The complete JSON object began before the preceding incomplete object had been closed or terminated with a newline. The session could not be resumed because the event log was not valid JSONL.

### Expected behavior

Session event writes should be atomic and serialized.

When resuming, the CLI should detect and recover from an incomplete trailing record rather than appending another event directly after it. Concurrent processes should also be prevented from writing to the same session without locking.

### Workaround

After backing up the session, I discarded each unrecoverable prefix and retained its complete JSON-event suffix. Once every physical line contained exactly one valid JSON object, the session resumed normally.

### Possible cause and related issue

Potential causes include:

- Resuming a session while another process still has it open.
- A process being interrupted during an event write.
- Missing locking or recovery around large or chunked JSONL writes.

The same session contained a 72 MB persisted `apply_patch` event reported in #4097. That unusually large write may have widened the failure window, but there is not enough evidence to claim both issues share the same root cause.

I have not attached `events.jsonl` because it contains conversation and tool history.

---

Investigated and filed with assistance from GitHub Copilot CLI.

贡献指南

打开贡献指南

调研方向

从 `copilot --resume=` 流程开始,跟踪会话恢复期间 `events.jsonl` 的写入和解析方式。如果可能,复现一次中断写入或并发写入,然后验证恢复的会话不会创建拼接的 JSONL 记录,并且不完整的尾部数据能够得到安全处理。

由索引模型根据 Issue 内容生成。

评估

技术栈
shell
领域
cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。