Bug Description
The patch tool intermittently corrupts the await keyword when applying changes to TypeScript/TSX files, replacing it with ***.
Reproduction
This has occurred multiple times in our Next.js project when patching React components:
Example 1
File: apps/web/app/[locale]/dashboard/blog/new/page.tsx
- Before patch:
const token = await getToken();
- After patch:
const token=*** getToken();
Example 2
File: apps/web/app/[locale]/dashboard/blog/[id]/edit/page.tsx
- Before patch:
const token = await getToken();
- After patch:
const token=*** getToken();
Both instances:
- Used the same
patch tool with mode: replace
- Targeted lines containing
await keyword
- Resulted in corrupted syntax that broke the build
Environment
- OS: Linux (containerized environment)
- File types affected:
.tsx, .ts
- Hermes Agent version: Latest (as of March 2026)
- Project: Next.js 14 + TypeScript
Impact
- Silent failures: The patch reports success, but the file is corrupted
- Build breaks: TypeScript compilation fails with cryptic errors
- Time loss: Requires manual investigation and fix
Workaround
After any patch operation on files containing await, manually verify the file content:
# Check for corruption
grep -n "\*\*\*" apps/web/app/**/*.tsx
Suggested Fix
The patch tool should:
- Validate output is valid TypeScript/JavaScript syntax before reporting success
- Add a pre-flight check for common keyword corruption patterns
- Consider using AST-aware patching for code files instead of text replacement
Additional Context
The corruption appears related to how the tool handles special characters or encoding around async/await keywords. This is a critical reliability issue for automated code editing workflows.
Bug Description
The
patchtool intermittently corrupts theawaitkeyword when applying changes to TypeScript/TSX files, replacing it with***.Reproduction
This has occurred multiple times in our Next.js project when patching React components:
Example 1
File:
apps/web/app/[locale]/dashboard/blog/new/page.tsxconst token = await getToken();const token=*** getToken();Example 2
File:
apps/web/app/[locale]/dashboard/blog/[id]/edit/page.tsxconst token = await getToken();const token=*** getToken();Both instances:
patchtool withmode: replaceawaitkeywordEnvironment
.tsx,.tsImpact
Workaround
After any patch operation on files containing
await, manually verify the file content:Suggested Fix
The patch tool should:
Additional Context
The corruption appears related to how the tool handles special characters or encoding around async/await keywords. This is a critical reliability issue for automated code editing workflows.