Skip to content

[BUG] Edit tool writes hash prefix into file content #17620

@ouyangxin1981

Description

@ouyangxin1981

Bug Description

The Edit tool occasionally writes hash prefix markers into the actual file content instead of just using them as internal line references.

Example of corrupted output:

#KW|'use client';
#KM|
#XW|import { useEffect, useRef, useState } from 'react';

Expected output:

'use client';

import { useEffect, useRef, useState } from 'react';

Root Cause

The Edit tool uses internal line references in the format {line_number}#{hash_id} where hash_id is from the set ZPMQVRWSNKTXJBYH. There appears to be a bug where these hash IDs are occasionally written into the actual file content instead of being used purely as internal references.

Impact

  • TypeScript/JavaScript files become syntactically invalid
  • Build failures
  • Requires manual file rewrite to fix

Workaround

Use Write tool (full file rewrite) instead of Edit tool.

Environment

  • OpenCode version: Latest
  • OS: Linux

Steps to Reproduce

  1. Use Edit tool to make changes to a TypeScript file
  2. Observe that hash prefix like #KW|, #KM|, #XW| appear at the start of lines

Frequency

This has occurred multiple times across different files in this project.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions