Skip to content

[Bug] Agent internal markers leak into output due to PTY read boundary truncation on Linux (v1.0.28) #2793

@wujunwei

Description

@wujunwei

Describe the bug

When the Agent executes a command that outputs a large amount of text (e.g.,
writing a long markdown via cat << 'EOF'), the internal control markers (such
as BEGIN___COMMAND_OUTPUT_MARKER or similar) are occasionally leaked
into the final rendered output.

This issue is highly reproducible on Linux environments but rarely happens on
macOS. It appears to be a race condition caused by how the underlying PTY
chunks data. If an internal marker is split across two read() boundaries from
the PTY, the regex used to strip these markers fails, causing the marker
string to be treated as normal output.

Affected version

v1.0.28

Steps to reproduce the behavior

  1. Run the agent on a Linux environment.
    2. Trigger an action that causes the agent to send a very long text payload
    to the terminal (e.g., creating a file using a Heredoc). Example payload
    used:
    run cat > /tmp/test.md << 'EOF'
    \n# Zhang Shan 综合查询分析结果\n\n根据 internal-wiki
         知识系统检索结果,Zhang Shan 对应的中文全名大概率是
         张山峰,目前系统关联到的历史信息主要涵盖以下两大部分内容:\n\n## 1.
         核心工作背景\n- 所属部门:核心基础架构研发平台组\n- 重点方向:NLP /
         深度学习大模型 / Embedding 向量化技术
    \n-
         相关技术分享:《深度学习特征工程与Embedding的业务实践应用深度解析》\n-
         主要内容涉及:\n  - One-hot 到稠密向量表征的演进\n  -
         Word2Vec、GloVe、BERT、GPT 等语义建模思路\n  - Embedding
         在语义搜索、推荐系统、多模态场景中的应用\n\n参考内部文档:\n-
         https://knowledge-base.internal.company.com/presentations/tech-sharing/9988
         77665544332211\n\n## 2. 高等教育与学术背景\n-
         毕业学校:南方科技重点大学计算机与软件学院\n-
         攻读专业:软件工程与人工智能方向(2021级)\n-
         毕业课题设计:**《基于分布式图数据库构建的复杂企业关系网络系统开发与演进》*
         *\n- 项目核心技术点:\n  - 图数据库存储复杂关联数据\n  -
         关系型数据库存储结构化数据\n  - 网页表单录入与知识图谱构建\n-
         答辩现场表现:逻辑思路清晰、专业提问回答准确,最终成绩评估为 88.5
         分
    \n\n参考内部文档:\n-
         https://knowledge-base.internal.company.com/documents/graduation-thesis/112
         233445566778899\n\n## 3. 综合整体判断\n内部知识系统里记录的 Zhang
         Shan
    ,从历史表现基本可以综合判定为一位:\n-
         具备非常扎实的软件工程科班学术背景\n-
         当前高度活跃于核心基础架构平台相关的研发工作\n- 对 Embedding、NLP
         算法、图数据库方向有着极强技术积累的资深研发工程师\nOF\n
    EOF

Expected behavior

The agent should correctly parse and The final rendered output should be clean.

Actual Behavior
The internal shell markers leak into the UI. For example, the rendered output
randomly contains strings like:

1 { echo BEGIN___COMMAND_OUTPUT_MARKER; PS1="";PS2="";unset HISTFILE;
EC=$?; echo "BEGIN___COMMAND_DONE_MARKER$EC"; }
Sometimes it also causes command inputs to interleave with outputs

Additional context

OS: Linux (Highly reproducible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platform-linuxLinux-specific: Wayland, X11, Ubuntu, Fedora, Alpine, ARM, terminal emulatorsarea:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions